[Lldb-commits] [lldb] [lldb] Fix SBMemoryRegionInfoListExtensions iter to yield unique refe… (PR #144815)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 18 17:51:58 PDT 2025
================
@@ -154,14 +154,32 @@ def test_find_in_memory_unaligned(self):
self.assertEqual(addr, lldb.LLDB_INVALID_ADDRESS)
def test_memory_info_list_iterable(self):
- """Make sure the SBMemoryRegionInfoList is iterable"""
+ """Make sure the SBMemoryRegionInfoList is iterable and each yielded object is unique"""
self.assertTrue(self.process, PROCESS_IS_VALID)
self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
info_list = self.process.GetMemoryRegions()
self.assertTrue(info_list.GetSize() > 0)
+
+ collected_info = []
try:
- for info in info_list:
- pass
+ for region in info_list:
+ collected_info.append(region)
except Exception:
self.fail("SBMemoryRegionInfoList is not iterable")
+
+ self.assertTrue(len(collected_info) >= 2, "Need at least 2 items")
+ self.assertEqual(len(collected_info), info_list.GetSize(), "Should have collected all items")
+
+ for i in range(len(collected_info)):
+ region = lldb.SBMemoryRegionInfo()
+ info_list.GetMemoryRegionAtIndex(i, region)
+
+ self.assertEqual(collected_info[i].GetRegionBase(), region.GetRegionBase(),
----------------
Jlalond wrote:
Nit: We should just add an equality method to SBMemoryRegionInfo and call that.
https://github.com/llvm/llvm-project/pull/144815
More information about the lldb-commits
mailing list