https://github.com/lukejriddle updated https://github.com/llvm/llvm-project/pull/117358
>From c4a4b658daac89204d9e03ad5ef7a3cd7b474325 Mon Sep 17 00:00:00 2001 From: Luke Riddle <rid...@meta.com> Date: Fri, 22 Nov 2024 10:23:43 -0800 Subject: [PATCH 1/2] Make SBMemeoryRegionInfoList iterable with Python SWIG --- lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i b/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i index 49d49110de7ff9..29c0179c0ffe3e 100644 --- a/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i +++ b/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i @@ -7,7 +7,12 @@ def __iter__(self): '''Iterate over all the memory regions in a lldb.SBMemoryRegionInfoList object.''' - return lldb_iter(self, 'GetSize', 'GetMemoryRegionAtIndex') + import lldb + size = self.GetSize() + region = lldb.SBMemoryRegionInfo() + for i in range(size): + self.GetMemoryRegionAtIndex(i, region) + yield region %} #endif } >From a6fe10a7c68df2f5f8bed606c190777d505e820c Mon Sep 17 00:00:00 2001 From: Luke Riddle <rid...@meta.com> Date: Fri, 22 Nov 2024 11:37:13 -0800 Subject: [PATCH 2/2] Add unit test for SBMemoryRegionInfoList iter --- .../python_api/find_in_memory/TestFindInMemory.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py index 04e807c5c6201d..1ef37d2ec98988 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py @@ -152,3 +152,16 @@ def test_find_in_memory_unaligned(self): ) self.assertSuccess(error) self.assertEqual(addr, lldb.LLDB_INVALID_ADDRESS) + + def test_memory_info_list_iterable(self): + """Make sure the SBMemoryRegionInfoList is iterable""" + 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) + try: + for info in info_list: + pass + except Exception: + self.fail("SBMemoryRegionInfoList is not iterable") _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits