[Lldb-commits] [lldb] r201372 - Fixed deadlocks that could occur when using python for breakpoints, operating system plugins, and other async python usage.

Greg Clayton gclayton at apple.com
Thu Feb 13 15:34:39 PST 2014


Author: gclayton
Date: Thu Feb 13 17:34:38 2014
New Revision: 201372

URL: http://llvm.org/viewvc/llvm-project?rev=201372&view=rev
Log:
Fixed deadlocks that could occur when using python for breakpoints, operating system plugins, and other async python usage.

<rdar://problem/16054348>
<rdar://problem/16040833>


Modified:
    lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
    lldb/trunk/include/lldb/Target/ThreadList.h
    lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
    lldb/trunk/source/Core/Log.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
    lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
    lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Target/ThreadList.cpp
    lldb/trunk/source/lldb-log.cpp

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Thu Feb 13 17:34:38 2014
@@ -287,7 +287,7 @@ public:
 protected:
 
     bool
-    EnterSession (bool init_lldb_globals,
+    EnterSession (uint16_t on_entry_flags,
                   FILE *in,
                   FILE *out,
                   FILE *err);
@@ -350,7 +350,8 @@ public:
         {
             AcquireLock         = 0x0001,
             InitSession         = 0x0002,
-            InitGlobals         = 0x0004
+            InitGlobals         = 0x0004,
+            NoSTDIN             = 0x0008
         };
         
         enum OnLeave
@@ -375,7 +376,7 @@ public:
         DoAcquireLock ();
         
         bool
-        DoInitSession (bool init_lldb_globals, FILE *in, FILE *out, FILE *err);
+        DoInitSession (uint16_t on_entry_flags, FILE *in, FILE *out, FILE *err);
         
         bool
         DoFreeLock ();

Modified: lldb/trunk/include/lldb/Target/ThreadList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadList.h?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadList.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadList.h Thu Feb 13 17:34:38 2014
@@ -45,6 +45,8 @@ public:
     void
     AddThread (const lldb::ThreadSP &thread_sp);
 
+    void
+    InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx);
     // Return the selected thread if there is one.  Otherwise, return the thread
     // selected at index 0.
     lldb::ThreadSP

Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Thu Feb 13 17:34:38 2014
@@ -100,6 +100,16 @@
             ReferencedContainer = "container:lldb.xcodeproj">
          </BuildableReference>
       </BuildableProductRunnable>
+      <CommandLineArguments>
+         <CommandLineArgument
+            argument = "/Volumes/work/gclayton/Documents/src/args/a.out"
+            isEnabled = "YES">
+         </CommandLineArgument>
+         <CommandLineArgument
+            argument = "-o "settings set target.process.python-os-plugin-path /Volumes/work/gclayton/Documents/src/lldb/tot/examples/python/operating_system.py""
+            isEnabled = "YES">
+         </CommandLineArgument>
+      </CommandLineArguments>
       <EnvironmentVariables>
          <EnvironmentVariable
             key = "LLDB_LAUNCH_FLAG_DISABLE_ASLR"

Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Thu Feb 13 17:34:38 2014
@@ -83,7 +83,10 @@ Log::GetMask() const
 void
 Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
 {
-    if (m_stream_sp)
+    // Make a copy of our stream shared pointer in case someone disables our
+    // log while we are logging and releases the stream
+    StreamSP stream_sp(m_stream_sp);
+    if (stream_sp)
     {
         static uint32_t g_sequence_id = 0;
         StreamString header;
@@ -116,11 +119,11 @@ Log::PrintfWithFlagsVarArg (uint32_t fla
         }
 
         header.PrintfVarArg (format, args);
-        m_stream_sp->Printf("%s\n", header.GetData());
+        stream_sp->Printf("%s\n", header.GetData());
         
         if (m_options.Test (LLDB_LOG_OPTION_BACKTRACE))
-            Host::Backtrace (*m_stream_sp, 1024);
-        m_stream_sp->Flush();
+            Host::Backtrace (*stream_sp, 1024);
+        stream_sp->Flush();
     }
 }
 
@@ -467,8 +470,11 @@ Log::GetVerbose() const
     if (m_options.Test(LLDB_LOG_OPTION_VERBOSE))
         return true;
         
-    if (m_stream_sp)
-        return m_stream_sp->GetVerbose();
+    // Make a copy of our stream shared pointer in case someone disables our
+    // log while we are logging and releases the stream
+    StreamSP stream_sp(m_stream_sp);
+    if (stream_sp)
+        return stream_sp->GetVerbose();
     return false;
 }
 
@@ -478,8 +484,11 @@ Log::GetVerbose() const
 bool
 Log::GetDebug() const
 {
-    if (m_stream_sp)
-        return m_stream_sp->GetDebug();
+    // Make a copy of our stream shared pointer in case someone disables our
+    // log while we are logging and releases the stream
+    StreamSP stream_sp(m_stream_sp);
+    if (stream_sp)
+        return stream_sp->GetDebug();
     return false;
 }
 

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Feb 13 17:34:38 2014
@@ -85,7 +85,7 @@ ScriptInterpreterPython::Locker::Locker
     DoAcquireLock();
     if ((on_entry & InitSession) == InitSession)
     {
-        if (DoInitSession((on_entry & InitGlobals) == InitGlobals, in, out, err) == false)
+        if (DoInitSession(on_entry, in, out, err) == false)
         {
             // Don't teardown the session if we didn't init it.
             m_teardown_session = false;
@@ -104,11 +104,11 @@ ScriptInterpreterPython::Locker::DoAcqui
 }
 
 bool
-ScriptInterpreterPython::Locker::DoInitSession(bool init_lldb_globals, FILE *in, FILE *out, FILE *err)
+ScriptInterpreterPython::Locker::DoInitSession(uint16_t on_entry_flags, FILE *in, FILE *out, FILE *err)
 {
     if (!m_python_interpreter)
         return false;
-    return m_python_interpreter->EnterSession (init_lldb_globals, in, out, err);
+    return m_python_interpreter->EnterSession (on_entry_flags, in, out, err);
 }
 
 bool
@@ -377,7 +377,7 @@ ScriptInterpreterPython::LeaveSession ()
 }
 
 bool
-ScriptInterpreterPython::EnterSession (bool init_lldb_globals,
+ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
                                        FILE *in,
                                        FILE *out,
                                        FILE *err)
@@ -388,19 +388,19 @@ ScriptInterpreterPython::EnterSession (b
     if (m_session_is_active)
     {
         if (log)
-            log->Printf("ScriptInterpreterPython::EnterSession(init_lldb_globals=%i) session is already active, returning without doing anything", init_lldb_globals);
+            log->Printf("ScriptInterpreterPython::EnterSession(on_entry_flags=0x%" PRIx16 ") session is already active, returning without doing anything", on_entry_flags);
         return false;
     }
 
     if (log)
-        log->Printf("ScriptInterpreterPython::EnterSession(init_lldb_globals=%i)", init_lldb_globals);
+        log->Printf("ScriptInterpreterPython::EnterSession(on_entry_flags=0x%" PRIx16 ")", on_entry_flags);
     
 
     m_session_is_active = true;
 
     StreamString run_string;
 
-    if (init_lldb_globals)
+    if (on_entry_flags & Locker::InitGlobals)
     {
         run_string.Printf (    "run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64, m_dictionary_name.c_str(), GetCommandInterpreter().GetDebugger().GetID());
         run_string.Printf (    "; lldb.debugger = lldb.SBDebugger.FindDebuggerWithID (%" PRIu64 ")", GetCommandInterpreter().GetDebugger().GetID());
@@ -430,7 +430,7 @@ ScriptInterpreterPython::EnterSession (b
         if (in == NULL || out == NULL || err == NULL)
             m_interpreter.GetDebugger().AdoptTopIOHandlerFilesIfInvalid (in_sp, out_sp, err_sp);
 
-        if (in == NULL && in_sp)
+        if (in == NULL && in_sp && (on_entry_flags & Locker::NoSTDIN) == 0)
             in = in_sp->GetFile().GetStream();
         if (in)
         {
@@ -1288,7 +1288,9 @@ ScriptInterpreterPython::OSPlugin_Create
     void* ret_val;
     
     {
-        Locker py_lock(this,Locker::AcquireLock,Locker::FreeLock);
+        Locker py_lock  (this,
+                         Locker::AcquireLock | Locker::NoSTDIN,
+                         Locker::FreeLock);
         ret_val = g_swig_create_os_plugin    (class_name,
                                               m_dictionary_name.c_str(),
                                               process_sp);
@@ -1300,7 +1302,9 @@ ScriptInterpreterPython::OSPlugin_Create
 lldb::ScriptInterpreterObjectSP
 ScriptInterpreterPython::OSPlugin_RegisterInfo (lldb::ScriptInterpreterObjectSP os_plugin_object_sp)
 {
-    Locker py_lock(this,Locker::AcquireLock,Locker::FreeLock);
+    Locker py_lock(this,
+                   Locker::AcquireLock | Locker::NoSTDIN,
+                   Locker::FreeLock);
     
     static char callee_name[] = "get_register_info";
     
@@ -1359,7 +1363,9 @@ ScriptInterpreterPython::OSPlugin_Regist
 lldb::ScriptInterpreterObjectSP
 ScriptInterpreterPython::OSPlugin_ThreadsInfo (lldb::ScriptInterpreterObjectSP os_plugin_object_sp)
 {
-    Locker py_lock(this,Locker::AcquireLock,Locker::FreeLock);
+    Locker py_lock (this,
+                    Locker::AcquireLock | Locker::NoSTDIN,
+                    Locker::FreeLock);
 
     static char callee_name[] = "get_thread_info";
     
@@ -1445,7 +1451,9 @@ lldb::ScriptInterpreterObjectSP
 ScriptInterpreterPython::OSPlugin_RegisterContextData (lldb::ScriptInterpreterObjectSP os_plugin_object_sp,
                                                        lldb::tid_t tid)
 {
-    Locker py_lock(this,Locker::AcquireLock,Locker::FreeLock);
+    Locker py_lock (this,
+                    Locker::AcquireLock | Locker::NoSTDIN,
+                    Locker::FreeLock);
 
     static char callee_name[] = "get_register_data";
     static char *param_format = const_cast<char *>(GetPythonValueFormatString(tid));
@@ -1507,7 +1515,9 @@ ScriptInterpreterPython::OSPlugin_Create
                                                 lldb::tid_t tid,
                                                 lldb::addr_t context)
 {
-    Locker py_lock(this,Locker::AcquireLock,Locker::FreeLock);
+    Locker py_lock(this,
+                   Locker::AcquireLock | Locker::NoSTDIN,
+                   Locker::FreeLock);
     
     static char callee_name[] = "create_thread";
     std::string param_format;
@@ -1599,7 +1609,7 @@ ScriptInterpreterPython::GetDynamicSetti
     PyObject *reply_pyobj = nullptr;
     
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         TargetSP target_sp(target->shared_from_this());
         reply_pyobj = (PyObject*)g_swig_plugin_get(plugin_module_sp->GetObject(),setting_name,target_sp);
     }
@@ -1633,7 +1643,7 @@ ScriptInterpreterPython::CreateSynthetic
     void* ret_val;
 
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_synthetic_script (class_name,
                                            python_interpreter->m_dictionary_name.c_str(),
                                            valobj);
@@ -1724,14 +1734,14 @@ ScriptInterpreterPython::GetScriptedSumm
         && *python_function_name)
     {
         {
-            Locker py_lock(this);
+            Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
             {
-            Timer scoped_timer ("g_swig_typescript_callback","g_swig_typescript_callback");
-            ret_val = g_swig_typescript_callback (python_function_name,
-                                                  GetSessionDictionary().get(),
-                                                  valobj,
-                                                  &new_callee,
-                                                  retval);
+                Timer scoped_timer ("g_swig_typescript_callback","g_swig_typescript_callback");
+                ret_val = g_swig_typescript_callback (python_function_name,
+                                                      GetSessionDictionary().get(),
+                                                      valobj,
+                                                      &new_callee,
+                                                      retval);
             }
         }
     }
@@ -1788,8 +1798,8 @@ ScriptInterpreterPython::BreakpointCallb
             {
                 bool ret_val = true;
                 {
-                    Locker py_lock(python_interpreter);
-                    ret_val = g_swig_breakpoint_callback (python_function_name, 
+                    Locker py_lock(python_interpreter, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+                    ret_val = g_swig_breakpoint_callback (python_function_name,
                                                           python_interpreter->m_dictionary_name.c_str(),
                                                           stop_frame_sp, 
                                                           bp_loc_sp);
@@ -1840,8 +1850,8 @@ ScriptInterpreterPython::WatchpointCallb
             {
                 bool ret_val = true;
                 {
-                    Locker py_lock(python_interpreter);
-                    ret_val = g_swig_watchpoint_callback (python_function_name, 
+                    Locker py_lock(python_interpreter, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+                    ret_val = g_swig_watchpoint_callback (python_function_name,
                                                           python_interpreter->m_dictionary_name.c_str(),
                                                           stop_frame_sp, 
                                                           wp_sp);
@@ -1872,7 +1882,7 @@ ScriptInterpreterPython::CalculateNumChi
     uint32_t ret_val = 0;
     
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_calc_children (implementor);
     }
     
@@ -1896,7 +1906,7 @@ ScriptInterpreterPython::GetChildAtIndex
     lldb::ValueObjectSP ret_val;
     
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         void* child_ptr = g_swig_get_child_index (implementor,idx);
         if (child_ptr != NULL && child_ptr != Py_None)
         {
@@ -1932,7 +1942,7 @@ ScriptInterpreterPython::GetIndexOfChild
     int ret_val = UINT32_MAX;
     
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_get_index_child (implementor, child_name);
     }
     
@@ -1956,7 +1966,7 @@ ScriptInterpreterPython::UpdateSynthProv
         return ret_val;
     
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_update_provider (implementor);
     }
     
@@ -1980,7 +1990,7 @@ ScriptInterpreterPython::MightHaveChildr
         return ret_val;
     
     {
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_mighthavechildren_provider (implementor);
     }
     
@@ -2068,7 +2078,7 @@ ScriptInterpreterPython::RunScriptFormat
     }
     {
         ProcessSP process_sp(process->shared_from_this());
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_run_script_keyword_process (impl_function, m_dictionary_name.c_str(), process_sp, output);
         if (!ret_val)
             error.SetErrorString("python script evaluation failed");
@@ -2100,7 +2110,7 @@ ScriptInterpreterPython::RunScriptFormat
     }
     {
         ThreadSP thread_sp(thread->shared_from_this());
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_run_script_keyword_thread (impl_function, m_dictionary_name.c_str(), thread_sp, output);
         if (!ret_val)
             error.SetErrorString("python script evaluation failed");
@@ -2132,7 +2142,7 @@ ScriptInterpreterPython::RunScriptFormat
     }
     {
         TargetSP target_sp(target->shared_from_this());
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_run_script_keyword_target (impl_function, m_dictionary_name.c_str(), target_sp, output);
         if (!ret_val)
             error.SetErrorString("python script evaluation failed");
@@ -2164,7 +2174,7 @@ ScriptInterpreterPython::RunScriptFormat
     }
     {
         StackFrameSP frame_sp(frame->shared_from_this());
-        Locker py_lock(this);
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
         ret_val = g_swig_run_script_keyword_frame (impl_function, m_dictionary_name.c_str(), frame_sp, output);
         if (!ret_val)
             error.SetErrorString("python script evaluation failed");
@@ -2214,7 +2224,7 @@ ScriptInterpreterPython::LoadScriptingMo
 
         // Before executing Pyton code, lock the GIL.
         Locker py_lock (this,
-                        Locker::AcquireLock      | (init_session ? Locker::InitSession     : 0),
+                        Locker::AcquireLock      | (init_session ? Locker::InitSession     : 0) | Locker::NoSTDIN,
                         Locker::FreeAcquiredLock | (init_session ? Locker::TearDownSession : 0));
         
         if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
@@ -2455,8 +2465,8 @@ std::unique_ptr<ScriptInterpreterLocker>
 ScriptInterpreterPython::AcquireInterpreterLock ()
 {
     std::unique_ptr<ScriptInterpreterLocker> py_lock(new Locker(this,
-                                                              Locker::AcquireLock | Locker::InitSession,
-                                                              Locker::FreeLock | Locker::TearDownSession));
+                                                                Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN,
+                                                                Locker::FreeLock | Locker::TearDownSession));
     return py_lock;
 }
 

Modified: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp Thu Feb 13 17:34:38 2014
@@ -190,6 +190,13 @@ OperatingSystemPython::UpdateThreadList
     
     auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure threads_list stays alive
     PythonList threads_list(m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp));
+    
+    const uint32_t num_cores = core_thread_list.GetSize(false);
+    
+    // Make a map so we can keep track of which cores were used from the
+    // core_thread list. Any real threads/cores that weren't used should
+    // later be put back into the "new_thread_list".
+    std::vector<bool> core_used_map(num_cores, false);
     if (threads_list)
     {
         if (log)
@@ -207,18 +214,26 @@ OperatingSystemPython::UpdateThreadList
                 PythonDictionary thread_dict(threads_list.GetItemAtIndex(i));
                 if (thread_dict)
                 {
-                    ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_dict, core_thread_list, old_thread_list, NULL));
+                    ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_dict, core_thread_list, old_thread_list, core_used_map, NULL));
                     if (thread_sp)
                         new_thread_list.AddThread(thread_sp);
                 }
             }
         }
     }
-    
-    // No new threads added from the thread info array gotten from python, just
-    // display the core threads.
-    if (new_thread_list.GetSize(false) == 0)
-        new_thread_list = core_thread_list;
+
+    // Any real core threads that didn't end up backing a memory thread should
+    // still be in the main thread list, and they should be inserted at the beginning
+    // of the list
+    uint32_t insert_idx = 0;
+    for (uint32_t core_idx = 0; core_idx < num_cores; ++core_idx)
+    {
+        if (core_used_map[core_idx] == false)
+        {
+            new_thread_list.InsertThread (core_thread_list.GetThreadAtIndex(core_idx, false), insert_idx);
+            ++insert_idx;
+        }
+    }
 
     return new_thread_list.GetSize(false) > 0;
 }
@@ -227,6 +242,7 @@ ThreadSP
 OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict,
                                                    ThreadList &core_thread_list,
                                                    ThreadList &old_thread_list,
+                                                   std::vector<bool> &core_used_map,
                                                    bool *did_create_ptr)
 {
     ThreadSP thread_sp;
@@ -282,6 +298,10 @@ OperatingSystemPython::CreateThreadFromT
                 ThreadSP core_thread_sp (core_thread_list.GetThreadAtIndex(core_number, false));
                 if (core_thread_sp)
                 {
+                    // Keep track of which cores were set as the backing thread for memory threads...
+                    if (core_number < core_used_map.size())
+                        core_used_map[core_number] = true;
+
                     ThreadSP backing_core_thread_sp (core_thread_sp->GetBackingThread());
                     if (backing_core_thread_sp)
                     {
@@ -398,12 +418,13 @@ OperatingSystemPython::CreateThread (lld
         
         auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure thread_info_dict stays alive
         PythonDictionary thread_info_dict (m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context));
+        std::vector<bool> core_used_map;
         if (thread_info_dict)
         {
             ThreadList core_threads(m_process);
             ThreadList &thread_list = m_process->GetThreadList();
             bool did_create = false;
-            ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_info_dict, core_threads, thread_list, &did_create));
+            ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_info_dict, core_threads, thread_list, core_used_map, &did_create));
             if (did_create)
                 thread_list.AddThread(thread_sp);
             return thread_sp;

Modified: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h Thu Feb 13 17:34:38 2014
@@ -93,6 +93,7 @@ protected:
     CreateThreadFromThreadInfo (lldb_private::PythonDictionary &thread_dict,
                                 lldb_private::ThreadList &core_thread_list,
                                 lldb_private::ThreadList &old_thread_list,
+                                std::vector<bool> &core_used_map,
                                 bool *did_create_ptr);
 
     DynamicRegisterInfo *

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=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Feb 13 17:34:38 2014
@@ -1170,7 +1170,11 @@ ProcessGDBRemote::DoResume ()
         bool continue_packet_error = false;
         if (m_gdb_comm.HasAnyVContSupport ())
         {
-            if (m_continue_c_tids.size() == num_threads)
+            if (m_continue_c_tids.size() == num_threads ||
+                (m_continue_c_tids.empty() &&
+                 m_continue_C_tids.empty() &&
+                 m_continue_s_tids.empty() &&
+                 m_continue_S_tids.empty()))
             {
                 // All threads are continuing, just send a "c" packet
                 continue_packet.PutCString ("c");

Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Thu Feb 13 17:34:38 2014
@@ -85,6 +85,17 @@ ThreadList::AddThread (const ThreadSP &t
     m_threads.push_back(thread_sp);
 }
 
+void
+ThreadList::InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx)
+{
+    Mutex::Locker locker(GetMutex());
+    if (idx < m_threads.size())
+        m_threads.insert(m_threads.begin() + idx, thread_sp);
+    else
+        m_threads.push_back (thread_sp);
+}
+
+
 uint32_t
 ThreadList::GetSize (bool can_update)
 {

Modified: lldb/trunk/source/lldb-log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=201372&r1=201371&r2=201372&view=diff
==============================================================================
--- lldb/trunk/source/lldb-log.cpp (original)
+++ lldb/trunk/source/lldb-log.cpp Thu Feb 13 17:34:38 2014
@@ -156,7 +156,10 @@ lldb_private::DisableLog (const char **c
         }
         log->GetMask().Reset (flag_bits);
         if (flag_bits == 0)
+        {
+            log->SetStream(lldb::StreamSP());
             g_log_enabled = false;
+        }
     }
 
     return;





More information about the lldb-commits mailing list