aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
authorLuke Riddle <35970909+lukejriddle@users.noreply.github.com>2024-12-03 13:29:12 -0500
committerGitHub <noreply@github.com>2024-12-03 10:29:12 -0800
commit2a1a02461a8d4ae9f560a4215fe85a1f085b4d82 (patch)
treed5c64c1ec2ed3ea95f6dd1f60d2ca126dd9d054a /lldb/test/API/python_api
parente8b9e1354accf33ced45321abdd8c8bc65d025cc (diff)
downloadllvm-2a1a02461a8d4ae9f560a4215fe85a1f085b4d82.zip
llvm-2a1a02461a8d4ae9f560a4215fe85a1f085b4d82.tar.gz
llvm-2a1a02461a8d4ae9f560a4215fe85a1f085b4d82.tar.bz2
Make SBMemoryRegionInfoList iterable with Python SWIG (#117358)
This PR fixes a simple SWIG issue with SBMemoryRegionInfoList not being iterable out-of-the-box. This is mostly because of limitations to the `lldb_iter` function, which doesn't allow for specifying arguments to the size / iter functions passed. Before: ``` (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> for region in lldb.process.GetMemoryRegions(): ... print(region) ... Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/llvm/stable/Toolchains/llvm-sand.xctoolchain/usr/lib/python3.10/site-packages/lldb/__init__.py", line 114, in lldb_iter yield elem(i) TypeError: SBMemoryRegionInfoList.GetMemoryRegionAtIndex() missing 1 required positional argument: 'region_info' ``` After: ``` (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> for region in lldb.process.GetMemoryRegions(): ... print(region) ... [0x0000000000200000-0x00000000002cf000 R--] [0x00000000002cf000-0x0000000000597000 R-X] [0x0000000000597000-0x00000000005ad000 R--] [0x00000000005ad000-0x00000000005b1000 RW-] [0x00000000005b1000-0x0000000000b68000 RW-] [0x000000007fff7000-0x000000008fff7000 RW-] [0x000002008fff7000-0x000010007fff8000 RW-] [0x0000503000000000-0x0000503000010000 RW-] [0x0000503e00000000-0x0000503e00010000 RW-] [0x0000504000000000-0x0000504000010000 RW-] [0x0000504e00000000-0x0000504e00010000 RW-] [0x000050d000000000-0x000050d000010000 RW-] [0x000050de00000000-0x000050de00010000 RW-] [0x000050e000000000-0x000050e000010000 RW-] [0x000050ee00000000-0x000050ee00010000 RW-] [0x0000511000000000-0x0000511000010000 RW-] [0x0000511e00000000-0x0000511e00010000 RW-] [0x0000513000000000-0x0000513000010000 RW-] ... ```
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/find_in_memory/TestFindInMemory.py13
1 files changed, 13 insertions, 0 deletions
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 04e807c..1ef37d2 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 @@ class FindInMemoryTestCase(TestBase):
)
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")