[Lldb-commits] [lldb] r194366 - The Threads created when requesting extended backtraces need to be owned by

Jason Molenda jmolenda at apple.com
Sun Nov 10 21:19:34 PST 2013


Author: jmolenda
Date: Sun Nov 10 23:19:34 2013
New Revision: 194366

URL: http://llvm.org/viewvc/llvm-project?rev=194366&view=rev
Log:
The Threads created when requesting extended backtraces need to be owned by
something; add a new ExtendedThreadList to Process where they can be retained
for the duration of a public stop.
<rdar://problem/15314068> 

Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/API/SBThread.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=194366&r1=194365&r2=194366&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Sun Nov 10 23:19:34 2013
@@ -3300,7 +3300,18 @@ public:
     {
         return m_thread_list;
     }
-    
+
+    // When ExtendedBacktraces are requested, the HistoryThreads that are
+    // created need an owner -- they're saved here in the Process.  The
+    // threads in this list are not iterated over - driver programs need to
+    // request the extended backtrace calls starting from a root concrete
+    // thread one by one.
+    ThreadList &
+    GetExtendedThreadList ()
+    {
+        return m_extended_thread_list;
+    }
+
     ThreadList::ThreadIterable
     Threads ()
     {
@@ -3672,6 +3683,7 @@ protected:
     ThreadList                  m_thread_list_real;     ///< The threads for this process as are known to the protocol we are debugging with
     ThreadList                  m_thread_list;          ///< The threads for this process as the user will see them. This is usually the same as
                                                         ///< m_thread_list_real, but might be different if there is an OS plug-in creating memory threads
+    ThreadList                  m_extended_thread_list; ///< Owner for extended threads that may be generated, cleared on public stops
     std::vector<Notifications>  m_notifications;        ///< The list of notifications that this process can deliver.
     std::vector<lldb::addr_t>   m_image_tokens;
     Listener                    &m_listener;

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=194366&r1=194365&r2=194366&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Sun Nov 10 23:19:34 2013
@@ -1295,16 +1295,22 @@ SBThread::GetExtendedBacktrace (const ch
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            ThreadSP real_thread(exe_ctx.GetThreadPtr());
+            ThreadSP real_thread(exe_ctx.GetThreadSP());
             if (real_thread)
             {
                 ConstString type_const (type);
-                SystemRuntime *runtime = exe_ctx.GetProcessPtr()->GetSystemRuntime();
-                if (runtime)
+                Process *process = exe_ctx.GetProcessPtr();
+                if (process)
                 {
-                    ThreadSP origin_thread = runtime->GetExtendedBacktrace (real_thread, type_const);
-                    if (origin_thread && origin_thread->IsValid())
-                        sb_origin_thread.SetThread (origin_thread);
+                    SystemRuntime *runtime = process->GetSystemRuntime();
+                    if (runtime)
+                    {
+                        ThreadSP new_thread_sp (runtime->GetExtendedBacktrace (real_thread, type_const));
+                        // Save this in the Process' ExtendedThreadList so a strong pointer retains the
+                        // object.
+                        process->GetExtendedThreadList().AddThread (new_thread_sp);
+                        sb_origin_thread.SetThread (new_thread_sp);
+                    }
                 }
             }
         }





More information about the lldb-commits mailing list