-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] Add stop_description Python property to SBThread #151568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kastiglione
merged 3 commits into
llvm:main
from
kastiglione:lldb-Add-stop_reason-Python-property-to-SBThread
Jul 31, 2025
Merged
[lldb] Add stop_description Python property to SBThread #151568
kastiglione
merged 3 commits into
llvm:main
from
kastiglione:lldb-Add-stop_reason-Python-property-to-SBThread
Jul 31, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-lldb @llvm/pr-subscribers-backend-risc-v Author: Dave Lee (kastiglione) ChangesFull diff: https://github.com/llvm/llvm-project/pull/151568.diff 13 Files Affected:
diff --git a/lldb/bindings/interface/SBThreadExtensions.i b/lldb/bindings/interface/SBThreadExtensions.i
index 267faad9d651f..ea6f72e664f42 100644
--- a/lldb/bindings/interface/SBThreadExtensions.i
+++ b/lldb/bindings/interface/SBThreadExtensions.i
@@ -45,6 +45,9 @@ STRING_EXTENSION_OUTSIDE(SBThread)
frames.append(frame)
return frames
+ def get_stop_description(self):
+ return self.GetStopReasonDescription(1024)
+
def get_stop_reason_data(self):
return [
self.GetStopReasonDataAtIndex(idx)
@@ -69,6 +72,7 @@ STRING_EXTENSION_OUTSIDE(SBThread)
name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''')
queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''')
queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''')
+ stop_description = property(get_stop_description, None, doc='''A read only property that returns a string describing the reason this thread stopped.''')
stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''')
stop_reason_data = property(get_stop_reason_data, None, doc='''A read only property that returns the stop reason data as a list.''')
is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''')
diff --git a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
index 8179d5288ce8e..67dfbeadbd7d6 100644
--- a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
+++ b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -50,11 +50,11 @@ def test_step_over_read_watchpoint(self):
lldb.eStopReasonWatchpoint,
STOPPED_DUE_TO_WATCHPOINT,
)
- self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
+ self.assertEqual(thread.stop_description, "watchpoint 1")
process.Continue()
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
- self.assertEqual(thread.GetStopDescription(20), "step over")
+ self.assertEqual(thread.stop_description, "step over")
self.step_inst_for_watchpoint(1)
@@ -89,11 +89,11 @@ def test_step_over_write_watchpoint(self):
lldb.eStopReasonWatchpoint,
STOPPED_DUE_TO_WATCHPOINT,
)
- self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
+ self.assertEqual(thread.stop_description, "watchpoint 1")
process.Continue()
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
- self.assertEqual(thread.GetStopDescription(20), "step over")
+ self.assertEqual(thread.stop_description, "step over")
self.step_inst_for_watchpoint(1)
@@ -106,7 +106,7 @@ def step_inst_for_watchpoint(self, wp_id):
if stop_reason == lldb.eStopReasonWatchpoint:
self.assertFalse(watchpoint_hit, "Watchpoint already hit.")
expected_stop_desc = "watchpoint %d" % wp_id
- actual_stop_desc = self.thread().GetStopDescription(20)
+ actual_stop_desc = self.thread().stop_description
self.assertEqual(
actual_stop_desc, expected_stop_desc, "Watchpoint ID didn't match."
)
diff --git a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
index ff834b508d9ad..a0251d42436a9 100644
--- a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
+++ b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
@@ -35,7 +35,7 @@ def test_watchpoint_count(self):
self.assertStopReason(
stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x1 not hit"
)
- stop_reason_descr = thread.GetStopDescription(256)
+ stop_reason_descr = thread.stop_description
self.assertEqual(stop_reason_descr, "watchpoint 1")
process.Continue()
@@ -43,5 +43,5 @@ def test_watchpoint_count(self):
self.assertStopReason(
stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x2 not hit"
)
- stop_reason_descr = thread.GetStopDescription(256)
+ stop_reason_descr = thread.stop_description
self.assertEqual(stop_reason_descr, "watchpoint 2")
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 12b464d3397eb..67c5d7d55846d 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -594,7 +594,7 @@ def cont(self):
process = self.connect(target)
self.assertEqual(process.threads[0].GetStopReason(), lldb.eStopReasonSignal)
- self.assertEqual(process.threads[0].GetStopDescription(100), "signal SIGBUS")
+ self.assertEqual(process.threads[0].stop_description, "signal SIGBUS")
def test_signal_lldb_old(self):
class MyResponder(MockGDBServerResponder):
@@ -620,7 +620,7 @@ def cont(self):
process = self.connect(target)
self.assertEqual(process.threads[0].GetStopReason(), lldb.eStopReasonSignal)
- self.assertEqual(process.threads[0].GetStopDescription(100), "signal SIGUSR1")
+ self.assertEqual(process.threads[0].stop_description, "signal SIGUSR1")
def test_signal_lldb(self):
class MyResponder(MockGDBServerResponder):
@@ -643,7 +643,7 @@ def cont(self):
process = self.connect(target)
self.assertEqual(process.threads[0].GetStopReason(), lldb.eStopReasonSignal)
- self.assertEqual(process.threads[0].GetStopDescription(100), "signal SIGUSR1")
+ self.assertEqual(process.threads[0].stop_description, "signal SIGUSR1")
def do_siginfo_test(self, platform, target_yaml, raw_data, expected):
class MyResponder(MockGDBServerResponder):
diff --git a/lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py b/lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
index 0d06a9da6535c..dc555dd286365 100644
--- a/lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
+++ b/lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
@@ -123,5 +123,5 @@ def run_python_os_step_missing_thread(self, do_prune):
os_thread = self.get_os_thread()
self.assertTrue(os_thread.IsValid(), "The OS thread is back after continue")
self.assertIn(
- "step out", os_thread.GetStopDescription(100), "Completed step out plan"
+ "step out", os_thread.stop_description, "Completed step out plan"
)
diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
index 8776d72ecbc02..4b7d24ef58e7e 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -117,7 +117,7 @@ def test_thread_info_in_minidump(self):
self.assertEqual(self.process.GetNumThreads(), 1)
thread = self.process.GetThreadAtIndex(0)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertIn("SIGSEGV", stop_description)
@skipIfLLVMTargetMissing("X86")
@@ -153,7 +153,7 @@ def test_snapshot_minidump_dump_requested(self):
self.assertEqual(self.process.GetNumThreads(), 1)
thread = self.process.GetThreadAtIndex(0)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertEqual(stop_description, "")
def test_snapshot_minidump_null_exn_code(self):
@@ -164,7 +164,7 @@ def test_snapshot_minidump_null_exn_code(self):
self.assertEqual(self.process.GetNumThreads(), 1)
thread = self.process.GetThreadAtIndex(0)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertEqual(stop_description, "")
def check_register_unsigned(self, set, name, expected):
@@ -198,7 +198,7 @@ def test_arm64_registers(self):
self.assertEqual(self.process.GetNumThreads(), 1)
thread = self.process.GetThreadAtIndex(0)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertEqual(stop_description, "")
registers = thread.GetFrameAtIndex(0).GetRegisters()
# Verify the GPR registers are all correct
@@ -261,7 +261,7 @@ def verify_arm_registers(self, apple=False):
self.assertEqual(self.process.GetNumThreads(), 1)
thread = self.process.GetThreadAtIndex(0)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertEqual(stop_description, "")
registers = thread.GetFrameAtIndex(0).GetRegisters()
# Verify the GPR registers are all correct
@@ -522,7 +522,7 @@ def test_multiple_exceptions_or_signals(self):
for i in range(2):
thread = self.process.GetThreadAtIndex(i)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertIn("SIGSEGV", stop_description)
def test_breakpoint_on_minidump(self):
@@ -539,7 +539,7 @@ def test_breakpoint_on_minidump(self):
process = target.LoadCore(core)
self.assertTrue(process, VALID_PROCESS)
thread = process.GetThreadAtIndex(0)
- stop_reason = thread.GetStopDescription(256)
+ stop_reason = thread.stop_description
self.assertIn("breakpoint 1.1", stop_reason)
finally:
if os.path.isfile(core):
diff --git a/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py b/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
index 8fe5d2a1d8562..362b21905597f 100644
--- a/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
+++ b/lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
@@ -32,7 +32,7 @@ def test_thread_info_in_mini_dump(self):
self.assertEqual(self.process.GetNumThreads(), 1)
thread = self.process.GetThreadAtIndex(0)
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonException)
- stop_description = thread.GetStopDescription(256)
+ stop_description = thread.stop_description
self.assertIn("0xc0000005", stop_description)
def test_modules_in_mini_dump(self):
diff --git a/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py b/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
index 736bb69397f9b..baf451109c712 100644
--- a/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ b/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -206,7 +206,7 @@ def get_stop_reason(self) -> Dict[str, Any]:
stop_reason["type"] = lldb.eStopReasonException
stop_reason["data"][
"desc"
- ] = self.corefile_thread.GetStopDescription(100)
+ ] = self.corefile_thread.stop_description
elif self.scripted_process.arch == "x86_64":
stop_reason["type"] = lldb.eStopReasonSignal
stop_reason["data"]["signal"] = signal.SIGTRAP
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 52763694541ec..343236a9e4e3c 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -41,7 +41,7 @@ def step_out_with_scripted_plan(self, name):
frame = thread.GetFrameAtIndex(0)
self.assertEqual("main", frame.GetFunctionName())
- stop_desc = thread.GetStopDescription(1000)
+ stop_desc = thread.stop_description
self.assertIn("Stepping out from", stop_desc, "Got right description")
def run_until_branch_instruction(self):
@@ -153,7 +153,7 @@ def do_test_checking_variable(self, use_cli):
self.assertTrue(foo_val.GetValueDidChange(), "Foo changed")
# And we should have a reasonable stop description:
- desc = thread.GetStopDescription(1000)
+ desc = thread.stop_description
self.assertIn("Stepped until foo changed", desc, "Got right stop description")
def test_stop_others_from_command(self):
diff --git a/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py b/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
index 435e18084a79b..aa2d1d9feadc0 100644
--- a/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
+++ b/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
@@ -49,7 +49,7 @@ def tsan_tests(self):
stop_description = (
self.dbg.GetSelectedTarget()
.process.GetSelectedThread()
- .GetStopDescription(100)
+ .stop_description
)
self.assertTrue(
diff --git a/lldb/test/API/macosx/abort_with_payload/TestAbortWithPayload.py b/lldb/test/API/macosx/abort_with_payload/TestAbortWithPayload.py
index c10d95882f652..a850908482da4 100644
--- a/lldb/test/API/macosx/abort_with_payload/TestAbortWithPayload.py
+++ b/lldb/test/API/macosx/abort_with_payload/TestAbortWithPayload.py
@@ -61,7 +61,7 @@ def abort_with_test(self, with_payload):
self.assertEqual(thread, sel_thread, "Selected the original thread")
# Make sure the stop reason is right:
self.assertEqual(
- thread.GetStopDescription(100),
+ thread.stop_description,
"abort with payload or reason",
"Description was right",
)
diff --git a/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py b/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
index ada74a11ffd7f..e452bb564ea40 100644
--- a/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
+++ b/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
@@ -44,7 +44,7 @@ def test(self):
self.runCmd("fr v")
self.assertEqual(
- thread.GetStopDescription(256), "ESR_EC_DABORT_EL0 (fault address: 0x0)"
+ thread.stop_description, "ESR_EC_DABORT_EL0 (fault address: 0x0)"
)
if self.TraceOn():
diff --git a/lldb/test/API/riscv/break-undecoded/TestBreakpointIllegal.py b/lldb/test/API/riscv/break-undecoded/TestBreakpointIllegal.py
index 41e8901bf84ab..5b00298827a67 100644
--- a/lldb/test/API/riscv/break-undecoded/TestBreakpointIllegal.py
+++ b/lldb/test/API/riscv/break-undecoded/TestBreakpointIllegal.py
@@ -17,7 +17,7 @@ def test_4(self):
)
self.runCmd("thread step-inst")
# we need to step more, as some compilers do not set appropriate debug info.
- while cur_thread.GetStopDescription(256) == "instruction step into":
+ while cur_thread.stop_description == "instruction step into":
self.runCmd("thread step-inst")
# The stop reason of the thread should be illegal opcode.
self.expect(
@@ -34,7 +34,7 @@ def test_2(self):
)
self.runCmd("thread step-inst")
# we need to step more, as some compilers do not set appropriate debug info.
- while cur_thread.GetStopDescription(256) == "instruction step into":
+ while cur_thread.stop_description == "instruction step into":
self.runCmd("thread step-inst")
# The stop reason of the thread should be illegal opcode.
self.expect(
|
|
✅ With the latest revision this PR passed the Python code formatter. |
jimingham
approved these changes
Jul 31, 2025
Collaborator
jimingham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
stop_descriptionas a Python convenience property toSBThread.