brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 75762c0 Raw
52 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Target/OperatingSystem.h"10#include "lldb/Core/PluginManager.h"11#include "lldb/Target/Thread.h"12 13using namespace lldb;14using namespace lldb_private;15 16OperatingSystem *OperatingSystem::FindPlugin(Process *process,17                                             const char *plugin_name) {18  OperatingSystemCreateInstance create_callback = nullptr;19  if (plugin_name) {20    create_callback =21        PluginManager::GetOperatingSystemCreateCallbackForPluginName(22            plugin_name);23    if (create_callback) {24      std::unique_ptr<OperatingSystem> instance_up(25          create_callback(process, true));26      if (instance_up)27        return instance_up.release();28    }29  } else {30    for (uint32_t idx = 0;31         (create_callback =32              PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=33         nullptr;34         ++idx) {35      std::unique_ptr<OperatingSystem> instance_up(36          create_callback(process, false));37      if (instance_up)38        return instance_up.release();39    }40  }41  return nullptr;42}43 44OperatingSystem::OperatingSystem(Process *process) : m_process(process) {}45 46bool OperatingSystem::IsOperatingSystemPluginThread(47    const lldb::ThreadSP &thread_sp) {48  if (thread_sp)49    return thread_sp->IsOperatingSystemPluginThread();50  return false;51}52