[Lldb-commits] [lldb] r193132 - Expose the Thread::GetQueueID() method through the SBThread API, similar to

Jason Molenda jmolenda at apple.com
Mon Oct 21 16:52:55 PDT 2013


Author: jmolenda
Date: Mon Oct 21 18:52:54 2013
New Revision: 193132

URL: http://llvm.org/viewvc/llvm-project?rev=193132&view=rev
Log:
Expose the Thread::GetQueueID() method through the SBThread API, similar to
the existing SBThread::GetQueueName() method.

Modified:
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/scripts/Python/interface/SBThread.i
    lldb/trunk/source/API/SBThread.cpp

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=193132&r1=193131&r2=193132&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Mon Oct 21 18:52:54 2013
@@ -94,6 +94,9 @@ public:
     const char *
     GetQueueName() const;
 
+    lldb::queue_id_t
+    GetQueueID() const;
+
     void
     StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
 

Modified: lldb/trunk/scripts/Python/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=193132&r1=193131&r2=193132&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBThread.i (original)
+++ lldb/trunk/scripts/Python/interface/SBThread.i Mon Oct 21 18:52:54 2013
@@ -133,6 +133,9 @@ public:
     const char *
     GetQueueName() const;
 
+    lldb::queue_id_t
+    GetQueueID() const;
+
     void
     StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
 
@@ -281,6 +284,9 @@ public:
         __swig_getmethods__["queue"] = GetQueueName
         if _newclass: queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''')
 
+        __swig_getmethods__["queue_id"] = GetQueueID
+        if _newclass: queue = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''')
+
         __swig_getmethods__["stop_reason"] = GetStopReason
         if _newclass: stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''')
 

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=193132&r1=193131&r2=193132&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Mon Oct 21 18:52:54 2013
@@ -507,6 +507,34 @@ SBThread::GetQueueName () const
     return name;
 }
 
+lldb::queue_id_t
+SBThread::GetQueueID () const
+{
+    queue_id_t id = LLDB_INVALID_QUEUE_ID;
+    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()))
+        {
+            id = exe_ctx.GetThreadPtr()->GetQueueID();
+        }
+        else
+        {
+            if (log)
+                log->Printf ("SBThread(%p)::GetQueueID() => error: process is running", exe_ctx.GetThreadPtr());
+        }
+    }
+    
+    if (log)
+        log->Printf ("SBThread(%p)::GetQueueID () => 0x%" PRIx64, exe_ctx.GetThreadPtr(), id);
+
+    return id;
+}
+
 SBError
 SBThread::ResumeNewPlan (ExecutionContext &exe_ctx, ThreadPlan *new_plan)
 {





More information about the lldb-commits mailing list