Skip to content

Add docs and an example use of the scripted command get_flags API. #109176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

jimingham
Copy link
Collaborator

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.

@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2024

@llvm/pr-subscribers-lldb

Author: None (jimingham)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/109176.diff

2 Files Affected:

  • (modified) lldb/docs/use/python-reference.rst (+6)
  • (modified) lldb/examples/python/cmdtemplate.py (+3)
diff --git a/lldb/docs/use/python-reference.rst b/lldb/docs/use/python-reference.rst
index 041e541a96f083..b12048f1af067d 100644
--- a/lldb/docs/use/python-reference.rst
+++ b/lldb/docs/use/python-reference.rst
@@ -562,6 +562,12 @@ which should implement the following interface:
           this call should return the short help text for this command[1]
       def get_long_help(self):
           this call should return the long help text for this command[1]
+      def get_flags(self):
+          this will be called when the command is added to the command interpreter,
+          and should return a flag field made from or-ing together the appropriate
+          elements of the lldb.CommandFlags enum to specify the requirements of this command.
+          The CommandInterpreter will make sure all these requirements are met, and will
+          return the standard lldb error if they are not.[1]
       def get_repeat_command(self, command):
           The auto-repeat command is what will get executed when the user types just
           a return at the next prompt after this command is run.  Even if your command
diff --git a/lldb/examples/python/cmdtemplate.py b/lldb/examples/python/cmdtemplate.py
index 9a96888508b6f2..b6a21cba7113e6 100644
--- a/lldb/examples/python/cmdtemplate.py
+++ b/lldb/examples/python/cmdtemplate.py
@@ -25,6 +25,9 @@ def register_lldb_command(cls, debugger, module_name):
             '--help" for detailed help.'.format(cls.program)
         )
 
+    def get_flags(self):
+        return lldb.eCommandRequiresFrame | lldb.eCommandProcessMustBePaused
+
     def setup_command_definition(self):
 
         self.ov_parser.add_option(

@jimingham jimingham merged commit 615bd9e into llvm:main Sep 19, 2024
10 checks passed
@jimingham jimingham deleted the get_flags-docs branch September 19, 2024 01:10
Copy link
Member

@medismailben medismailben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

tmsri pushed a commit to tmsri/llvm-project that referenced this pull request Sep 19, 2024
…lvm#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants