[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 16 05:54:17 PDT 2022
DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
There are two conditions for the loop exit. Either we hit LLDB_INVALID_ADDRESS
or the ABI tells us we are beyond mappable memory.
I made a mistake in that second part that meant if you had no ABI plugin
--all would stop on the first loop and return nothing.
If there's no ABI plugin we should only check for LLDB_INVALID_ADDRESS.
Depends on D134029 <https://reviews.llvm.org/D134029>
Repository:
rG LLVM Github Monorepo
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.460708.patch
Type: text/x-patch
Size: 2881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220916/f0f59cf7/attachment.bin>
More information about the lldb-commits
mailing list