diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/API/SBQueue.cpp | 2 | ||||
-rw-r--r-- | lldb/source/API/SBThread.cpp | 37 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp | 41 |
4 files changed, 76 insertions, 20 deletions
diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp index 31867b0dedf..b19ed72543c 100644 --- a/lldb/source/API/SBQueue.cpp +++ b/lldb/source/API/SBQueue.cpp @@ -15,6 +15,8 @@ #include "lldb/API/SBProcess.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBQueueItem.h" + #include "lldb/Core/Log.h" #include "lldb/Target/Process.h" #include "lldb/Target/Queue.h" diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 7c1bbfe9c92..97bd6f4fed7 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -23,6 +23,7 @@ #include "lldb/Target/SystemRuntime.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Queue.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Target/StopInfo.h" @@ -88,6 +89,42 @@ SBThread::~SBThread() { } +lldb::SBQueue +SBThread::GetQueue () const +{ + SBQueue sb_queue; + QueueSP queue_sp; + Mutex::Locker api_locker; + ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (exe_ctx.HasThreadScope()) + { + Process::StopLocker stop_locker; + if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) + { + queue_sp = exe_ctx.GetThreadPtr()->GetQueue(); + if (queue_sp) + { + sb_queue.SetQueue (queue_sp); + } + } + else + { + if (log) + log->Printf ("SBThread(%p)::GetQueueKind() => error: process is running", + static_cast<void*>(exe_ctx.GetThreadPtr())); + } + } + + if (log) + log->Printf ("SBThread(%p)::GetQueueKind () => SBQueue(%p)", + static_cast<void*>(exe_ctx.GetThreadPtr()), static_cast<void*>(queue_sp.get())); + + return sb_queue; +} + + bool SBThread::IsValid() const { diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 395f8c6e056..79893cf6612 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -107,6 +107,22 @@ ThreadGDBRemote::GetQueueID () return LLDB_INVALID_QUEUE_ID; } +QueueSP +ThreadGDBRemote::GetQueue () +{ + queue_id_t queue_id = GetQueueID(); + QueueSP queue; + if (queue_id != LLDB_INVALID_QUEUE_ID) + { + ProcessSP process_sp (GetProcess()); + if (process_sp) + { + queue = process_sp->GetQueueList().FindQueueByID (queue_id); + } + } + return queue; +} + addr_t ThreadGDBRemote::GetQueueLibdispatchQueueAddress () { diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index b4495fde00c..7ff14fc5e09 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -524,26 +524,7 @@ SystemRuntimeMacOSX::GetExtendedBacktraceTypes () void SystemRuntimeMacOSX::PopulateQueueList (lldb_private::QueueList &queue_list) { - if (!BacktraceRecordingHeadersInitialized()) - { - // We don't have libBacktraceRecording -- build the list of queues by looking at - // all extant threads, and the queues that they currently belong to. - - for (ThreadSP thread_sp : m_process->Threads()) - { - if (thread_sp->GetQueueID() != LLDB_INVALID_QUEUE_ID) - { - if (queue_list.FindQueueByID (thread_sp->GetQueueID()).get() == NULL) - { - QueueSP queue_sp (new Queue(m_process->shared_from_this(), thread_sp->GetQueueID(), thread_sp->GetQueueName())); - queue_sp->SetKind (GetQueueKind (thread_sp->GetQueueLibdispatchQueueAddress())); - queue_sp->SetLibdispatchQueueAddress (thread_sp->GetQueueLibdispatchQueueAddress()); - queue_list.AddQueue (queue_sp); - } - } - } - } - else + if (BacktraceRecordingHeadersInitialized()) { AppleGetQueuesHandler::GetQueuesReturnInfo queue_info_pointer; ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread()); @@ -566,6 +547,26 @@ SystemRuntimeMacOSX::PopulateQueueList (lldb_private::QueueList &queue_list) } } } + + // We either didn't have libBacktraceRecording (and need to create the queues list based on threads) + // or we did get the queues list from libBacktraceRecording but some special queues may not be + // included in its information. This is needed because libBacktraceRecording + // will only list queues with pending or running items by default - but the magic com.apple.main-thread + // queue on thread 1 is always around. + + for (ThreadSP thread_sp : m_process->Threads()) + { + if (thread_sp->GetQueueID() != LLDB_INVALID_QUEUE_ID) + { + if (queue_list.FindQueueByID (thread_sp->GetQueueID()).get() == NULL) + { + QueueSP queue_sp (new Queue(m_process->shared_from_this(), thread_sp->GetQueueID(), thread_sp->GetQueueName())); + queue_sp->SetKind (GetQueueKind (thread_sp->GetQueueLibdispatchQueueAddress())); + queue_sp->SetLibdispatchQueueAddress (thread_sp->GetQueueLibdispatchQueueAddress()); + queue_list.AddQueue (queue_sp); + } + } + } } // Returns either an array of introspection_dispatch_item_info_ref's for the pending items on |