[Lldb-commits] [lldb] 760298a - [lldb] Specify aguments of `image list`

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Mon May 23 11:00:57 PDT 2022


Author: Dave Lee
Date: 2022-05-23T11:00:48-07:00
New Revision: 760298adc264f9c1029d93ab38711c131e19a2f4

URL: https://github.com/llvm/llvm-project/commit/760298adc264f9c1029d93ab38711c131e19a2f4
DIFF: https://github.com/llvm/llvm-project/commit/760298adc264f9c1029d93ab38711c131e19a2f4.diff

LOG: [lldb] Specify aguments of `image list`

Register positional argument details in `CommandObjectTargetModulesList`.

I recently learned that `image list` takes a module name, but the help info
does not indicate this. With this change, `help image list` will show that it
accepts zero or more module names.

This makes it easier to get info about specific modules, without having to
find/grep through the full image list.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D125154

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectTarget.cpp
    lldb/test/API/commands/help/TestHelp.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index f42588b673a46..7789698c1d678 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -50,6 +50,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Timer.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-enumerations.h"
 
 #include "llvm/ADT/ScopeExit.h"
@@ -2901,8 +2902,10 @@ class CommandObjectTargetModulesList : public CommandObjectParsed {
   CommandObjectTargetModulesList(CommandInterpreter &interpreter)
       : CommandObjectParsed(
             interpreter, "target modules list",
-            "List current executable and dependent shared library images.",
-            "target modules list [<cmd-options>]") {}
+            "List current executable and dependent shared library images.") {
+    CommandArgumentData module_arg{eArgTypeShlibName, eArgRepeatStar};
+    m_arguments.push_back({module_arg});
+  }
 
   ~CommandObjectTargetModulesList() override = default;
 

diff  --git a/lldb/test/API/commands/help/TestHelp.py b/lldb/test/API/commands/help/TestHelp.py
index e3363e870e5db..09e7a32a854ca 100644
--- a/lldb/test/API/commands/help/TestHelp.py
+++ b/lldb/test/API/commands/help/TestHelp.py
@@ -104,6 +104,13 @@ def test_help_image_du_line_should_work(self):
         self.expect("help image du line", substrs=[
                     'Dump the line table for one or more compilation units'])
 
+    @no_debug_info_test
+    def test_help_image_list_shows_positional_args(self):
+        """Command 'help image list' should describe positional args."""
+        # 'image' is an alias for 'target modules'.
+        self.expect("help image list", substrs=[
+                    '<shlib-name> [...]'])
+
     @no_debug_info_test
     def test_help_target_variable_syntax(self):
         """Command 'help target variable' should display <variable-name> ..."""


        


More information about the lldb-commits mailing list