1 //===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Target/OperatingSystem.h" 11 #include "lldb/Core/PluginManager.h" 12 #include "lldb/Target/Thread.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 FindPlugin(Process * process,const char * plugin_name)17OperatingSystem *OperatingSystem::FindPlugin(Process *process, 18 const char *plugin_name) { 19 OperatingSystemCreateInstance create_callback = nullptr; 20 if (plugin_name) { 21 ConstString const_plugin_name(plugin_name); 22 create_callback = 23 PluginManager::GetOperatingSystemCreateCallbackForPluginName( 24 const_plugin_name); 25 if (create_callback) { 26 std::unique_ptr<OperatingSystem> instance_ap( 27 create_callback(process, true)); 28 if (instance_ap) 29 return instance_ap.release(); 30 } 31 } else { 32 for (uint32_t idx = 0; 33 (create_callback = 34 PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != 35 nullptr; 36 ++idx) { 37 std::unique_ptr<OperatingSystem> instance_ap( 38 create_callback(process, false)); 39 if (instance_ap) 40 return instance_ap.release(); 41 } 42 } 43 return nullptr; 44 } 45 OperatingSystem(Process * process)46OperatingSystem::OperatingSystem(Process *process) : m_process(process) {} 47 48 OperatingSystem::~OperatingSystem() = default; 49 IsOperatingSystemPluginThread(const lldb::ThreadSP & thread_sp)50bool OperatingSystem::IsOperatingSystemPluginThread( 51 const lldb::ThreadSP &thread_sp) { 52 if (thread_sp) 53 return thread_sp->IsOperatingSystemPluginThread(); 54 return false; 55 } 56