[Lldb-commits] [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 25 14:32:36 PDT 2017


jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

Use the form of the command that gets an SBExecutionContext, then you can avoid having to cache the target at all.



================
Comment at: utils/clangdiag.py:98-100
+def the_diag_command(debugger, command, result, dict):
+    # Use the Shell Lexer to properly parse up command options just like a
+    # shell would
----------------
If you use the form of the command function that takes an execution context:

def command_function(debugger, command, exe_ctx, result, internal_dict):

then you can grab the target from there when the command gets invoked and pass it to your enable & disable funcs.  That way you won't have to rely on GetSelectedTarget.  That's important, for instance, if you were running a debug session with two targets and you wanted to invoke your command in a breakpoint command of a breakpoint in target A.  There's no guarantee when target A hits the breakpoint that A is the currently selected target (it won't get selected till it actually decides  to stop.)  But when the breakpoint runs its command, it sets the right target, & thread in the execution context that gets passed in.


https://reviews.llvm.org/D36347





More information about the lldb-commits mailing list