1*80814287SRaphael Isemann //===-- OperatingSystem.cpp -----------------------------------------------===// 256d9a1b3SGreg Clayton // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 656d9a1b3SGreg Clayton // 756d9a1b3SGreg Clayton //===----------------------------------------------------------------------===// 856d9a1b3SGreg Clayton 99394d772SEugene Zelenko #include "lldb/Target/OperatingSystem.h" 1056d9a1b3SGreg Clayton #include "lldb/Core/PluginManager.h" 11160c9d81SGreg Clayton #include "lldb/Target/Thread.h" 1256d9a1b3SGreg Clayton 1356d9a1b3SGreg Clayton using namespace lldb; 1456d9a1b3SGreg Clayton using namespace lldb_private; 1556d9a1b3SGreg Clayton 16b9c1b51eSKate Stone OperatingSystem *OperatingSystem::FindPlugin(Process *process, 17b9c1b51eSKate Stone const char *plugin_name) { 189394d772SEugene Zelenko OperatingSystemCreateInstance create_callback = nullptr; 19b9c1b51eSKate Stone if (plugin_name) { 2057abc5d6SGreg Clayton ConstString const_plugin_name(plugin_name); 21b9c1b51eSKate Stone create_callback = 22b9c1b51eSKate Stone PluginManager::GetOperatingSystemCreateCallbackForPluginName( 23b9c1b51eSKate Stone const_plugin_name); 24b9c1b51eSKate Stone if (create_callback) { 25d5b44036SJonas Devlieghere std::unique_ptr<OperatingSystem> instance_up( 26b9c1b51eSKate Stone create_callback(process, true)); 27d5b44036SJonas Devlieghere if (instance_up) 28d5b44036SJonas Devlieghere return instance_up.release(); 2956d9a1b3SGreg Clayton } 30b9c1b51eSKate Stone } else { 31b9c1b51eSKate Stone for (uint32_t idx = 0; 32b9c1b51eSKate Stone (create_callback = 33b9c1b51eSKate Stone PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != 34b9c1b51eSKate Stone nullptr; 35b9c1b51eSKate Stone ++idx) { 36d5b44036SJonas Devlieghere std::unique_ptr<OperatingSystem> instance_up( 37b9c1b51eSKate Stone create_callback(process, false)); 38d5b44036SJonas Devlieghere if (instance_up) 39d5b44036SJonas Devlieghere return instance_up.release(); 4056d9a1b3SGreg Clayton } 4156d9a1b3SGreg Clayton } 429394d772SEugene Zelenko return nullptr; 4356d9a1b3SGreg Clayton } 4456d9a1b3SGreg Clayton 45b9c1b51eSKate Stone OperatingSystem::OperatingSystem(Process *process) : m_process(process) {} 4656d9a1b3SGreg Clayton 479394d772SEugene Zelenko OperatingSystem::~OperatingSystem() = default; 48160c9d81SGreg Clayton 49b9c1b51eSKate Stone bool OperatingSystem::IsOperatingSystemPluginThread( 50b9c1b51eSKate Stone const lldb::ThreadSP &thread_sp) { 51160c9d81SGreg Clayton if (thread_sp) 52160c9d81SGreg Clayton return thread_sp->IsOperatingSystemPluginThread(); 53160c9d81SGreg Clayton return false; 54160c9d81SGreg Clayton } 55