1309124Sdim//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===// 2254721Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6254721Semaste// 7254721Semaste//===----------------------------------------------------------------------===// 8254721Semaste 9309124Sdim#include "lldb/Target/OperatingSystem.h" 10254721Semaste#include "lldb/Core/PluginManager.h" 11254721Semaste#include "lldb/Target/Thread.h" 12254721Semaste 13254721Semasteusing namespace lldb; 14254721Semasteusing namespace lldb_private; 15254721Semaste 16314564SdimOperatingSystem *OperatingSystem::FindPlugin(Process *process, 17314564Sdim const char *plugin_name) { 18314564Sdim OperatingSystemCreateInstance create_callback = nullptr; 19314564Sdim if (plugin_name) { 20314564Sdim ConstString const_plugin_name(plugin_name); 21314564Sdim create_callback = 22314564Sdim PluginManager::GetOperatingSystemCreateCallbackForPluginName( 23314564Sdim const_plugin_name); 24314564Sdim if (create_callback) { 25353358Sdim std::unique_ptr<OperatingSystem> instance_up( 26314564Sdim create_callback(process, true)); 27353358Sdim if (instance_up) 28353358Sdim return instance_up.release(); 29254721Semaste } 30314564Sdim } else { 31314564Sdim for (uint32_t idx = 0; 32314564Sdim (create_callback = 33314564Sdim PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != 34314564Sdim nullptr; 35314564Sdim ++idx) { 36353358Sdim std::unique_ptr<OperatingSystem> instance_up( 37314564Sdim create_callback(process, false)); 38353358Sdim if (instance_up) 39353358Sdim return instance_up.release(); 40254721Semaste } 41314564Sdim } 42314564Sdim return nullptr; 43254721Semaste} 44254721Semaste 45314564SdimOperatingSystem::OperatingSystem(Process *process) : m_process(process) {} 46254721Semaste 47309124SdimOperatingSystem::~OperatingSystem() = default; 48254721Semaste 49314564Sdimbool OperatingSystem::IsOperatingSystemPluginThread( 50314564Sdim const lldb::ThreadSP &thread_sp) { 51314564Sdim if (thread_sp) 52314564Sdim return thread_sp->IsOperatingSystemPluginThread(); 53314564Sdim return false; 54254721Semaste} 55