Skip to content

Commit 927e8d4

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b6dfaf4c291e' from llvm.org/main into next
2 parents a646bb8 + b6dfaf4 commit 927e8d4

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

lldb/docs/use/python-reference.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,34 +491,42 @@ which will work like all the natively defined lldb commands. This provides a
491491
very flexible and easy way to extend LLDB to meet your debugging requirements.
492492

493493
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:
495495

496496
::
497497

498-
def command_function(debugger, command, result, internal_dict):
498+
def command_function(debugger, command, exe_ctx, result, internal_dict):
499499
# Your code goes here
500500

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:
502505

503506
::
504507

505508
def command_function(debugger, command, result, internal_dict):
506509
"""This command takes a lot of options and does many fancy things"""
507510
# Your code goes here
508511

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).
512513

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:
516516

517517
::
518518

519-
def command_function(debugger, command, exe_ctx, result, internal_dict):
519+
def command_function(debugger, command, result, internal_dict):
520520
# Your code goes here
521521

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+
522530
+-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
523531
| Argument | Type | Description |
524532
+-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)