From f415791bda664c481dd125fd5d2c6c6087338249 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 15 Oct 2015 04:20:42 +0000 Subject: [PATCH] In r240466, when Greg added the jThreadsInfo packet, he accidentally disabled the use of the jThreadGetExtendedInfo packet which is used to retrieve additional information about a thread, such as the QoS setting for that thread on darwin systems. Re-enable the use of the jThreadGetExtendedInfo packet, and add some quick tests to the TestQueues mac test case which will verify that we can retrieve the QoS names for these test threads. llvm-svn: 250364 --- .../GDBRemoteCommunicationClient.cpp | 1 - lldb/test/macosx/queues/TestQueues.py | 46 ++++++++++++++++++- lldb/test/macosx/queues/main.c | 35 ++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index cad49efcaf58..42eb0a1d2ac4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -619,7 +619,6 @@ GDBRemoteCommunicationClient::GetThreadsInfo() if (m_supports_jThreadsInfo) { StringExtractorGDBRemote response; - m_supports_jThreadExtendedInfo = eLazyBoolNo; if (SendPacketAndWaitForResponse("jThreadsInfo", response, false) == PacketResult::Success) { if (response.IsUnsupportedResponse()) diff --git a/lldb/test/macosx/queues/TestQueues.py b/lldb/test/macosx/queues/TestQueues.py index 4028bc96ef90..b15c38aa0963 100644 --- a/lldb/test/macosx/queues/TestQueues.py +++ b/lldb/test/macosx/queues/TestQueues.py @@ -108,6 +108,51 @@ class TestQueues(TestBase): self.check_queues_threads_match_queue (queue_performer_2) self.check_queues_threads_match_queue (queue_performer_3) + + + # 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. + + user_initiated_thread = lldb.SBThread() + user_interactive_thread = lldb.SBThread() + utility_thread = lldb.SBThread() + unspecified_thread = lldb.SBThread() + background_thread = lldb.SBThread() + for th in process.threads: + if th.GetName() == "user initiated QoS": + user_initiated_thread = th + if th.GetName() == "user interactive QoS": + user_interactive_thread = th + if th.GetName() == "utility QoS": + utility_thread = th + if th.GetName() == "unspecified QoS": + unspecified_thread = th + if th.GetName() == "background QoS": + background_thread = th + + self.assertTrue(user_initiated_thread.IsValid(), "Found user initiated QoS thread") + self.assertTrue(user_interactive_thread.IsValid(), "Found user interactive QoS thread") + self.assertTrue(utility_thread.IsValid(), "Found utility QoS thread") + self.assertTrue(unspecified_thread.IsValid(), "Found unspecified QoS thread") + self.assertTrue(background_thread.IsValid(), "Found background QoS thread") + + stream = lldb.SBStream() + self.assertTrue(user_initiated_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for user initiated QoS thread") + self.assertTrue(stream.GetData() == "User Initiated", "user initiated QoS thread name is valid") + stream.Clear() + self.assertTrue(user_interactive_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for user interactive QoS thread") + self.assertTrue(stream.GetData() == "User Interactive", "user interactive QoS thread name is valid") + stream.Clear() + self.assertTrue(utility_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for utility QoS thread") + self.assertTrue(stream.GetData() == "Utility", "utility QoS thread name is valid") + stream.Clear() + self.assertTrue(unspecified_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for unspecified QoS thread") + self.assertTrue(stream.GetData() == "User Initiated", "unspecified QoS thread name is valid") + stream.Clear() + self.assertTrue(background_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for background QoS thread") + self.assertTrue(stream.GetData() == "Background", "background QoS thread name is valid") + def queues_with_libBacktraceRecording(self): """Test queues inspection SB APIs with libBacktraceRecording present.""" exe = os.path.join(os.getcwd(), "a.out") @@ -193,7 +238,6 @@ class TestQueues(TestBase): self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).GetAddress().GetSymbol().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") - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/macosx/queues/main.c b/lldb/test/macosx/queues/main.c index 369f0257aa9e..fa6a3e570ae3 100644 --- a/lldb/test/macosx/queues/main.c +++ b/lldb/test/macosx/queues/main.c @@ -91,6 +91,41 @@ int main () dispatch_async_f (work_submittor_3, (void*) &work_performer_3, submit_work_3); + + // Spin up threads with each of the different libdispatch QoS values. + + dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ + pthread_setname_np ("user initiated QoS"); + while (1) + sleep (10); + }); + dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{ + pthread_setname_np ("user interactive QoS"); + while (1) + sleep (10); + }); + dispatch_async (dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{ + pthread_setname_np ("default QoS"); + while (1) + sleep (10); + }); + dispatch_async (dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{ + pthread_setname_np ("utility QoS"); + while (1) + sleep (10); + }); + dispatch_async (dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + pthread_setname_np ("background QoS"); + while (1) + sleep (10); + }); + dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{ + pthread_setname_np ("unspecified QoS"); + while (1) + sleep (10); + }); + + sleep (1); stopper ();