Skip to content

Commit f170f5f

Browse files
authored
[lldb] Add stop_reason_data property to SBThread python extensions (llvm#117266)
Add a pythonic `stop_reason_data` property to `SBThread`. The property produces a list of ints.
1 parent a5f501e commit f170f5f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lldb/bindings/interface/SBThreadExtensions.i

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

48+
def get_stop_reason_data(self):
49+
return [
50+
self.GetStopReasonDataAtIndex(idx)
51+
for idx in range(self.GetStopReasonDataCount())
52+
]
53+
4854
id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''')
4955
idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''')
5056
return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''')
@@ -56,6 +62,7 @@ STRING_EXTENSION_OUTSIDE(SBThread)
5662
queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''')
5763
queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''')
5864
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.''')
65+
stop_reason_data = property(get_stop_reason_data, None, doc='''A read only property that returns the stop reason data as a list.''')
5966
is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''')
6067
is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''')
6168
%}

lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ def test_and_python_api(self):
9999
frame = thread.GetFrameAtIndex(0)
100100
current_line = frame.GetLineEntry().GetLine()
101101
current_file = frame.GetLineEntry().GetFileSpec()
102-
current_bp = []
103-
current_bp.append(thread.GetStopReasonDataAtIndex(0))
104-
current_bp.append(thread.GetStopReasonDataAtIndex(1))
102+
current_bp = thread.stop_reason_data
105103

106104
stop_id_before_expression = process.GetStopID()
107105
stop_id_before_including_expressions = process.GetStopID(True)
@@ -124,9 +122,9 @@ def test_and_python_api(self):
124122
lldb.eStopReasonBreakpoint,
125123
"We still say we stopped for a breakpoint.",
126124
)
127-
self.assertTrue(
128-
thread.GetStopReasonDataAtIndex(0) == current_bp[0]
129-
and thread.GetStopReasonDataAtIndex(1) == current_bp[1],
125+
self.assertEqual(
126+
thread.stop_reason_data,
127+
current_bp,
130128
"And it is the same breakpoint.",
131129
)
132130

0 commit comments

Comments
 (0)