1 //===-- OperatingSystem.cpp -----------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "lldb/Target/OperatingSystem.h" 10 #include "lldb/Core/PluginManager.h" 11 #include "lldb/Target/Thread.h" 12 13 using namespace lldb; 14 using namespace lldb_private; 15 FindPlugin(Process * process,const char * plugin_name)16OperatingSystem *OperatingSystem::FindPlugin(Process *process, 17 const char *plugin_name) { 18 OperatingSystemCreateInstance create_callback = nullptr; 19 if (plugin_name) { 20 ConstString const_plugin_name(plugin_name); 21 create_callback = 22 PluginManager::GetOperatingSystemCreateCallbackForPluginName( 23 const_plugin_name); 24 if (create_callback) { 25 std::unique_ptr<OperatingSystem> instance_up( 26 create_callback(process, true)); 27 if (instance_up) 28 return instance_up.release(); 29 } 30 } else { 31 for (uint32_t idx = 0; 32 (create_callback = 33 PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != 34 nullptr; 35 ++idx) { 36 std::unique_ptr<OperatingSystem> instance_up( 37 create_callback(process, false)); 38 if (instance_up) 39 return instance_up.release(); 40 } 41 } 42 return nullptr; 43 } 44 OperatingSystem(Process * process)45OperatingSystem::OperatingSystem(Process *process) : m_process(process) {} 46 IsOperatingSystemPluginThread(const lldb::ThreadSP & thread_sp)47bool OperatingSystem::IsOperatingSystemPluginThread( 48 const lldb::ThreadSP &thread_sp) { 49 if (thread_sp) 50 return thread_sp->IsOperatingSystemPluginThread(); 51 return false; 52 } 53