Skip to content

Commit 8c4923e

Browse files
[lldb][testing] Check all stop reasons in get_threads_stopped_at_breakpoint_id (llvm#108281)
If multiple breakpoints are hit at the same time, multiple stop reasons are reported, one per breakpoint. Currently, `get_threads_stopped_at_breakpoint_id` only checks the first such reason. (cherry picked from commit 7e74472)
1 parent c16f367 commit 8c4923e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lldb/packages/Python/lldbsuite/test/lldbutil.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,16 @@ def get_threads_stopped_at_breakpoint_id(process, bpid):
784784
return threads
785785

786786
for thread in stopped_threads:
787-
# Make sure we've hit our breakpoint...
788-
break_id = thread.GetStopReasonDataAtIndex(0)
789-
if break_id == bpid:
787+
# Make sure we've hit our breakpoint.
788+
# From the docs of GetStopReasonDataAtIndex: "Breakpoint stop reasons
789+
# will have data that consists of pairs of breakpoint IDs followed by
790+
# the breakpoint location IDs".
791+
# Iterate over all such pairs looking for `bpid`.
792+
break_ids = [
793+
thread.GetStopReasonDataAtIndex(idx)
794+
for idx in range(0, thread.GetStopReasonDataCount(), 2)
795+
]
796+
if bpid in break_ids:
790797
threads.append(thread)
791798

792799
return threads

0 commit comments

Comments
 (0)