[Lldb-commits] [lldb] 9525015 - [lldb][tests] Test queue-specific breakpoints
Chelsea Cassanova via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 17 09:46:16 PDT 2022
Author: Chelsea Cassanova
Date: 2022-08-17T12:46:04-04:00
New Revision: 9525015c1bed5563813a440c5e5c871bd3c7eb24
URL: https://github.com/llvm/llvm-project/commit/9525015c1bed5563813a440c5e5c871bd3c7eb24
DIFF: https://github.com/llvm/llvm-project/commit/9525015c1bed5563813a440c5e5c871bd3c7eb24.diff
LOG: [lldb][tests] Test queue-specific breakpoints
This commit adds tests to ensure that queue-specific breakpoints
work as expected, as this feature wasn't being tested before.
Differential Revision: https://reviews.llvm.org/D131605
Added:
Modified:
lldb/test/API/macosx/queues/TestQueues.py
Removed:
################################################################################
diff --git a/lldb/test/API/macosx/queues/TestQueues.py b/lldb/test/API/macosx/queues/TestQueues.py
index 7bd5787413ab3..f906f5b314279 100644
--- a/lldb/test/API/macosx/queues/TestQueues.py
+++ b/lldb/test/API/macosx/queues/TestQueues.py
@@ -16,6 +16,12 @@ def test_with_python_api_queues(self):
self.build()
self.queues()
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_queue_specific_breakpoints(self):
+ self.build()
+ self.queue_specific_breakpoints()
+
@skipUnlessDarwin
@add_test_categories(['pyapi'])
def test_with_python_api_queues_with_backtrace(self):
@@ -118,6 +124,21 @@ def check_queues_threads_match_queue(self, queue):
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.assertEqual(queue_breakpoint.GetHitCount(), 1,
+ "The breakpoint for queue %s has not been hit" % (queue_breakpoint.GetQueueName()))
+ self.assertStopReason(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")
@@ -367,3 +388,21 @@ def queues_with_libBacktraceRecording(self):
).GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2")
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(
9999).IsValid() == False, "queue 2's pending item #9999 is invalid")
+
+ def queue_specific_breakpoints(self):
+ # 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
+ target, process, main_thread, queue_breakpoint = lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+ queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+
+ # Create a submittor queue
+ queue_submittor_1 = lldb.SBQueue()
+ for idx in range(0, process.GetNumQueues()):
+ q = process.GetQueueAtIndex(idx)
+ if q.GetName() == "com.apple.work_submittor_1":
+ queue_submittor_1 = q
+
+ self.assertTrue(queue_submittor_1.IsValid(), "Unable to get expected queue com.apple.work_submittor_1, instead got queue %s" % (queue_submittor_1.GetName()))
+
+ self.check_queue_breakpoints(main_thread.GetQueue(), queue_submittor_1, queue_breakpoint)
More information about the lldb-commits
mailing list