Skip to content

Commit 68b9bb5

Browse files
authored
[lldb] Add stop_description Python property to SBThread (#151568)
Add `stop_description` as a Python convenience property to `SBThread`.
1 parent 2737d01 commit 68b9bb5

File tree

13 files changed

+31
-29
lines changed

13 files changed

+31
-29
lines changed

lldb/bindings/interface/SBThreadExtensions.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ STRING_EXTENSION_OUTSIDE(SBThread)
4545
frames.append(frame)
4646
return frames
4747

48+
def get_stop_description(self):
49+
return self.GetStopDescription(1024)
50+
4851
def get_stop_reason_data(self):
4952
return [
5053
self.GetStopReasonDataAtIndex(idx)
@@ -69,6 +72,7 @@ STRING_EXTENSION_OUTSIDE(SBThread)
6972
name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''')
7073
queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''')
7174
queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''')
75+
stop_description = property(get_stop_description, None, doc='''A read only property that returns a string describing the reason this thread stopped.''')
7276
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.''')
7377
stop_reason_data = property(get_stop_reason_data, None, doc='''A read only property that returns the stop reason data as a list.''')
7478
is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''')

lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def test_step_over_read_watchpoint(self):
5050
lldb.eStopReasonWatchpoint,
5151
STOPPED_DUE_TO_WATCHPOINT,
5252
)
53-
self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
53+
self.assertEqual(thread.stop_description, "watchpoint 1")
5454

5555
process.Continue()
5656
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
57-
self.assertEqual(thread.GetStopDescription(20), "step over")
57+
self.assertEqual(thread.stop_description, "step over")
5858

5959
self.step_inst_for_watchpoint(1)
6060

@@ -89,11 +89,11 @@ def test_step_over_write_watchpoint(self):
8989
lldb.eStopReasonWatchpoint,
9090
STOPPED_DUE_TO_WATCHPOINT,
9191
)
92-
self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
92+
self.assertEqual(thread.stop_description, "watchpoint 1")
9393

9494
process.Continue()
9595
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
96-
self.assertEqual(thread.GetStopDescription(20), "step over")
96+
self.assertEqual(thread.stop_description, "step over")
9797

9898
self.step_inst_for_watchpoint(1)
9999

@@ -106,7 +106,7 @@ def step_inst_for_watchpoint(self, wp_id):
106106
if stop_reason == lldb.eStopReasonWatchpoint:
107107
self.assertFalse(watchpoint_hit, "Watchpoint already hit.")
108108
expected_stop_desc = "watchpoint %d" % wp_id
109-
actual_stop_desc = self.thread().GetStopDescription(20)
109+
actual_stop_desc = self.thread().stop_description
110110
self.assertEqual(
111111
actual_stop_desc, expected_stop_desc, "Watchpoint ID didn't match."
112112
)

lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def test_watchpoint_count(self):
3535
self.assertStopReason(
3636
stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x1 not hit"
3737
)
38-
stop_reason_descr = thread.GetStopDescription(256)
38+
stop_reason_descr = thread.stop_description
3939
self.assertEqual(stop_reason_descr, "watchpoint 1")
4040

4141
process.Continue()
4242
stop_reason = thread.GetStopReason()
4343
self.assertStopReason(
4444
stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x2 not hit"
4545
)
46-
stop_reason_descr = thread.GetStopDescription(256)
46+
stop_reason_descr = thread.stop_description
4747
self.assertEqual(stop_reason_descr, "watchpoint 2")

lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def cont(self):
594594
process = self.connect(target)
595595

596596
self.assertEqual(process.threads[0].GetStopReason(), lldb.eStopReasonSignal)
597-
self.assertEqual(process.threads[0].GetStopDescription(100), "signal SIGBUS")
597+
self.assertEqual(process.threads[0].stop_description, "signal SIGBUS")
598598

599599
def test_signal_lldb_old(self):
600600
class MyResponder(MockGDBServerResponder):
@@ -620,7 +620,7 @@ def cont(self):
620620
process = self.connect(target)
621621

622622
self.assertEqual(process.threads[0].GetStopReason(), lldb.eStopReasonSignal)
623-
self.assertEqual(process.threads[0].GetStopDescription(100), "signal SIGUSR1")
623+
self.assertEqual(process.threads[0].stop_description, "signal SIGUSR1")
624624

625625
def test_signal_lldb(self):
626626
class MyResponder(MockGDBServerResponder):
@@ -643,7 +643,7 @@ def cont(self):
643643
process = self.connect(target)
644644

645645
self.assertEqual(process.threads[0].GetStopReason(), lldb.eStopReasonSignal)
646-
self.assertEqual(process.threads[0].GetStopDescription(100), "signal SIGUSR1")
646+
self.assertEqual(process.threads[0].stop_description, "signal SIGUSR1")
647647

648648
def do_siginfo_test(self, platform, target_yaml, raw_data, expected):
649649
class MyResponder(MockGDBServerResponder):

lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ def run_python_os_step_missing_thread(self, do_prune):
123123
os_thread = self.get_os_thread()
124124
self.assertTrue(os_thread.IsValid(), "The OS thread is back after continue")
125125
self.assertIn(
126-
"step out", os_thread.GetStopDescription(100), "Completed step out plan"
126+
"step out", os_thread.stop_description, "Completed step out plan"
127127
)

lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_thread_info_in_minidump(self):
117117
self.assertEqual(self.process.GetNumThreads(), 1)
118118
thread = self.process.GetThreadAtIndex(0)
119119
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal)
120-
stop_description = thread.GetStopDescription(256)
120+
stop_description = thread.stop_description
121121
self.assertIn("SIGSEGV", stop_description)
122122

123123
@skipIfLLVMTargetMissing("X86")
@@ -153,7 +153,7 @@ def test_snapshot_minidump_dump_requested(self):
153153
self.assertEqual(self.process.GetNumThreads(), 1)
154154
thread = self.process.GetThreadAtIndex(0)
155155
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
156-
stop_description = thread.GetStopDescription(256)
156+
stop_description = thread.stop_description
157157
self.assertEqual(stop_description, "")
158158

159159
def test_snapshot_minidump_null_exn_code(self):
@@ -164,7 +164,7 @@ def test_snapshot_minidump_null_exn_code(self):
164164
self.assertEqual(self.process.GetNumThreads(), 1)
165165
thread = self.process.GetThreadAtIndex(0)
166166
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
167-
stop_description = thread.GetStopDescription(256)
167+
stop_description = thread.stop_description
168168
self.assertEqual(stop_description, "")
169169

170170
def check_register_unsigned(self, set, name, expected):
@@ -198,7 +198,7 @@ def test_arm64_registers(self):
198198
self.assertEqual(self.process.GetNumThreads(), 1)
199199
thread = self.process.GetThreadAtIndex(0)
200200
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
201-
stop_description = thread.GetStopDescription(256)
201+
stop_description = thread.stop_description
202202
self.assertEqual(stop_description, "")
203203
registers = thread.GetFrameAtIndex(0).GetRegisters()
204204
# Verify the GPR registers are all correct
@@ -261,7 +261,7 @@ def verify_arm_registers(self, apple=False):
261261
self.assertEqual(self.process.GetNumThreads(), 1)
262262
thread = self.process.GetThreadAtIndex(0)
263263
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)
264-
stop_description = thread.GetStopDescription(256)
264+
stop_description = thread.stop_description
265265
self.assertEqual(stop_description, "")
266266
registers = thread.GetFrameAtIndex(0).GetRegisters()
267267
# Verify the GPR registers are all correct
@@ -522,7 +522,7 @@ def test_multiple_exceptions_or_signals(self):
522522
for i in range(2):
523523
thread = self.process.GetThreadAtIndex(i)
524524
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal)
525-
stop_description = thread.GetStopDescription(256)
525+
stop_description = thread.stop_description
526526
self.assertIn("SIGSEGV", stop_description)
527527

528528
def test_breakpoint_on_minidump(self):
@@ -539,7 +539,7 @@ def test_breakpoint_on_minidump(self):
539539
process = target.LoadCore(core)
540540
self.assertTrue(process, VALID_PROCESS)
541541
thread = process.GetThreadAtIndex(0)
542-
stop_reason = thread.GetStopDescription(256)
542+
stop_reason = thread.stop_description
543543
self.assertIn("breakpoint 1.1", stop_reason)
544544
finally:
545545
if os.path.isfile(core):

lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_thread_info_in_mini_dump(self):
3232
self.assertEqual(self.process.GetNumThreads(), 1)
3333
thread = self.process.GetThreadAtIndex(0)
3434
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonException)
35-
stop_description = thread.GetStopDescription(256)
35+
stop_description = thread.stop_description
3636
self.assertIn("0xc0000005", stop_description)
3737

3838
def test_modules_in_mini_dump(self):

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ def get_stop_reason(self) -> Dict[str, Any]:
204204
if self.is_stopped:
205205
if "arm64" in self.scripted_process.arch:
206206
stop_reason["type"] = lldb.eStopReasonException
207-
stop_reason["data"][
208-
"desc"
209-
] = self.corefile_thread.GetStopDescription(100)
207+
stop_reason["data"]["desc"] = self.corefile_thread.stop_description
210208
elif self.scripted_process.arch == "x86_64":
211209
stop_reason["type"] = lldb.eStopReasonSignal
212210
stop_reason["data"]["signal"] = signal.SIGTRAP

lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def step_out_with_scripted_plan(self, name):
4141

4242
frame = thread.GetFrameAtIndex(0)
4343
self.assertEqual("main", frame.GetFunctionName())
44-
stop_desc = thread.GetStopDescription(1000)
44+
stop_desc = thread.stop_description
4545
self.assertIn("Stepping out from", stop_desc, "Got right description")
4646

4747
def run_until_branch_instruction(self):
@@ -153,7 +153,7 @@ def do_test_checking_variable(self, use_cli):
153153
self.assertTrue(foo_val.GetValueDidChange(), "Foo changed")
154154

155155
# And we should have a reasonable stop description:
156-
desc = thread.GetStopDescription(1000)
156+
desc = thread.stop_description
157157
self.assertIn("Stepped until foo changed", desc, "Got right stop description")
158158

159159
def test_stop_others_from_command(self):

lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def tsan_tests(self):
4949
stop_description = (
5050
self.dbg.GetSelectedTarget()
5151
.process.GetSelectedThread()
52-
.GetStopDescription(100)
52+
.stop_description
5353
)
5454

5555
self.assertTrue(

0 commit comments

Comments
 (0)