1*dda28197Spatrick //===-- OperatingSystemPython.cpp -----------------------------------------===// 2061da546Spatrick // 3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information. 5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6061da546Spatrick // 7061da546Spatrick //===----------------------------------------------------------------------===// 8061da546Spatrick 9061da546Spatrick #include "lldb/Host/Config.h" 10061da546Spatrick 11061da546Spatrick #if LLDB_ENABLE_PYTHON 12061da546Spatrick 13061da546Spatrick #include "OperatingSystemPython.h" 14061da546Spatrick 15061da546Spatrick #include "Plugins/Process/Utility/DynamicRegisterInfo.h" 16061da546Spatrick #include "Plugins/Process/Utility/RegisterContextDummy.h" 17061da546Spatrick #include "Plugins/Process/Utility/RegisterContextMemory.h" 18061da546Spatrick #include "Plugins/Process/Utility/ThreadMemory.h" 19061da546Spatrick #include "lldb/Core/Debugger.h" 20061da546Spatrick #include "lldb/Core/Module.h" 21061da546Spatrick #include "lldb/Core/PluginManager.h" 22061da546Spatrick #include "lldb/Core/ValueObjectVariable.h" 23061da546Spatrick #include "lldb/Interpreter/CommandInterpreter.h" 24061da546Spatrick #include "lldb/Interpreter/ScriptInterpreter.h" 25061da546Spatrick #include "lldb/Symbol/ObjectFile.h" 26061da546Spatrick #include "lldb/Symbol/VariableList.h" 27061da546Spatrick #include "lldb/Target/Process.h" 28061da546Spatrick #include "lldb/Target/StopInfo.h" 29061da546Spatrick #include "lldb/Target/Target.h" 30061da546Spatrick #include "lldb/Target/Thread.h" 31061da546Spatrick #include "lldb/Target/ThreadList.h" 32061da546Spatrick #include "lldb/Utility/DataBufferHeap.h" 33061da546Spatrick #include "lldb/Utility/RegisterValue.h" 34061da546Spatrick #include "lldb/Utility/StreamString.h" 35061da546Spatrick #include "lldb/Utility/StructuredData.h" 36061da546Spatrick 37061da546Spatrick #include <memory> 38061da546Spatrick 39061da546Spatrick using namespace lldb; 40061da546Spatrick using namespace lldb_private; 41061da546Spatrick 42*dda28197Spatrick LLDB_PLUGIN_DEFINE(OperatingSystemPython) 43*dda28197Spatrick 44061da546Spatrick void OperatingSystemPython::Initialize() { 45061da546Spatrick PluginManager::RegisterPlugin(GetPluginNameStatic(), 46061da546Spatrick GetPluginDescriptionStatic(), CreateInstance, 47061da546Spatrick nullptr); 48061da546Spatrick } 49061da546Spatrick 50061da546Spatrick void OperatingSystemPython::Terminate() { 51061da546Spatrick PluginManager::UnregisterPlugin(CreateInstance); 52061da546Spatrick } 53061da546Spatrick 54061da546Spatrick OperatingSystem *OperatingSystemPython::CreateInstance(Process *process, 55061da546Spatrick bool force) { 56061da546Spatrick // Python OperatingSystem plug-ins must be requested by name, so force must 57061da546Spatrick // be true 58061da546Spatrick FileSpec python_os_plugin_spec(process->GetPythonOSPluginPath()); 59061da546Spatrick if (python_os_plugin_spec && 60061da546Spatrick FileSystem::Instance().Exists(python_os_plugin_spec)) { 61061da546Spatrick std::unique_ptr<OperatingSystemPython> os_up( 62061da546Spatrick new OperatingSystemPython(process, python_os_plugin_spec)); 63061da546Spatrick if (os_up.get() && os_up->IsValid()) 64061da546Spatrick return os_up.release(); 65061da546Spatrick } 66061da546Spatrick return nullptr; 67061da546Spatrick } 68061da546Spatrick 69061da546Spatrick ConstString OperatingSystemPython::GetPluginNameStatic() { 70061da546Spatrick static ConstString g_name("python"); 71061da546Spatrick return g_name; 72061da546Spatrick } 73061da546Spatrick 74061da546Spatrick const char *OperatingSystemPython::GetPluginDescriptionStatic() { 75061da546Spatrick return "Operating system plug-in that gathers OS information from a python " 76061da546Spatrick "class that implements the necessary OperatingSystem functionality."; 77061da546Spatrick } 78061da546Spatrick 79061da546Spatrick OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process, 80061da546Spatrick const FileSpec &python_module_path) 81061da546Spatrick : OperatingSystem(process), m_thread_list_valobj_sp(), m_register_info_up(), 82061da546Spatrick m_interpreter(nullptr), m_python_object_sp() { 83061da546Spatrick if (!process) 84061da546Spatrick return; 85061da546Spatrick TargetSP target_sp = process->CalculateTarget(); 86061da546Spatrick if (!target_sp) 87061da546Spatrick return; 88061da546Spatrick m_interpreter = target_sp->GetDebugger().GetScriptInterpreter(); 89061da546Spatrick if (m_interpreter) { 90061da546Spatrick 91061da546Spatrick std::string os_plugin_class_name( 92061da546Spatrick python_module_path.GetFilename().AsCString("")); 93061da546Spatrick if (!os_plugin_class_name.empty()) { 94061da546Spatrick const bool init_session = false; 95061da546Spatrick char python_module_path_cstr[PATH_MAX]; 96061da546Spatrick python_module_path.GetPath(python_module_path_cstr, 97061da546Spatrick sizeof(python_module_path_cstr)); 98061da546Spatrick Status error; 99061da546Spatrick if (m_interpreter->LoadScriptingModule(python_module_path_cstr, 100061da546Spatrick init_session, error)) { 101061da546Spatrick // Strip the ".py" extension if there is one 102061da546Spatrick size_t py_extension_pos = os_plugin_class_name.rfind(".py"); 103061da546Spatrick if (py_extension_pos != std::string::npos) 104061da546Spatrick os_plugin_class_name.erase(py_extension_pos); 105061da546Spatrick // Add ".OperatingSystemPlugIn" to the module name to get a string like 106061da546Spatrick // "modulename.OperatingSystemPlugIn" 107061da546Spatrick os_plugin_class_name += ".OperatingSystemPlugIn"; 108061da546Spatrick StructuredData::ObjectSP object_sp = 109061da546Spatrick m_interpreter->OSPlugin_CreatePluginObject( 110061da546Spatrick os_plugin_class_name.c_str(), process->CalculateProcess()); 111061da546Spatrick if (object_sp && object_sp->IsValid()) 112061da546Spatrick m_python_object_sp = object_sp; 113061da546Spatrick } 114061da546Spatrick } 115061da546Spatrick } 116061da546Spatrick } 117061da546Spatrick 118061da546Spatrick OperatingSystemPython::~OperatingSystemPython() {} 119061da546Spatrick 120061da546Spatrick DynamicRegisterInfo *OperatingSystemPython::GetDynamicRegisterInfo() { 121061da546Spatrick if (m_register_info_up == nullptr) { 122061da546Spatrick if (!m_interpreter || !m_python_object_sp) 123061da546Spatrick return nullptr; 124061da546Spatrick Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS)); 125061da546Spatrick 126061da546Spatrick LLDB_LOGF(log, 127061da546Spatrick "OperatingSystemPython::GetDynamicRegisterInfo() fetching " 128061da546Spatrick "thread register definitions from python for pid %" PRIu64, 129061da546Spatrick m_process->GetID()); 130061da546Spatrick 131061da546Spatrick StructuredData::DictionarySP dictionary = 132061da546Spatrick m_interpreter->OSPlugin_RegisterInfo(m_python_object_sp); 133061da546Spatrick if (!dictionary) 134061da546Spatrick return nullptr; 135061da546Spatrick 136061da546Spatrick m_register_info_up.reset(new DynamicRegisterInfo( 137061da546Spatrick *dictionary, m_process->GetTarget().GetArchitecture())); 138061da546Spatrick assert(m_register_info_up->GetNumRegisters() > 0); 139061da546Spatrick assert(m_register_info_up->GetNumRegisterSets() > 0); 140061da546Spatrick } 141061da546Spatrick return m_register_info_up.get(); 142061da546Spatrick } 143061da546Spatrick 144061da546Spatrick // PluginInterface protocol 145061da546Spatrick ConstString OperatingSystemPython::GetPluginName() { 146061da546Spatrick return GetPluginNameStatic(); 147061da546Spatrick } 148061da546Spatrick 149061da546Spatrick uint32_t OperatingSystemPython::GetPluginVersion() { return 1; } 150061da546Spatrick 151061da546Spatrick bool OperatingSystemPython::UpdateThreadList(ThreadList &old_thread_list, 152061da546Spatrick ThreadList &core_thread_list, 153061da546Spatrick ThreadList &new_thread_list) { 154061da546Spatrick if (!m_interpreter || !m_python_object_sp) 155061da546Spatrick return false; 156061da546Spatrick 157061da546Spatrick Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS)); 158061da546Spatrick 159061da546Spatrick // First thing we have to do is to try to get the API lock, and the 160061da546Spatrick // interpreter lock. We're going to change the thread content of the process, 161061da546Spatrick // and we're going to use python, which requires the API lock to do it. We 162061da546Spatrick // need the interpreter lock to make sure thread_info_dict stays alive. 163061da546Spatrick // 164061da546Spatrick // If someone already has the API lock, that is ok, we just want to avoid 165061da546Spatrick // external code from making new API calls while this call is happening. 166061da546Spatrick // 167061da546Spatrick // This is a recursive lock so we can grant it to any Python code called on 168061da546Spatrick // the stack below us. 169061da546Spatrick Target &target = m_process->GetTarget(); 170061da546Spatrick std::unique_lock<std::recursive_mutex> api_lock(target.GetAPIMutex(), 171061da546Spatrick std::defer_lock); 172061da546Spatrick (void)api_lock.try_lock(); // See above. 173061da546Spatrick auto interpreter_lock = m_interpreter->AcquireInterpreterLock(); 174061da546Spatrick 175061da546Spatrick LLDB_LOGF(log, 176061da546Spatrick "OperatingSystemPython::UpdateThreadList() fetching thread " 177061da546Spatrick "data from python for pid %" PRIu64, 178061da546Spatrick m_process->GetID()); 179061da546Spatrick 180061da546Spatrick // The threads that are in "core_thread_list" upon entry are the threads from 181061da546Spatrick // the lldb_private::Process subclass, no memory threads will be in this 182061da546Spatrick // list. 183061da546Spatrick StructuredData::ArraySP threads_list = 184061da546Spatrick m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp); 185061da546Spatrick 186061da546Spatrick const uint32_t num_cores = core_thread_list.GetSize(false); 187061da546Spatrick 188061da546Spatrick // Make a map so we can keep track of which cores were used from the 189061da546Spatrick // core_thread list. Any real threads/cores that weren't used should later be 190061da546Spatrick // put back into the "new_thread_list". 191061da546Spatrick std::vector<bool> core_used_map(num_cores, false); 192061da546Spatrick if (threads_list) { 193061da546Spatrick if (log) { 194061da546Spatrick StreamString strm; 195061da546Spatrick threads_list->Dump(strm); 196061da546Spatrick LLDB_LOGF(log, "threads_list = %s", strm.GetData()); 197061da546Spatrick } 198061da546Spatrick 199061da546Spatrick const uint32_t num_threads = threads_list->GetSize(); 200061da546Spatrick for (uint32_t i = 0; i < num_threads; ++i) { 201061da546Spatrick StructuredData::ObjectSP thread_dict_obj = 202061da546Spatrick threads_list->GetItemAtIndex(i); 203061da546Spatrick if (auto thread_dict = thread_dict_obj->GetAsDictionary()) { 204061da546Spatrick ThreadSP thread_sp(CreateThreadFromThreadInfo( 205061da546Spatrick *thread_dict, core_thread_list, old_thread_list, core_used_map, 206061da546Spatrick nullptr)); 207061da546Spatrick if (thread_sp) 208061da546Spatrick new_thread_list.AddThread(thread_sp); 209061da546Spatrick } 210061da546Spatrick } 211061da546Spatrick } 212061da546Spatrick 213061da546Spatrick // Any real core threads that didn't end up backing a memory thread should 214061da546Spatrick // still be in the main thread list, and they should be inserted at the 215061da546Spatrick // beginning of the list 216061da546Spatrick uint32_t insert_idx = 0; 217061da546Spatrick for (uint32_t core_idx = 0; core_idx < num_cores; ++core_idx) { 218061da546Spatrick if (!core_used_map[core_idx]) { 219061da546Spatrick new_thread_list.InsertThread( 220061da546Spatrick core_thread_list.GetThreadAtIndex(core_idx, false), insert_idx); 221061da546Spatrick ++insert_idx; 222061da546Spatrick } 223061da546Spatrick } 224061da546Spatrick 225061da546Spatrick return new_thread_list.GetSize(false) > 0; 226061da546Spatrick } 227061da546Spatrick 228061da546Spatrick ThreadSP OperatingSystemPython::CreateThreadFromThreadInfo( 229061da546Spatrick StructuredData::Dictionary &thread_dict, ThreadList &core_thread_list, 230061da546Spatrick ThreadList &old_thread_list, std::vector<bool> &core_used_map, 231061da546Spatrick bool *did_create_ptr) { 232061da546Spatrick ThreadSP thread_sp; 233061da546Spatrick tid_t tid = LLDB_INVALID_THREAD_ID; 234061da546Spatrick if (!thread_dict.GetValueForKeyAsInteger("tid", tid)) 235061da546Spatrick return ThreadSP(); 236061da546Spatrick 237061da546Spatrick uint32_t core_number; 238061da546Spatrick addr_t reg_data_addr; 239061da546Spatrick llvm::StringRef name; 240061da546Spatrick llvm::StringRef queue; 241061da546Spatrick 242061da546Spatrick thread_dict.GetValueForKeyAsInteger("core", core_number, UINT32_MAX); 243061da546Spatrick thread_dict.GetValueForKeyAsInteger("register_data_addr", reg_data_addr, 244061da546Spatrick LLDB_INVALID_ADDRESS); 245061da546Spatrick thread_dict.GetValueForKeyAsString("name", name); 246061da546Spatrick thread_dict.GetValueForKeyAsString("queue", queue); 247061da546Spatrick 248061da546Spatrick // See if a thread already exists for "tid" 249061da546Spatrick thread_sp = old_thread_list.FindThreadByID(tid, false); 250061da546Spatrick if (thread_sp) { 251061da546Spatrick // A thread already does exist for "tid", make sure it was an operating 252061da546Spatrick // system 253061da546Spatrick // plug-in generated thread. 254061da546Spatrick if (!IsOperatingSystemPluginThread(thread_sp)) { 255061da546Spatrick // We have thread ID overlap between the protocol threads and the 256061da546Spatrick // operating system threads, clear the thread so we create an operating 257061da546Spatrick // system thread for this. 258061da546Spatrick thread_sp.reset(); 259061da546Spatrick } 260061da546Spatrick } 261061da546Spatrick 262061da546Spatrick if (!thread_sp) { 263061da546Spatrick if (did_create_ptr) 264061da546Spatrick *did_create_ptr = true; 265061da546Spatrick thread_sp = std::make_shared<ThreadMemory>(*m_process, tid, name, queue, 266061da546Spatrick reg_data_addr); 267061da546Spatrick } 268061da546Spatrick 269061da546Spatrick if (core_number < core_thread_list.GetSize(false)) { 270061da546Spatrick ThreadSP core_thread_sp( 271061da546Spatrick core_thread_list.GetThreadAtIndex(core_number, false)); 272061da546Spatrick if (core_thread_sp) { 273061da546Spatrick // Keep track of which cores were set as the backing thread for memory 274061da546Spatrick // threads... 275061da546Spatrick if (core_number < core_used_map.size()) 276061da546Spatrick core_used_map[core_number] = true; 277061da546Spatrick 278061da546Spatrick ThreadSP backing_core_thread_sp(core_thread_sp->GetBackingThread()); 279061da546Spatrick if (backing_core_thread_sp) { 280061da546Spatrick thread_sp->SetBackingThread(backing_core_thread_sp); 281061da546Spatrick } else { 282061da546Spatrick thread_sp->SetBackingThread(core_thread_sp); 283061da546Spatrick } 284061da546Spatrick } 285061da546Spatrick } 286061da546Spatrick return thread_sp; 287061da546Spatrick } 288061da546Spatrick 289061da546Spatrick void OperatingSystemPython::ThreadWasSelected(Thread *thread) {} 290061da546Spatrick 291061da546Spatrick RegisterContextSP 292061da546Spatrick OperatingSystemPython::CreateRegisterContextForThread(Thread *thread, 293061da546Spatrick addr_t reg_data_addr) { 294061da546Spatrick RegisterContextSP reg_ctx_sp; 295061da546Spatrick if (!m_interpreter || !m_python_object_sp || !thread) 296061da546Spatrick return reg_ctx_sp; 297061da546Spatrick 298061da546Spatrick if (!IsOperatingSystemPluginThread(thread->shared_from_this())) 299061da546Spatrick return reg_ctx_sp; 300061da546Spatrick 301061da546Spatrick // First thing we have to do is to try to get the API lock, and the 302061da546Spatrick // interpreter lock. We're going to change the thread content of the process, 303061da546Spatrick // and we're going to use python, which requires the API lock to do it. We 304061da546Spatrick // need the interpreter lock to make sure thread_info_dict stays alive. 305061da546Spatrick // 306061da546Spatrick // If someone already has the API lock, that is ok, we just want to avoid 307061da546Spatrick // external code from making new API calls while this call is happening. 308061da546Spatrick // 309061da546Spatrick // This is a recursive lock so we can grant it to any Python code called on 310061da546Spatrick // the stack below us. 311061da546Spatrick Target &target = m_process->GetTarget(); 312061da546Spatrick std::unique_lock<std::recursive_mutex> api_lock(target.GetAPIMutex(), 313061da546Spatrick std::defer_lock); 314061da546Spatrick (void)api_lock.try_lock(); // See above. 315061da546Spatrick auto interpreter_lock = m_interpreter->AcquireInterpreterLock(); 316061da546Spatrick 317061da546Spatrick Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); 318061da546Spatrick 319061da546Spatrick if (reg_data_addr != LLDB_INVALID_ADDRESS) { 320061da546Spatrick // The registers data is in contiguous memory, just create the register 321061da546Spatrick // context using the address provided 322061da546Spatrick LLDB_LOGF(log, 323061da546Spatrick "OperatingSystemPython::CreateRegisterContextForThread (tid " 324061da546Spatrick "= 0x%" PRIx64 ", 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64 325061da546Spatrick ") creating memory register context", 326061da546Spatrick thread->GetID(), thread->GetProtocolID(), reg_data_addr); 327061da546Spatrick reg_ctx_sp = std::make_shared<RegisterContextMemory>( 328061da546Spatrick *thread, 0, *GetDynamicRegisterInfo(), reg_data_addr); 329061da546Spatrick } else { 330061da546Spatrick // No register data address is provided, query the python plug-in to let it 331061da546Spatrick // make up the data as it sees fit 332061da546Spatrick LLDB_LOGF(log, 333061da546Spatrick "OperatingSystemPython::CreateRegisterContextForThread (tid " 334061da546Spatrick "= 0x%" PRIx64 ", 0x%" PRIx64 335061da546Spatrick ") fetching register data from python", 336061da546Spatrick thread->GetID(), thread->GetProtocolID()); 337061da546Spatrick 338061da546Spatrick StructuredData::StringSP reg_context_data = 339061da546Spatrick m_interpreter->OSPlugin_RegisterContextData(m_python_object_sp, 340061da546Spatrick thread->GetID()); 341061da546Spatrick if (reg_context_data) { 342*dda28197Spatrick std::string value = std::string(reg_context_data->GetValue()); 343061da546Spatrick DataBufferSP data_sp(new DataBufferHeap(value.c_str(), value.length())); 344061da546Spatrick if (data_sp->GetByteSize()) { 345061da546Spatrick RegisterContextMemory *reg_ctx_memory = new RegisterContextMemory( 346061da546Spatrick *thread, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS); 347061da546Spatrick if (reg_ctx_memory) { 348061da546Spatrick reg_ctx_sp.reset(reg_ctx_memory); 349061da546Spatrick reg_ctx_memory->SetAllRegisterData(data_sp); 350061da546Spatrick } 351061da546Spatrick } 352061da546Spatrick } 353061da546Spatrick } 354061da546Spatrick // if we still have no register data, fallback on a dummy context to avoid 355061da546Spatrick // crashing 356061da546Spatrick if (!reg_ctx_sp) { 357061da546Spatrick LLDB_LOGF(log, 358061da546Spatrick "OperatingSystemPython::CreateRegisterContextForThread (tid " 359061da546Spatrick "= 0x%" PRIx64 ") forcing a dummy register context", 360061da546Spatrick thread->GetID()); 361061da546Spatrick reg_ctx_sp = std::make_shared<RegisterContextDummy>( 362061da546Spatrick *thread, 0, target.GetArchitecture().GetAddressByteSize()); 363061da546Spatrick } 364061da546Spatrick return reg_ctx_sp; 365061da546Spatrick } 366061da546Spatrick 367061da546Spatrick StopInfoSP 368061da546Spatrick OperatingSystemPython::CreateThreadStopReason(lldb_private::Thread *thread) { 369061da546Spatrick // We should have gotten the thread stop info from the dictionary of data for 370061da546Spatrick // the thread in the initial call to get_thread_info(), this should have been 371061da546Spatrick // cached so we can return it here 372061da546Spatrick StopInfoSP 373061da546Spatrick stop_info_sp; //(StopInfo::CreateStopReasonWithSignal (*thread, SIGSTOP)); 374061da546Spatrick return stop_info_sp; 375061da546Spatrick } 376061da546Spatrick 377061da546Spatrick lldb::ThreadSP OperatingSystemPython::CreateThread(lldb::tid_t tid, 378061da546Spatrick addr_t context) { 379061da546Spatrick Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); 380061da546Spatrick 381061da546Spatrick LLDB_LOGF(log, 382061da546Spatrick "OperatingSystemPython::CreateThread (tid = 0x%" PRIx64 383061da546Spatrick ", context = 0x%" PRIx64 ") fetching register data from python", 384061da546Spatrick tid, context); 385061da546Spatrick 386061da546Spatrick if (m_interpreter && m_python_object_sp) { 387061da546Spatrick // First thing we have to do is to try to get the API lock, and the 388061da546Spatrick // interpreter lock. We're going to change the thread content of the 389061da546Spatrick // process, and we're going to use python, which requires the API lock to 390061da546Spatrick // do it. We need the interpreter lock to make sure thread_info_dict stays 391061da546Spatrick // alive. 392061da546Spatrick // 393061da546Spatrick // If someone already has the API lock, that is ok, we just want to avoid 394061da546Spatrick // external code from making new API calls while this call is happening. 395061da546Spatrick // 396061da546Spatrick // This is a recursive lock so we can grant it to any Python code called on 397061da546Spatrick // the stack below us. 398061da546Spatrick Target &target = m_process->GetTarget(); 399061da546Spatrick std::unique_lock<std::recursive_mutex> api_lock(target.GetAPIMutex(), 400061da546Spatrick std::defer_lock); 401061da546Spatrick (void)api_lock.try_lock(); // See above. 402061da546Spatrick auto interpreter_lock = m_interpreter->AcquireInterpreterLock(); 403061da546Spatrick 404061da546Spatrick StructuredData::DictionarySP thread_info_dict = 405061da546Spatrick m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context); 406061da546Spatrick std::vector<bool> core_used_map; 407061da546Spatrick if (thread_info_dict) { 408061da546Spatrick ThreadList core_threads(m_process); 409061da546Spatrick ThreadList &thread_list = m_process->GetThreadList(); 410061da546Spatrick bool did_create = false; 411061da546Spatrick ThreadSP thread_sp( 412061da546Spatrick CreateThreadFromThreadInfo(*thread_info_dict, core_threads, 413061da546Spatrick thread_list, core_used_map, &did_create)); 414061da546Spatrick if (did_create) 415061da546Spatrick thread_list.AddThread(thread_sp); 416061da546Spatrick return thread_sp; 417061da546Spatrick } 418061da546Spatrick } 419061da546Spatrick return ThreadSP(); 420061da546Spatrick } 421061da546Spatrick 422061da546Spatrick #endif // #if LLDB_ENABLE_PYTHON 423