[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

Chelsea Cassanova via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 12 12:02:18 PDT 2022


cassanova updated this revision to Diff 452267.
cassanova added a comment.

Use the enum name for the stop reason when asserting that the queues hit their breakpoints instead of just the raw number.

Also, get the main thread from `run_to_name_breakpoint` instead of getting it from `get_threads_stopped_at_breakpoint`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131605/new/

https://reviews.llvm.org/D131605

Files:
  lldb/test/API/macosx/queues/TestQueues.py


Index: lldb/test/API/macosx/queues/TestQueues.py
===================================================================
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
                  t.GetQueue().GetQueueID(),
                     queue.GetQueueID()))
 
+    def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+        queue1_thread = queue1.GetThreadAtIndex(0)
+        queue2_thread = queue2.GetThreadAtIndex(0)
+
+        self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+                         "The breakpoint was set for queue %s, but the breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), queue1.GetName()))
+        self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+                        "The breakpoint for queue %s has not been hit" % (queue_breakpoint.GetQueueName()))
+        self.assertEqual(queue1_thread.GetStopReason(), lldb.eStopReasonBreakpoint,
+                         "Queue %s is not stopped at breakpoint %d" %
+                         (queue1.GetName(), queue_breakpoint.GetID()))
+        self.assertNotEqual(queue2_thread.GetStopReason(), lldb.eStopReasonBreakpoint,
+                            "Queue %s is stopped at breakpoint %d, but this breakpoint should only be hit for queue %s" %
+                            (queue2.GetName(), queue_breakpoint.GetID(), queue_breakpoint.GetQueueName()))
+
     def queues(self):
         """Test queues inspection SB APIs without libBacktraceRecording."""
         exe = self.getBuildArtifact("a.out")
@@ -183,6 +198,15 @@
         self.check_queues_threads_match_queue(queue_performer_2)
         self.check_queues_threads_match_queue(queue_performer_3)
 
+        # Run the executable until the stopper function and get the breakpoint
+        # that's created from that. Then set the queue name of the breakpoint
+        # to be the name of the main thread
+        process_info = lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+        main_thread = process_info[2]
+        queue_breakpoint = process_info[3]
+        queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+        self.check_queue_breakpoints(main_thread.GetQueue(), queue_submittor_1, queue_breakpoint)
+
         # We have threads running with all the different dispatch QoS service
         # levels - find those threads and check that we can get the correct
         # QoS name for each of them.
@@ -291,6 +315,7 @@
         if len(threads) != 1:
             self.fail("Failed to stop at breakpoint 1.")
 
+        main_thread = threads[0]
         self.inferior_process = process
 
         libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib")
@@ -358,6 +383,15 @@
         self.check_queues_threads_match_queue(queue_performer_2)
         self.check_queues_threads_match_queue(queue_performer_3)
 
+        # Run the executable until the stopper function and get the breakpoint
+        # that's created from that. Then set the queue name of the breakpoint
+        # to be the name of the main thread
+        process_info = lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+        main_thread = process_info[2]
+        queue_breakpoint = process_info[3]
+        queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+        self.check_queue_breakpoints(main_thread.GetQueue(), queue_submittor_1, queue_breakpoint)
+
         self.assertTrue(queue_performer_2.GetPendingItemAtIndex(
             0).IsValid(), "queue 2's pending item #0 is valid")
         self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131605.452267.patch
Type: text/x-patch
Size: 3710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220812/7f5d2d2e/attachment.bin>


More information about the lldb-commits mailing list