[Lldb-commits] [PATCH] D79563: [lldb/test] Make "inline" tests handle multiple statements at the same location

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 7 04:29:16 PDT 2020


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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79563.262607.patch
Type: text/x-patch
Size: 1216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200507/cd6829ff/attachment-0001.bin>


More information about the lldb-commits mailing list