[Lldb-commits] [PATCH] D134030: [LLDB] Fix "memory region --all" when there is no ABI plugin

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 23 05:32:44 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc831cea5efaa: [LLDB] Fix "memory region --all" when there is no ABI plugin (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134030/new/

https://reviews.llvm.org/D134030

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/API/functionalities/memory-region/TestMemoryRegion.py


Index: lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
===================================================================
--- lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -160,4 +160,38 @@
         interp.HandleCommand("memory region --all ", result)
         self.assertFalse(result.Succeeded())
         self.assertEqual(result.GetError(),
-                    "error: qMemoryRegionInfo is not supported\n")
\ No newline at end of file
+                    "error: qMemoryRegionInfo is not supported\n")
+
+    @skipIfAsan
+    def test_all_no_abi_plugin(self):
+        # There are two conditions for breaking the all loop. Either we get to
+        # LLDB_INVALID_ADDRESS, or the ABI plugin tells us we have got beyond
+        # the mappable range. If we don't have an ABI plugin, the option should still
+        # work and only check the first condition.
+
+        class MyResponder(MockGDBServerResponder):
+            def qMemoryRegionInfo(self, addr):
+                if addr == 0:
+                    return "start:0;size:100000000;"
+                # Goes until the end of memory.
+                if addr == 0x100000000:
+                    return "start:100000000;size:fffffffeffffffff;"
+
+        self.server.responder = MyResponder()
+        target = self.dbg.CreateTarget('')
+        if self.TraceOn():
+          self.runCmd("log enable gdb-remote packets")
+          self.addTearDownHook(
+                lambda: self.runCmd("log disable gdb-remote packets"))
+
+        process = self.connect(target)
+        lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+                                      [lldb.eStateStopped])
+
+        interp = self.dbg.GetCommandInterpreter()
+        result = lldb.SBCommandReturnObject()
+        interp.HandleCommand("memory region --all ", result)
+        self.assertTrue(result.Succeeded())
+        self.assertEqual(result.GetOutput(),
+                    "[0x0000000000000000-0x0000000100000000) ---\n"
+                    "[0x0000000100000000-0xffffffffffffffff) ---\n")
Index: lldb/source/Commands/CommandObjectMemory.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -1821,7 +1821,7 @@
              // When there are non-address bits the last range will not extend
              // to LLDB_INVALID_ADDRESS but to the max virtual address.
              // This prevents us looping forever if that is the case.
-             (abi && (abi->FixAnyAddress(addr) == addr))) {
+             (!abi || (abi->FixAnyAddress(addr) == addr))) {
         lldb_private::MemoryRegionInfo region_info;
         error = process_sp->GetMemoryRegionInfo(addr, region_info);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134030.462453.patch
Type: text/x-patch
Size: 2881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220923/ea3f7eb3/attachment-0001.bin>


More information about the lldb-commits mailing list