[Lldb-commits] [lldb] r192949 - Move the code which translates a dispatch_qaddr into a

Jason Molenda jmolenda at apple.com
Thu Oct 17 22:55:25 PDT 2013


Author: jmolenda
Date: Fri Oct 18 00:55:24 2013
New Revision: 192949

URL: http://llvm.org/viewvc/llvm-project?rev=192949&view=rev
Log:
Move the code which translates a dispatch_qaddr into a
queue name out of ProcessGDBRemote and in to the Platform
plugin, specifically PlatformDarwin.

Also add a Platform method to translate a dispatch_quaddr
to a QueueID, and a Thread::GetQueueID().

I'll add an SBThread::GetQueueID() next.

Modified:
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/include/lldb/lldb-defines.h
    lldb/trunk/include/lldb/lldb-types.h
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
    lldb/trunk/tools/darwin-threads/examine-threads.c

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Fri Oct 18 00:55:24 2013
@@ -732,7 +732,60 @@ namespace lldb_private {
         {
             return 1;
         }
-                
+
+        //------------------------------------------------------------------
+        /// Locate a queue name given a thread's qaddr
+        ///
+        /// On a system using libdispatch ("Grand Central Dispatch") style
+        /// queues, a thread may be associated with a GCD queue or not,
+        /// and a queue may be associated with multiple threads.
+        /// The process/thread must provide a way to find the "dispatch_qaddr" 
+        /// for each thread, and from that dispatch_qaddr this Platform method
+        /// will locate the queue name and provide that.
+        ///
+        /// @param[in] process
+        ///     A process is required for reading memory.
+        ///
+        /// @param[in] dispatch_qaddr
+        ///     The dispatch_qaddr for this thread.
+        ///
+        /// @return
+        ///     The name of the queue, if there is one.  An empty string
+        ///     means that this thread is not associated with a dispatch 
+        ///     queue.
+        //------------------------------------------------------------------
+        virtual std::string
+        GetQueueNameForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
+        {
+            return "";
+        }
+
+        //------------------------------------------------------------------
+        /// Locate a queue ID given a thread's qaddr
+        ///
+        /// On a system using libdispatch ("Grand Central Dispatch") style
+        /// queues, a thread may be associated with a GCD queue or not,
+        /// and a queue may be associated with multiple threads.
+        /// The process/thread must provide a way to find the "dispatch_qaddr" 
+        /// for each thread, and from that dispatch_qaddr this Platform method
+        /// will locate the queue ID and provide that.
+        ///
+        /// @param[in] process
+        ///     A process is required for reading memory.
+        ///
+        /// @param[in] dispatch_qaddr
+        ///     The dispatch_qaddr for this thread.
+        ///
+        /// @return
+        ///     The queue_id for this thread, if this thread is associated
+        ///     with a dispatch queue.  Else LLDB_INVALID_QUEUE_ID is returned.
+        //------------------------------------------------------------------
+        virtual lldb::queue_id_t
+        GetQueueIDForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
+        {
+            return LLDB_INVALID_QUEUE_ID;
+        }
+
     protected:
         bool m_is_host;
         // Set to true when we are able to actually set the OS version while 

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Fri Oct 18 00:55:24 2013
@@ -339,6 +339,12 @@ public:
         return NULL;
     }
 
+    virtual lldb::queue_id_t
+    GetQueueID ()
+    {
+        return LLDB_INVALID_QUEUE_ID;
+    }
+
     virtual const char *
     GetQueueName ()
     {

Modified: lldb/trunk/include/lldb/lldb-defines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-defines.h (original)
+++ lldb/trunk/include/lldb/lldb-defines.h Fri Oct 18 00:55:24 2013
@@ -83,6 +83,7 @@
 #define LLDB_INVALID_SIGNAL_NUMBER      INT32_MAX
 #define LLDB_INVALID_OFFSET             UINT64_MAX // Must match max of lldb::offset_t
 #define LLDB_INVALID_LINE_NUMBER        UINT32_MAX
+#define LLDB_INVALID_QUEUE_ID           0
 
 //----------------------------------------------------------------------
 /// CPU Type defintions

Modified: lldb/trunk/include/lldb/lldb-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-types.h (original)
+++ lldb/trunk/include/lldb/lldb-types.h Fri Oct 18 00:55:24 2013
@@ -95,6 +95,7 @@ namespace lldb
     typedef int32_t     break_id_t;
     typedef int32_t     watch_id_t;
     typedef void *      clang_type_t;
+    typedef uint64_t    queue_id_t;
 }
 
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Oct 18 00:55:24 2013
@@ -38,7 +38,8 @@ using namespace lldb_private;
 //------------------------------------------------------------------
 PlatformDarwin::PlatformDarwin (bool is_host) :
     PlatformPOSIX(is_host),  // This is the local host platform
-    m_developer_directory ()
+    m_developer_directory (),
+    m_dispatch_queue_offsets_addr (LLDB_INVALID_ADDRESS)
 {
 }
 
@@ -847,6 +848,113 @@ PlatformDarwin::ModuleIsExcludedForNonMo
         return false;
 }
 
+std::string
+PlatformDarwin::GetQueueNameForThreadQAddress (Process *process, addr_t thread_dispatch_qaddr)
+{
+    std::string dispatch_queue_name;
+    if (thread_dispatch_qaddr == LLDB_INVALID_ADDRESS || thread_dispatch_qaddr == 0 || process == NULL)
+        return "";
+
+    Target &target = process->GetTarget();
+
+    // Cache the dispatch_queue_offsets_addr value so we don't always have
+    // to look it up
+    if (m_dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS)
+    {
+        static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets");
+        const Symbol *dispatch_queue_offsets_symbol = NULL;
+
+        // libdispatch symbols were in libSystem.B.dylib up through Mac OS X 10.6 ("Snow Leopard")
+        ModuleSpec libSystem_module_spec (FileSpec("libSystem.B.dylib", false));
+        ModuleSP module_sp(target.GetImages().FindFirstModule (libSystem_module_spec));
+        if (module_sp)
+            dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
+        
+        // libdispatch symbols are in their own dylib as of Mac OS X 10.7 ("Lion") and later
+        if (dispatch_queue_offsets_symbol == NULL)
+        {
+            ModuleSpec libdispatch_module_spec (FileSpec("libdispatch.dylib", false));
+            module_sp = target.GetImages().FindFirstModule (libdispatch_module_spec);
+            if (module_sp)
+                dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
+        }
+        if (dispatch_queue_offsets_symbol)
+            m_dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetAddress().GetLoadAddress(&target);
+
+        if (m_dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS)
+            return "";
+    }
+
+    uint8_t memory_buffer[8];
+    DataExtractor data (memory_buffer, 
+                        sizeof(memory_buffer), 
+                        target.GetArchitecture().GetByteOrder(), 
+                        target.GetArchitecture().GetAddressByteSize());
+
+    // Excerpt from src/queue_private.h
+    // version 4 of this struct first appears in Mac OS X 10.9 ("Mavericks") and iOS 7.
+    // TODO When version 1-3 no longer needs to be supported, the dqo_label offset should be
+    // read from the inferior one time and saved in an ivar like m_dispatch_queue_offsets_addr.
+    struct dispatch_queue_offsets_s
+    {
+        uint16_t dqo_version;
+        uint16_t dqo_label;      // in version 1-3, offset to string; in version 4+, offset to a pointer to a string
+        uint16_t dqo_label_size; // in version 1-3, length of string; in version 4+, size of a (void*) in this process
+    } dispatch_queue_offsets;
+
+    Error error;
+    if (process->ReadMemory (m_dispatch_queue_offsets_addr, memory_buffer, sizeof(dispatch_queue_offsets), error) == sizeof(dispatch_queue_offsets))
+    {
+        lldb::offset_t data_offset = 0;
+        if (data.GetU16(&data_offset, &dispatch_queue_offsets.dqo_version, sizeof(dispatch_queue_offsets)/sizeof(uint16_t)))
+        {
+            if (process->ReadMemory (thread_dispatch_qaddr, &memory_buffer, data.GetAddressByteSize(), error) == data.GetAddressByteSize())
+            {
+                data_offset = 0;
+                lldb::addr_t queue_addr = data.GetAddress(&data_offset);
+                if (dispatch_queue_offsets.dqo_version >= 4)
+                {
+                    // libdispatch versions 4+, pointer to dispatch name is in the 
+                    // queue structure.
+                    lldb::addr_t pointer_to_label_address = queue_addr + dispatch_queue_offsets.dqo_label;
+                    if (process->ReadMemory (pointer_to_label_address, &memory_buffer, data.GetAddressByteSize(), error) == data.GetAddressByteSize())
+                    {
+                        data_offset = 0;
+                        lldb::addr_t label_addr = data.GetAddress(&data_offset);
+                        process->ReadCStringFromMemory (label_addr, dispatch_queue_name, error);
+                    }
+                }
+                else
+                {
+                    // libdispatch versions 1-3, dispatch name is a fixed width char array
+                    // in the queue structure.
+                    lldb::addr_t label_addr = queue_addr + dispatch_queue_offsets.dqo_label;
+                    dispatch_queue_name.resize(dispatch_queue_offsets.dqo_label_size, '\0');
+                    size_t bytes_read = process->ReadMemory (label_addr, &dispatch_queue_name[0], dispatch_queue_offsets.dqo_label_size, error);
+                    if (bytes_read < dispatch_queue_offsets.dqo_label_size)
+                        dispatch_queue_name.erase (bytes_read);
+                }
+            }
+        }
+    }
+    return dispatch_queue_name;
+}
+
+lldb::queue_id_t
+PlatformDarwin::GetQueueIDForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
+{
+    if (dispatch_qaddr == LLDB_INVALID_ADDRESS || dispatch_qaddr == 0 || process == NULL)
+        return LLDB_INVALID_QUEUE_ID;
+
+    Error error;
+    uint32_t ptr_size = process->GetTarget().GetArchitecture().GetAddressByteSize();
+    uint64_t this_thread_queue_id = process->ReadUnsignedIntegerFromMemory (dispatch_qaddr, ptr_size, LLDB_INVALID_QUEUE_ID, error);
+    if (!error.Success())
+        return LLDB_INVALID_QUEUE_ID;
+
+    return this_thread_queue_id;
+}
+
 
 bool
 PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Fri Oct 18 00:55:24 2013
@@ -111,6 +111,12 @@ public:
     virtual size_t
     GetEnvironment (lldb_private::StringList &environment);
 
+    std::string
+    GetQueueNameForThreadQAddress (lldb_private::Process *process, lldb::addr_t dispatch_qaddr);
+
+    lldb::queue_id_t
+    GetQueueIDForThreadQAddress (lldb_private::Process *process, lldb::addr_t dispatch_qaddr);
+
     bool
     ARMGetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
     
@@ -129,6 +135,7 @@ protected:
                                    bool *did_create_ptr);
 
     std::string m_developer_directory;
+    lldb::addr_t m_dispatch_queue_offsets_addr;
     
     const char *
     GetDeveloperDirectory();

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Oct 18 00:55:24 2013
@@ -266,7 +266,6 @@ ProcessGDBRemote::ProcessGDBRemote(Targe
     m_continue_C_tids (),
     m_continue_s_tids (),
     m_continue_S_tids (),
-    m_dispatch_queue_offsets_addr (LLDB_INVALID_ADDRESS),
     m_max_memory_size (512),
     m_addr_to_mmap_size (),
     m_thread_create_bp_sp (),
@@ -934,8 +933,6 @@ ProcessGDBRemote::DidLaunchOrAttach ()
         log->Printf ("ProcessGDBRemote::DidLaunch()");
     if (GetID() != LLDB_INVALID_PROCESS_ID)
     {
-        m_dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS;
-
         BuildDynamicRegisterInfo (false);
 
         // See if the GDB server supports the qHostInfo information
@@ -2994,97 +2991,6 @@ ProcessGDBRemote::AsyncThread (void *arg
     return NULL;
 }
 
-const char *
-ProcessGDBRemote::GetDispatchQueueNameForThread
-(
-    addr_t thread_dispatch_qaddr,
-    std::string &dispatch_queue_name
-)
-{
-    dispatch_queue_name.clear();
-    if (thread_dispatch_qaddr != 0 && thread_dispatch_qaddr != LLDB_INVALID_ADDRESS)
-    {
-        // Cache the dispatch_queue_offsets_addr value so we don't always have
-        // to look it up
-        if (m_dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS)
-        {
-            static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets");
-            const Symbol *dispatch_queue_offsets_symbol = NULL;
-            ModuleSpec libSystem_module_spec (FileSpec("libSystem.B.dylib", false));
-            ModuleSP module_sp(GetTarget().GetImages().FindFirstModule (libSystem_module_spec));
-            if (module_sp)
-                dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
-            
-            if (dispatch_queue_offsets_symbol == NULL)
-            {
-                ModuleSpec libdispatch_module_spec (FileSpec("libdispatch.dylib", false));
-                module_sp = GetTarget().GetImages().FindFirstModule (libdispatch_module_spec);
-                if (module_sp)
-                    dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
-            }
-            if (dispatch_queue_offsets_symbol)
-                m_dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetAddress().GetLoadAddress(&m_target);
-
-            if (m_dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS)
-                return NULL;
-        }
-
-        uint8_t memory_buffer[8];
-        DataExtractor data (memory_buffer, 
-                            sizeof(memory_buffer), 
-                            m_target.GetArchitecture().GetByteOrder(), 
-                            m_target.GetArchitecture().GetAddressByteSize());
-
-        // Excerpt from src/queue_private.h
-        struct dispatch_queue_offsets_s
-        {
-            uint16_t dqo_version;
-            uint16_t dqo_label;      // in version 1-3, offset to string; in version 4+, offset to a pointer to a string
-            uint16_t dqo_label_size; // in version 1-3, length of string; in version 4+, size of a (void*) in this process
-        } dispatch_queue_offsets;
-
-
-        Error error;
-        if (ReadMemory (m_dispatch_queue_offsets_addr, memory_buffer, sizeof(dispatch_queue_offsets), error) == sizeof(dispatch_queue_offsets))
-        {
-            lldb::offset_t data_offset = 0;
-            if (data.GetU16(&data_offset, &dispatch_queue_offsets.dqo_version, sizeof(dispatch_queue_offsets)/sizeof(uint16_t)))
-            {
-                if (ReadMemory (thread_dispatch_qaddr, &memory_buffer, data.GetAddressByteSize(), error) == data.GetAddressByteSize())
-                {
-                    data_offset = 0;
-                    lldb::addr_t queue_addr = data.GetAddress(&data_offset);
-                    if (dispatch_queue_offsets.dqo_version >= 4)
-                    {
-                        // libdispatch versions 4+, pointer to dispatch name is in the 
-                        // queue structure.
-                        lldb::addr_t pointer_to_label_address = queue_addr + dispatch_queue_offsets.dqo_label;
-                        if (ReadMemory (pointer_to_label_address, &memory_buffer, data.GetAddressByteSize(), error) == data.GetAddressByteSize())
-                        {
-                            data_offset = 0;
-                            lldb::addr_t label_addr = data.GetAddress(&data_offset);
-                            ReadCStringFromMemory (label_addr, dispatch_queue_name, error);
-                        }
-                    }
-                    else
-                    {
-                        // libdispatch versions 1-3, dispatch name is a fixed width char array
-                        // in the queue structure.
-                        lldb::addr_t label_addr = queue_addr + dispatch_queue_offsets.dqo_label;
-                        dispatch_queue_name.resize(dispatch_queue_offsets.dqo_label_size, '\0');
-                        size_t bytes_read = ReadMemory (label_addr, &dispatch_queue_name[0], dispatch_queue_offsets.dqo_label_size, error);
-                        if (bytes_read < dispatch_queue_offsets.dqo_label_size)
-                            dispatch_queue_name.erase (bytes_read);
-                    }
-                }
-            }
-        }
-    }
-    if (dispatch_queue_name.empty())
-        return NULL;
-    return dispatch_queue_name.c_str();
-}
-
 //uint32_t
 //ProcessGDBRemote::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids)
 //{

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Oct 18 00:55:24 2013
@@ -332,7 +332,6 @@ protected:
     tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
     tid_collection m_continue_s_tids;                  // 's' for step
     tid_sig_collection m_continue_S_tids; // 'S' for step with signal
-    lldb::addr_t m_dispatch_queue_offsets_addr;
     size_t m_max_memory_size;       // The maximum number of bytes to read/write when reading and writing memory
     MMapMap m_addr_to_mmap_size;
     lldb::BreakpointSP m_thread_create_bp_sp;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Fri Oct 18 00:55:24 2013
@@ -10,16 +10,17 @@
 
 #include "ThreadGDBRemote.h"
 
+#include "lldb/Breakpoint/Watchpoint.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/StreamString.h"
 #include "lldb/Core/State.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Unwind.h"
-#include "lldb/Breakpoint/Watchpoint.h"
 
 #include "ProcessGDBRemote.h"
 #include "ProcessGDBRemoteLog.h"
@@ -73,13 +74,38 @@ ThreadGDBRemote::GetQueueName ()
         ProcessSP process_sp (GetProcess());
         if (process_sp)
         {
-            ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get());
-            return gdb_process->GetDispatchQueueNameForThread (m_thread_dispatch_qaddr, m_dispatch_queue_name);
+            PlatformSP platform_sp (process_sp->GetTarget().GetPlatform());
+            if (platform_sp)
+            {
+                m_dispatch_queue_name = platform_sp->GetQueueNameForThreadQAddress (process_sp.get(), m_thread_dispatch_qaddr);
+            }
+            if (m_dispatch_queue_name.length() > 0)
+            {
+                return m_dispatch_queue_name.c_str();
+            }
         }
     }
     return NULL;
 }
 
+queue_id_t
+ThreadGDBRemote::GetQueueID ()
+{
+    if (m_thread_dispatch_qaddr != 0 || m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS)
+    {
+        ProcessSP process_sp (GetProcess());
+        if (process_sp)
+        {
+            PlatformSP platform_sp (process_sp->GetTarget().GetPlatform());
+            if (platform_sp)
+            {
+                return platform_sp->GetQueueIDForThreadQAddress (process_sp.get(), m_thread_dispatch_qaddr);
+            }
+        }
+    }
+    return LLDB_INVALID_QUEUE_ID;
+}
+
 void
 ThreadGDBRemote::WillResume (StateType resume_state)
 {

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Fri Oct 18 00:55:24 2013
@@ -38,6 +38,9 @@ public:
     virtual const char *
     GetQueueName ();
 
+    virtual lldb::queue_id_t
+    GetQueueID ();
+
     virtual lldb::RegisterContextSP
     GetRegisterContext ();
 

Modified: lldb/trunk/tools/darwin-threads/examine-threads.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-threads/examine-threads.c?rev=192949&r1=192948&r2=192949&view=diff
==============================================================================
--- lldb/trunk/tools/darwin-threads/examine-threads.c (original)
+++ lldb/trunk/tools/darwin-threads/examine-threads.c Fri Oct 18 00:55:24 2013
@@ -8,6 +8,7 @@
 #include <ctype.h>
 #include <libproc.h>
 #include <errno.h>
+#include <dispatch/dispatch.h>
 
 /* Step through the process table, find a matching process name, return
    the pid of that matched process.
@@ -419,20 +420,23 @@ main (int argc, char **argv)
             case TH_STATE_HALTED: puts ("halted"); break;
             default: puts ("");
           }
+
+          printf ("           pthread handle id 0x%llx (not the same value as pthread_self() returns)\n", (uint64_t) identifier_info.thread_handle);
+
+          struct proc_threadinfo pth;
+          int proc_threadinfo_succeeded = get_proc_threadinfo (pid, identifier_info.thread_handle, &pth);
+
+          if (proc_threadinfo_succeeded && pth.pth_name[0] != '\0')
+            printf ("           thread name '%s'\n", pth.pth_name);
+
+          printf ("           libdispatch qaddr 0x%llx (not the same as the dispatch_queue_t token)\n", (uint64_t) identifier_info.dispatch_qaddr);
+
           if (verbose)
             {
               printf ("           (examine-threads port namespace) mach port # 0x%4.4x\n", (int) thread_list[i]);
               thread_t mach_port_inferior_namespace;
               if (inferior_namespace_mach_port_num (task, thread_list[i], &mach_port_inferior_namespace))
                   printf ("           (inferior port namepsace) mach port # 0x%4.4x\n", (int) mach_port_inferior_namespace);
-              printf ("           pthread handle id 0x%llx\n", (uint64_t) identifier_info.thread_handle);
-
-              struct proc_threadinfo pth;
-              int proc_threadinfo_succeeded = get_proc_threadinfo (pid, identifier_info.thread_handle, &pth);
-
-              if (proc_threadinfo_succeeded && pth.pth_name[0] != '\0')
-                printf ("           thread name '%s' ", pth.pth_name);
-
               printf ("           user %d.%06ds, system %d.%06ds", 
                               basic_info->user_time.seconds, basic_info->user_time.microseconds, 
                               basic_info->system_time.seconds, basic_info->system_time.microseconds);





More information about the lldb-commits mailing list