[Lldb-commits] [lldb] b9bc518 - [lldb] Use current breakpoint location in TestBreakpointLocationDot.py (NFC) (#197472)

via lldb-commits lldb-commits at lists.llvm.org
Thu May 14 12:51:32 PDT 2026


Author: Dave Lee
Date: 2026-05-14T12:51:27-07:00
New Revision: b9bc518ac5083ce0a67ce18725952245c13d814c

URL: https://github.com/llvm/llvm-project/commit/b9bc518ac5083ce0a67ce18725952245c13d814c
DIFF: https://github.com/llvm/llvm-project/commit/b9bc518ac5083ce0a67ce18725952245c13d814c.diff

LOG: [lldb] Use current breakpoint location in TestBreakpointLocationDot.py (NFC) (#197472)

Replaces `FindLocationByID(1)` with `FindLocationByID(loc_id)`. Instead
of hard-coding an ID of 1, the location ID is determined from
`GetStopReasonDataAtIndex`.

Some of these asserts were failing on a windows CI, because the
breakpoint was resolved to **two** locations.

Added: 
    

Modified: 
    lldb/test/API/commands/breakpoint/location-dot/TestBreakpointLocationDot.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/breakpoint/location-dot/TestBreakpointLocationDot.py b/lldb/test/API/commands/breakpoint/location-dot/TestBreakpointLocationDot.py
index d2f0226699c6d..f1714753168f4 100644
--- a/lldb/test/API/commands/breakpoint/location-dot/TestBreakpointLocationDot.py
+++ b/lldb/test/API/commands/breakpoint/location-dot/TestBreakpointLocationDot.py
@@ -6,27 +6,29 @@
 class TestCase(TestBase):
     def test_disable_enable(self):
         self.build()
-        _, _, _, bp = lldbutil.run_to_source_breakpoint(
+        _, _, thread, bp = lldbutil.run_to_source_breakpoint(
             self, "break here", lldb.SBFileSpec("main.c")
         )
 
-        self.assertTrue(bp.FindLocationByID(1).IsEnabled())
+        loc = self._stop_location(thread, bp)
+        self.assertTrue(loc.IsEnabled())
         self.expect("breakpoint disable .", startstr="1 breakpoints disabled.")
-        self.assertFalse(bp.FindLocationByID(1).IsEnabled())
+        self.assertFalse(loc.IsEnabled())
         self.expect("breakpoint enable .", startstr="1 breakpoints enabled.")
-        self.assertTrue(bp.FindLocationByID(1).IsEnabled())
+        self.assertTrue(loc.IsEnabled())
 
     def test_delete(self):
         self.build()
-        _, _, _, bp = lldbutil.run_to_source_breakpoint(
+        _, _, thread, bp = lldbutil.run_to_source_breakpoint(
             self, "break here", lldb.SBFileSpec("main.c")
         )
 
+        loc = self._stop_location(thread, bp)
         self.expect(
             "breakpoint delete .",
             startstr="0 breakpoints deleted; 1 breakpoint locations disabled",
         )
-        self.assertFalse(bp.FindLocationByID(1).IsEnabled())
+        self.assertFalse(loc.IsEnabled())
 
     def test_error_not_breakpoint_stop(self):
         self.build()
@@ -34,7 +36,8 @@ def test_error_not_breakpoint_stop(self):
             self, "break here", lldb.SBFileSpec("main.c")
         )
 
-        self.assertTrue(bp.FindLocationByID(1).IsEnabled())
+        loc = self._stop_location(thread, bp)
+        self.assertTrue(loc.IsEnabled())
         thread.StepOver()
         self.assertNotEqual(thread.stop_reason, lldb.eStopReasonBreakpoint)
         self.expect(
@@ -42,10 +45,23 @@ def test_error_not_breakpoint_stop(self):
             error=True,
             startstr="error: current thread is not stopped at a breakpoint",
         )
-        self.assertTrue(bp.FindLocationByID(1).IsEnabled())
+        self.assertTrue(loc.IsEnabled())
 
     def test_error_no_process(self):
         self.build()
         target = self.createTestTarget()
         target.BreakpointCreateByLocation("main.c", 2)
         self.expect("breakpoint disable .", error=True, substrs=["no current thread"])
+
+    def _stop_location(
+        self, thread: lldb.SBThread, bp: lldb.SBBreakpoint
+    ) -> lldb.SBBreakpointLocation:
+        # At a breakpoint stop, the stop reason data has the following structure:
+        #   [bp1_id, loc1_id, bp2_id, loc2_id, ...]
+        self.assertEqual(
+            thread.GetStopReasonDataCount(),
+            2,
+            "stop should be for one breakpoint only",
+        )
+        loc_id = thread.GetStopReasonDataAtIndex(1)
+        return bp.FindLocationByID(loc_id)


        


More information about the lldb-commits mailing list