Skip to content

[lldb] Add stop_reason_data property to SBThread python extensions #117266

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lldb/bindings/interface/SBThreadExtensions.i
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ STRING_EXTENSION_OUTSIDE(SBThread)
frames.append(frame)
return frames

def get_stop_reason_data(self):
return [
self.GetStopReasonDataAtIndex(idx)
for idx in range(self.GetStopReasonDataCount())
]

id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''')
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.''')
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.''')
Expand All @@ -56,6 +62,7 @@ STRING_EXTENSION_OUTSIDE(SBThread)
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_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.''')
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.''')
%}
Expand Down
10 changes: 4 additions & 6 deletions lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ def test_and_python_api(self):
frame = thread.GetFrameAtIndex(0)
current_line = frame.GetLineEntry().GetLine()
current_file = frame.GetLineEntry().GetFileSpec()
current_bp = []
current_bp.append(thread.GetStopReasonDataAtIndex(0))
current_bp.append(thread.GetStopReasonDataAtIndex(1))
current_bp = thread.stop_reason_data

stop_id_before_expression = process.GetStopID()
stop_id_before_including_expressions = process.GetStopID(True)
Expand All @@ -124,9 +122,9 @@ def test_and_python_api(self):
lldb.eStopReasonBreakpoint,
"We still say we stopped for a breakpoint.",
)
self.assertTrue(
thread.GetStopReasonDataAtIndex(0) == current_bp[0]
and thread.GetStopReasonDataAtIndex(1) == current_bp[1],
self.assertEqual(
thread.stop_reason_data,
current_bp,
"And it is the same breakpoint.",
)

Expand Down
Loading