https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/177559

>From b72ee4fa8e94caaf0fd1439fc2736a43aa0c8634 Mon Sep 17 00:00:00 2001
From: David Spickett <[email protected]>
Date: Fri, 23 Jan 2026 09:45:40 +0000
Subject: [PATCH] [lldb] Improve error and docs for repeating "memory region"

"memory region" can be given an address once and then when repeated,
it will try to find a region just beyond the last one it printed.
This continues until the end of the address space.

Then it gives you an error showing the usage, which is odd because
you just saw a bunch of "memory region" with no options work.

So I've improved the error a bit to imply its to do with the repetition.
Then described the repeating behaviour in the help text.
---
 lldb/source/Commands/CommandObjectMemory.cpp  | 23 ++++++++++++-------
 .../memory-region/TestMemoryRegion.py         |  2 +-
 .../completions/TestDAP_completions.py        |  9 ++++++--
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index eabe2fb4c4483..49c91028108ca 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1651,12 +1651,18 @@ class CommandObjectMemoryRegion : public 
CommandObjectParsed {
   };
 
   CommandObjectMemoryRegion(CommandInterpreter &interpreter)
-      : CommandObjectParsed(interpreter, "memory region",
-                            "Get information on the memory region containing "
-                            "an address in the current target process.",
-                            "memory region <address-expression> (or --all)",
-                            eCommandRequiresProcess | eCommandTryTargetAPILock 
|
-                                eCommandProcessMustBeLaunched) {
+      : CommandObjectParsed(
+            interpreter, "memory region",
+            "Get information on the memory region containing "
+            "an address in the current target process.\n"
+            "If this command is given an <address-expression> once "
+            "and then repeated without options, it will try to print "
+            "the memory region that follows the previously printed "
+            "region. The command can be repeated until the end of "
+            "the address range is reached.",
+            "memory region <address-expression> (or --all)",
+            eCommandRequiresProcess | eCommandTryTargetAPILock |
+                eCommandProcessMustBeLaunched) {
     // Address in option set 1.
     m_arguments.push_back(CommandArgumentEntry{CommandArgumentData(
         eArgTypeAddressOrExpression, eArgRepeatPlain, LLDB_OPT_SET_1)});
@@ -1747,8 +1753,9 @@ class CommandObjectMemoryRegion : public 
CommandObjectParsed {
             // we must be at the end of the mappable range.
             (abi && (abi->FixAnyAddress(load_addr) != load_addr))) {
           result.AppendErrorWithFormat(
-              "'%s' takes one argument or \"--all\" option:\nUsage: %s\n",
-              m_cmd_name.c_str(), m_cmd_syntax.c_str());
+              "No next region address set: one address expression argument or "
+              "\"--all\" option required:\nUsage: %s\n",
+              m_cmd_syntax.c_str());
           return;
         }
       }
diff --git a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py 
b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
index 50182e72e498c..85b378ccd0990 100644
--- a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -54,7 +54,7 @@ def test_command(self):
         self.assertFalse(result.Succeeded())
         self.assertEqual(
             result.GetError(),
-            "error: 'memory region' takes one argument or \"--all\" option:\n"
+            'error: No next region address set: one address expression 
argument or "--all" option required:\n'
             "Usage: memory region <address-expression> (or --all)\n",
         )
 
diff --git a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
index 3996bdf77242d..dd5fdcc4bbad4 100644
--- a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
+++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
@@ -162,10 +162,15 @@ def test_command_completions(self):
                     ),
                     CompletionItem(
                         label="region",
-                        detail="Get information on the memory region 
containing an address in the current target process.",
+                        detail="Get information on the memory region 
containing an address "
+                        "in the current target process.\nIf this command is 
given an "
+                        "<address-expression> once and then repeated without 
options, "
+                        "it will try to print the memory region that follows 
the "
+                        "previously printed region. The command can be 
repeated "
+                        "until the end of the address range is reached.",
                     ),
                 },
-            )
+            ),
         )
 
         # Provides completions for parameter values of commands

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to