diff options
author | Jason Molenda <jmolenda@apple.com> | 2014-03-13 02:54:54 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2014-03-13 02:54:54 +0000 |
commit | aac16e0f809a7e7a78dc5d0bb63a0e0a294761e6 (patch) | |
tree | e263c74cc27dbcb6591115ba3f9cd55ecbe33e92 /lldb | |
parent | 4b4b2478fc4a08d035a7653ae7acaa1853553b34 (diff) | |
download | bcm5719-llvm-aac16e0f809a7e7a78dc5d0bb63a0e0a294761e6.tar.gz bcm5719-llvm-aac16e0f809a7e7a78dc5d0bb63a0e0a294761e6.zip |
Add a SBQueue::GetKind() method to retrieve the type of libdispatch queue (serial or concurrent).
<rdar://problem/7964505>
llvm-svn: 203748
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/API/SBQueue.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Queue.h | 13 | ||||
-rw-r--r-- | lldb/include/lldb/Target/SystemRuntime.h | 24 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Thread.h | 47 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-enumerations.h | 12 | ||||
-rw-r--r-- | lldb/scripts/Python/interface/SBQueue.i | 18 | ||||
-rw-r--r-- | lldb/source/API/SBQueue.cpp | 17 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp | 19 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h | 3 | ||||
-rw-r--r-- | lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp | 43 | ||||
-rw-r--r-- | lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h | 6 | ||||
-rw-r--r-- | lldb/source/Target/Queue.cpp | 15 |
12 files changed, 217 insertions, 3 deletions
diff --git a/lldb/include/lldb/API/SBQueue.h b/lldb/include/lldb/API/SBQueue.h index 619454eff29..cd418c037b4 100644 --- a/lldb/include/lldb/API/SBQueue.h +++ b/lldb/include/lldb/API/SBQueue.h @@ -65,6 +65,9 @@ public: uint32_t GetNumRunningItems (); + lldb::QueueKind + GetKind (); + protected: friend class SBProcess; diff --git a/lldb/include/lldb/Target/Queue.h b/lldb/include/lldb/Target/Queue.h index 32ee24aebc1..514481fe8c9 100644 --- a/lldb/include/lldb/Target/Queue.h +++ b/lldb/include/lldb/Target/Queue.h @@ -168,6 +168,18 @@ public: m_pending_items.push_back (item); } + //------------------------------------------------------------------ + /// Return the kind (serial, concurrent) of this queue + /// + /// @return + // Whether this is a serial or a concurrent queue + //------------------------------------------------------------------ + lldb::QueueKind + GetKind (); + + void + SetKind (lldb::QueueKind kind); + private: //------------------------------------------------------------------ // For Queue only @@ -180,6 +192,7 @@ private: uint32_t m_pending_work_items_count; std::vector<lldb::QueueItemSP> m_pending_items; lldb::addr_t m_dispatch_queue_t_addr; // address of libdispatch dispatch_queue_t for this Queue + lldb::QueueKind m_kind; DISALLOW_COPY_AND_ASSIGN (Queue); }; diff --git a/lldb/include/lldb/Target/SystemRuntime.h b/lldb/include/lldb/Target/SystemRuntime.h index 5ea6e7c12bc..294d509ee64 100644 --- a/lldb/include/lldb/Target/SystemRuntime.h +++ b/lldb/include/lldb/Target/SystemRuntime.h @@ -222,7 +222,7 @@ public: /// get the queue name and return it. /// /// @param [in] dispatch_qaddr - /// The address of the dispatch_queue_t structure for this thread. + /// The address of the dispatch_qaddr pointer for this thread. /// /// @return /// The string of this queue's name. An empty string is returned if the @@ -244,7 +244,7 @@ public: /// get the queue ID and return it. /// /// @param [in] dispatch_qaddr - /// The address of the dispatch_queue_t structure for this thread. + /// The address of the dispatch_qaddr pointer for this thread. /// /// @return /// The queue ID, or if it could not be retrieved, LLDB_INVALID_QUEUE_ID. @@ -256,6 +256,26 @@ public: } //------------------------------------------------------------------ + /// Get the libdispatch_queue_t address for the queue given the thread's dispatch_qaddr. + /// + /// On systems using libdispatch queues, a thread may be associated with a queue. + /// There will be a call to get the thread's dispatch_qaddr. + /// Given the thread's dispatch_qaddr, find the libdispatch_queue_t address and + /// return it. + /// + /// @param [in] dispatch_qaddr + /// The address of the dispatch_qaddr pointer for this thread. + /// + /// @return + /// The libdispatch_queue_t address, or LLDB_INVALID_ADDRESS if unavailable/not found. + //------------------------------------------------------------------ + virtual lldb::addr_t + GetLibdispatchQueueAddressFromThreadQAddress (lldb::addr_t dispatch_qaddr) + { + return LLDB_INVALID_ADDRESS; + } + + //------------------------------------------------------------------ /// Get the pending work items for a libdispatch Queue /// /// If this system/process is using libdispatch and the runtime can do so, diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index e6bc939477a..aa484287c45 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -305,6 +305,21 @@ public: { } + //------------------------------------------------------------------ + /// Retrieve the Queue ID for the queue currently using this Thread + /// + /// If this Thread is doing work on behalf of a libdispatch/GCD queue, + /// retrieve the QueueID. + /// + /// This is a unique identifier for the libdispatch/GCD queue in a + /// process. Often starting at 1 for the initial system-created + /// queues and incrementing, a QueueID will not be reused for a + /// different queue during the lifetime of a proces. + /// + /// @return + /// A QueueID if the Thread subclass implements this, else + /// LLDB_INVALID_QUEUE_ID. + //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueID () { @@ -316,6 +331,16 @@ public: { } + //------------------------------------------------------------------ + /// Retrieve the Queue name for the queue currently using this Thread + /// + /// If this Thread is doing work on behalf of a libdispatch/GCD queue, + /// retrieve the Queue name. + /// + /// @return + /// The Queue name, if the Thread subclass implements this, else + /// NULL. + //------------------------------------------------------------------ virtual const char * GetQueueName () { @@ -327,6 +352,28 @@ public: { } + //------------------------------------------------------------------ + /// Retrieve the address of the libdispatch_queue_t struct for queue + /// currently using this Thread + /// + /// If this Thread is doing work on behalf of a libdispatch/GCD queue, + /// retrieve the address of the libdispatch_queue_t structure describing + /// the queue. + /// + /// This address may be reused for different queues later in the Process + /// lifetime and should not be used to identify a queue uniquely. Use + /// the GetQueueID() call for that. + /// + /// @return + /// The Queue's libdispatch_queue_t address if the Thread subclass + /// implements this, else LLDB_INVALID_ADDRESS. + //------------------------------------------------------------------ + virtual lldb::addr_t + GetQueueLibdispatchQueueAddress () + { + return LLDB_INVALID_ADDRESS; + } + virtual uint32_t GetStackFrameCount() { diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 347e20f21df..ecee7c67a99 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -741,6 +741,18 @@ namespace lldb { eQueueItemKindBlock } QueueItemKind; + //---------------------------------------------------------------------- + // Queue type + // libdispatch aka Grand Central Dispatch (GCD) queues can be either serial + // (executing on one thread) or concurrent (executing on multiple threads). + //---------------------------------------------------------------------- + typedef enum QueueKind + { + eQueueKindUnknown = 0, + eQueueKindSerial, + eQueueKindConcurrent + } QueueKind; + } // namespace lldb diff --git a/lldb/scripts/Python/interface/SBQueue.i b/lldb/scripts/Python/interface/SBQueue.i index 7f48166f6c2..52724032a87 100644 --- a/lldb/scripts/Python/interface/SBQueue.i +++ b/lldb/scripts/Python/interface/SBQueue.i @@ -27,12 +27,30 @@ public: lldb::SBProcess GetProcess (); + %feature("autodoc", " + Returns an lldb::queue_id_t type unique identifier number for this + queue that will not be used by any other queue during this process' + execution. These ID numbers often start at 1 with the first + system-created queues and increment from there. + ") + GetQueueID; + lldb::queue_id_t GetQueueID () const; const char * GetName () const; + %feature("autodoc", " + Returns an lldb::QueueKind enumerated value (e.g. eQueueKindUnknown, + eQueueKindSerial, eQueueKindConcurrent) describing the type of this + queue. + ") + GetKind(); + + lldb::QueueKind + GetKind(); + uint32_t GetIndexID () const; diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp index cd914bc26a8..96876ac8d4e 100644 --- a/lldb/source/API/SBQueue.cpp +++ b/lldb/source/API/SBQueue.cpp @@ -274,6 +274,17 @@ namespace lldb_private return result; } + lldb::QueueKind + GetKind () + { + lldb::QueueKind kind = eQueueKindUnknown; + QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp) + kind = queue_sp->GetKind(); + + return kind; + } + private: lldb::QueueWP m_queue_wp; std::vector<lldb::ThreadWP> m_threads; // threads currently executing this queue's items @@ -427,3 +438,9 @@ SBQueue::GetProcess () { return m_opaque_sp->GetProcess(); } + +lldb::QueueKind +SBQueue::GetKind () +{ + return m_opaque_sp->GetKind(); +} diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index fb524deda81..395f8c6e056 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -107,6 +107,25 @@ ThreadGDBRemote::GetQueueID () return LLDB_INVALID_QUEUE_ID; } +addr_t +ThreadGDBRemote::GetQueueLibdispatchQueueAddress () +{ + addr_t dispatch_queue_t_addr = LLDB_INVALID_ADDRESS; + if (m_thread_dispatch_qaddr != 0 || m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS) + { + ProcessSP process_sp (GetProcess()); + if (process_sp) + { + SystemRuntime *runtime = process_sp->GetSystemRuntime (); + if (runtime) + { + dispatch_queue_t_addr = runtime->GetLibdispatchQueueAddressFromThreadQAddress (m_thread_dispatch_qaddr); + } + } + } + return dispatch_queue_t_addr; +} + void ThreadGDBRemote::WillResume (StateType resume_state) { diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index dd4cc036ef8..47dd32affcc 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -41,6 +41,9 @@ public: virtual lldb::queue_id_t GetQueueID (); + lldb::addr_t + GetQueueLibdispatchQueueAddress (); + virtual lldb::RegisterContextSP GetRegisterContext (); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 408de4e0554..a7ed0e90a2c 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -174,6 +174,46 @@ SystemRuntimeMacOSX::GetQueueNameFromThreadQAddress (addr_t dispatch_qaddr) return dispatch_queue_name; } +lldb::addr_t +SystemRuntimeMacOSX::GetLibdispatchQueueAddressFromThreadQAddress (addr_t dispatch_qaddr) +{ + addr_t libdispatch_queue_t_address = LLDB_INVALID_ADDRESS; + Error error; + libdispatch_queue_t_address = m_process->ReadPointerFromMemory (dispatch_qaddr, error); + if (!error.Success()) + { + libdispatch_queue_t_address = LLDB_INVALID_ADDRESS; + } + return libdispatch_queue_t_address; +} + +lldb::QueueKind +SystemRuntimeMacOSX::GetQueueKind (addr_t dispatch_queue_addr) +{ + if (dispatch_queue_addr == LLDB_INVALID_ADDRESS || dispatch_queue_addr == 0) + return eQueueKindUnknown; + + QueueKind kind = eQueueKindUnknown; + ReadLibdispatchOffsets (); + if (m_libdispatch_offsets.IsValid () && m_libdispatch_offsets.dqo_version >= 4) + { + Error error; + uint64_t width = m_process->ReadUnsignedIntegerFromMemory (dispatch_queue_addr + m_libdispatch_offsets.dqo_width, m_libdispatch_offsets.dqo_width_size, 0, error); + if (error.Success()) + { + if (width == 1) + { + kind = eQueueKindSerial; + } + if (width > 1) + { + kind = eQueueKindConcurrent; + } + } + } + return kind; +} + lldb::queue_id_t SystemRuntimeMacOSX::GetQueueIDFromThreadQAddress (lldb::addr_t dispatch_qaddr) { @@ -496,6 +536,8 @@ SystemRuntimeMacOSX::PopulateQueueList (lldb_private::QueueList &queue_list) 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); } } @@ -716,6 +758,7 @@ SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR (lldb::addr_t queues_buffer, uint queue_sp->SetNumRunningWorkItems (running_work_items_count); queue_sp->SetNumPendingWorkItems (pending_work_items_count); queue_sp->SetLibdispatchQueueAddress (queue); + queue_sp->SetKind (GetQueueKind (queue)); queue_list.AddQueue (queue_sp); queues_read++; } diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h index 949653fd650..75e9b9e8f03 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -97,12 +97,18 @@ public: lldb::queue_id_t GetQueueIDFromThreadQAddress (lldb::addr_t dispatch_qaddr); + lldb::addr_t + GetLibdispatchQueueAddressFromThreadQAddress (lldb::addr_t dispatch_qaddr); + void PopulatePendingItemsForQueue (lldb_private::Queue *queue); void CompleteQueueItem (lldb_private::QueueItem *queue_item, lldb::addr_t item_ref); + virtual lldb::QueueKind + GetQueueKind (lldb::addr_t dispatch_queue_addr); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ diff --git a/lldb/source/Target/Queue.cpp b/lldb/source/Target/Queue.cpp index 2b9d2a0ed9a..7cfa6fa5582 100644 --- a/lldb/source/Target/Queue.cpp +++ b/lldb/source/Target/Queue.cpp @@ -23,7 +23,8 @@ Queue::Queue (ProcessSP process_sp, lldb::queue_id_t queue_id, const char *queue m_running_work_items_count(0), m_pending_work_items_count(0), m_pending_items(), - m_dispatch_queue_t_addr(LLDB_INVALID_ADDRESS) + m_dispatch_queue_t_addr(LLDB_INVALID_ADDRESS), + m_kind (eQueueKindUnknown) { if (queue_name) m_queue_name = queue_name; @@ -125,3 +126,15 @@ Queue::GetPendingItems () } return m_pending_items; } + +lldb::QueueKind +Queue::GetKind () +{ + return m_kind; +} + +void +Queue::SetKind (lldb::QueueKind kind) +{ + m_kind = kind; +} |