aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
authorjimingham <jingham@apple.com>2024-04-11 15:22:58 -0700
committerGitHub <noreply@github.com>2024-04-11 15:22:58 -0700
commit9a36077e4db30c7da603620762036d4a430e4e62 (patch)
tree4418eac035626b93b6b876d1eefcae8524bab92b /lldb/test/API/python_api
parent95fbd8d19dff10b5a734e3db1b29cba2da7a983f (diff)
downloadllvm-9a36077e4db30c7da603620762036d4a430e4e62.zip
llvm-9a36077e4db30c7da603620762036d4a430e4e62.tar.gz
llvm-9a36077e4db30c7da603620762036d4a430e4e62.tar.bz2
Fix error in unrecognized register name handling for "SBFrame.register" (#88047)
The code returned lldb.SBValue() when you passed in an unrecognized register name. But referring to "lldb" is apparently not legal within the module. I changed this to just return SBValue(), but then this construct: (lldb) script >>> for reg_set in lldb.target.process.thread[0].frames[0].register ... print(reg) Runs forever printing "No Value". The __getitem__(key) gets called with a monotonically increasing by 1 series of integers. I don't know why Python decided the class we defined should have a generator that returns positive integers in order, but we can add a more useful one here by returning an iterator over the flattened list of registers. Note, the not very aptly named "SBFrame.registers" is an iterator over register sets, not registers, so the two are not redundant.
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/frame/TestFrames.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/frame/TestFrames.py b/lldb/test/API/python_api/frame/TestFrames.py
index a82b129..dfa96d5 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -73,7 +73,19 @@ class FrameAPITestCase(TestBase):
gpr_reg_set = lldbutil.get_GPRs(frame)
pc_value = gpr_reg_set.GetChildMemberWithName("pc")
self.assertTrue(pc_value, "We should have a valid PC.")
+ # Make sure we can also get this from the "register" property:
+ iterator_pc_value = 0
+ found_pc = False
+ for reg in frame.register:
+ if reg.name == "pc":
+ found_pc = True
+ iterator_pc_value = int(reg.GetValue(), 0)
+ break
+
pc_value_int = int(pc_value.GetValue(), 0)
+ self.assertTrue(found_pc, "Found the PC value in the register list")
+ self.assertEqual(iterator_pc_value, pc_value_int, "The methods of finding pc match")
+
# Make sure on arm targets we dont mismatch PC value on the basis of thumb bit.
# Frame PC will not have thumb bit set in case of a thumb
# instruction as PC.