@@ -491,34 +491,42 @@ which will work like all the natively defined lldb commands. This provides a
491
491
very flexible and easy way to extend LLDB to meet your debugging requirements.
492
492
493
493
To write a python function that implements a new LLDB command define the
494
- function to take four arguments as follows:
494
+ function to take five arguments as follows:
495
495
496
496
::
497
497
498
- def command_function(debugger, command, result, internal_dict):
498
+ def command_function(debugger, command, exe_ctx, result, internal_dict):
499
499
# Your code goes here
500
500
501
- Optionally, you can also provide a Python docstring, and LLDB will use it when providing help for your command, as in:
501
+ The meaning of the arguments is given in the table below.
502
+
503
+ If you provide a Python docstring in your command function LLDB will use it
504
+ when providing "long help" for your command, as in:
502
505
503
506
::
504
507
505
508
def command_function(debugger, command, result, internal_dict):
506
509
"""This command takes a lot of options and does many fancy things"""
507
510
# Your code goes here
508
511
509
- Since lldb 3.5.2, LLDB Python commands can also take an SBExecutionContext as an
510
- argument. This is useful in cases where the command's notion of where to act is
511
- independent of the currently-selected entities in the debugger.
512
+ though providing help can also be done programmatically (see below).
512
513
513
- This feature is enabled if the command-implementing function can be recognized
514
- as taking 5 arguments, or a variable number of arguments, and it alters the
515
- signature as such:
514
+ Prior to lldb 3.5.2 (April 2015), LLDB Python command definitions didn't take the SBExecutionContext
515
+ argument. So you may still see commands where the command definition is:
516
516
517
517
::
518
518
519
- def command_function(debugger, command, exe_ctx, result, internal_dict):
519
+ def command_function(debugger, command, result, internal_dict):
520
520
# Your code goes here
521
521
522
+ Using this form is strongly discouraged because it can only operate on the "currently selected"
523
+ target, process, thread, frame. The command will behave as expected when run
524
+ directly on the command line. But if the command is used in a stop-hook, breakpoint
525
+ callback, etc. where the response to the callback determines whether we will select
526
+ this or that particular process/frame/thread, the global "currently selected"
527
+ entity is not necessarily the one the callback is meant to handle. In that case, this
528
+ command definition form can't do the right thing.
529
+
522
530
+-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
523
531
| Argument | Type | Description |
524
532
+-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
0 commit comments