Skip to content

Commit 615bd9e

Browse files
authored
Add docs and an example use of the scripted command get_flags API. (#109176)
The API is present, and we even have a test for it, but it isn't documented so no one probably knows you can set requirements for your scripted commands. This just adds docs and uses it appropriately in the `framestats` example command.
1 parent 9f5139c commit 615bd9e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lldb/docs/use/python-reference.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ which should implement the following interface:
562562
this call should return the short help text for this command[1]
563563
def get_long_help(self):
564564
this call should return the long help text for this command[1]
565+
def get_flags(self):
566+
this will be called when the command is added to the command interpreter,
567+
and should return a flag field made from or-ing together the appropriate
568+
elements of the lldb.CommandFlags enum to specify the requirements of this command.
569+
The CommandInterpreter will make sure all these requirements are met, and will
570+
return the standard lldb error if they are not.[1]
565571
def get_repeat_command(self, command):
566572
The auto-repeat command is what will get executed when the user types just
567573
a return at the next prompt after this command is run. Even if your command

lldb/examples/python/cmdtemplate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def register_lldb_command(cls, debugger, module_name):
2525
'--help" for detailed help.'.format(cls.program)
2626
)
2727

28+
def get_flags(self):
29+
return lldb.eCommandRequiresFrame | lldb.eCommandProcessMustBePaused
30+
2831
def setup_command_definition(self):
2932

3033
self.ov_parser.add_option(

0 commit comments

Comments
 (0)