[Lldb-commits] [lldb] [lldb][testing] Check all stop reasons in get_threads_stopped_at_breakpoint_id (PR #108281)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 11 12:48:59 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/108281.diff


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbutil.py (+10-3) 


``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 629565b38ca1e6..660a3c085a908a 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -773,9 +773,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

``````````

</details>


https://github.com/llvm/llvm-project/pull/108281


More information about the lldb-commits mailing list