1*9394d772SEugene Zelenko //===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===// 256d9a1b3SGreg Clayton // 356d9a1b3SGreg Clayton // The LLVM Compiler Infrastructure 456d9a1b3SGreg Clayton // 556d9a1b3SGreg Clayton // This file is distributed under the University of Illinois Open Source 656d9a1b3SGreg Clayton // License. See LICENSE.TXT for details. 756d9a1b3SGreg Clayton // 856d9a1b3SGreg Clayton //===----------------------------------------------------------------------===// 956d9a1b3SGreg Clayton 1056d9a1b3SGreg Clayton // C Includes 1156d9a1b3SGreg Clayton // C++ Includes 1256d9a1b3SGreg Clayton // Other libraries and framework includes 13*9394d772SEugene Zelenko // Project includes 14*9394d772SEugene Zelenko #include "lldb/Target/OperatingSystem.h" 1556d9a1b3SGreg Clayton #include "lldb/Core/PluginManager.h" 16160c9d81SGreg Clayton #include "lldb/Target/Thread.h" 1756d9a1b3SGreg Clayton 1856d9a1b3SGreg Clayton using namespace lldb; 1956d9a1b3SGreg Clayton using namespace lldb_private; 2056d9a1b3SGreg Clayton 2156d9a1b3SGreg Clayton OperatingSystem* 2256d9a1b3SGreg Clayton OperatingSystem::FindPlugin (Process *process, const char *plugin_name) 2356d9a1b3SGreg Clayton { 24*9394d772SEugene Zelenko OperatingSystemCreateInstance create_callback = nullptr; 2556d9a1b3SGreg Clayton if (plugin_name) 2656d9a1b3SGreg Clayton { 2757abc5d6SGreg Clayton ConstString const_plugin_name(plugin_name); 2857abc5d6SGreg Clayton create_callback = PluginManager::GetOperatingSystemCreateCallbackForPluginName (const_plugin_name); 2956d9a1b3SGreg Clayton if (create_callback) 3056d9a1b3SGreg Clayton { 317b0992d9SGreg Clayton std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, true)); 32*9394d772SEugene Zelenko if (instance_ap) 3356d9a1b3SGreg Clayton return instance_ap.release(); 3456d9a1b3SGreg Clayton } 3556d9a1b3SGreg Clayton } 3656d9a1b3SGreg Clayton else 3756d9a1b3SGreg Clayton { 38*9394d772SEugene Zelenko for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != nullptr; ++idx) 3956d9a1b3SGreg Clayton { 407b0992d9SGreg Clayton std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, false)); 41*9394d772SEugene Zelenko if (instance_ap) 4256d9a1b3SGreg Clayton return instance_ap.release(); 4356d9a1b3SGreg Clayton } 4456d9a1b3SGreg Clayton } 45*9394d772SEugene Zelenko return nullptr; 4656d9a1b3SGreg Clayton } 4756d9a1b3SGreg Clayton 4856d9a1b3SGreg Clayton 4956d9a1b3SGreg Clayton OperatingSystem::OperatingSystem (Process *process) : 5056d9a1b3SGreg Clayton m_process (process) 5156d9a1b3SGreg Clayton { 5256d9a1b3SGreg Clayton } 5356d9a1b3SGreg Clayton 54*9394d772SEugene Zelenko OperatingSystem::~OperatingSystem() = default; 55160c9d81SGreg Clayton 56160c9d81SGreg Clayton bool 57160c9d81SGreg Clayton OperatingSystem::IsOperatingSystemPluginThread (const lldb::ThreadSP &thread_sp) 58160c9d81SGreg Clayton { 59160c9d81SGreg Clayton if (thread_sp) 60160c9d81SGreg Clayton return thread_sp->IsOperatingSystemPluginThread(); 61160c9d81SGreg Clayton return false; 62160c9d81SGreg Clayton } 63