From 8c4923e40ca5cc378b1ccbc9bf1e4b93318bd064 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 12 Sep 2024 07:01:59 -0700 Subject: [PATCH] [lldb][testing] Check all stop reasons in get_threads_stopped_at_breakpoint_id (#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 7e74472801486cc702fba3e831c8fcd77c120142) --- lldb/packages/Python/lldbsuite/test/lldbutil.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py index d87421d7758f9..7bc0a00736fda 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -784,9 +784,16 @@ def get_threads_stopped_at_breakpoint_id(process, bpid): return threads for thread in stopped_threads: - # Make sure we've hit our breakpoint... - break_id = thread.GetStopReasonDataAtIndex(0) - if break_id == bpid: + # Make sure we've hit our breakpoint. + # From the docs of GetStopReasonDataAtIndex: "Breakpoint stop reasons + # will have data that consists of pairs of breakpoint IDs followed by + # the breakpoint location IDs". + # Iterate over all such pairs looking for `bpid`. + break_ids = [ + thread.GetStopReasonDataAtIndex(idx) + for idx in range(0, thread.GetStopReasonDataCount(), 2) + ] + if bpid in break_ids: threads.append(thread) return threads