labath created this revision.
labath added reviewers: vsk, JDevlieghere.
Herald added a project: LLDB.

The test machinery translates each continuous block of "//%" comments
into a single breakpoint. If there's no code between the blocks the
breakpoints will end up at the same location in the program. When the
process stops at a breakpoint lldb correctly reports all breakpoint IDs,
but the test machinery only looks at the first one. This results in a
very dangerous situation as it means some checks can be silently
stopped.

This patch fixes that by making the test machinery iterate through all
breakpoints at a given location and execute all commands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79563

Files:
  lldb/packages/Python/lldbsuite/test/lldbinline.py


Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -126,6 +126,13 @@
     def execute_user_command(self, __command):
         exec(__command, globals(), locals())
 
+    def _get_breakpoint_ids(self, thread):
+        ids = set()
+        for i in range(0, thread.GetStopReasonDataCount(), 2):
+            ids.add(thread.GetStopReasonDataAtIndex(i))
+        self.assertGreater(len(ids), 0)
+        return sorted(ids)
+
     def do_test(self):
         exe = self.getBuildArtifact("a.out")
         source_files = [f for f in os.listdir(self.getSourceDir())
@@ -145,8 +152,8 @@
             hit_breakpoints += 1
             thread = lldbutil.get_stopped_thread(
                 process, lldb.eStopReasonBreakpoint)
-            breakpoint_id = thread.GetStopReasonDataAtIndex(0)
-            parser.handle_breakpoint(self, breakpoint_id)
+            for id in self._get_breakpoint_ids(thread):
+                parser.handle_breakpoint(self, id)
             process.Continue()
 
         self.assertTrue(hit_breakpoints > 0,


Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -126,6 +126,13 @@
     def execute_user_command(self, __command):
         exec(__command, globals(), locals())
 
+    def _get_breakpoint_ids(self, thread):
+        ids = set()
+        for i in range(0, thread.GetStopReasonDataCount(), 2):
+            ids.add(thread.GetStopReasonDataAtIndex(i))
+        self.assertGreater(len(ids), 0)
+        return sorted(ids)
+
     def do_test(self):
         exe = self.getBuildArtifact("a.out")
         source_files = [f for f in os.listdir(self.getSourceDir())
@@ -145,8 +152,8 @@
             hit_breakpoints += 1
             thread = lldbutil.get_stopped_thread(
                 process, lldb.eStopReasonBreakpoint)
-            breakpoint_id = thread.GetStopReasonDataAtIndex(0)
-            parser.handle_breakpoint(self, breakpoint_id)
+            for id in self._get_breakpoint_ids(thread):
+                parser.handle_breakpoint(self, id)
             process.Continue()
 
         self.assertTrue(hit_breakpoints > 0,
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to