2016-02-18 08:10:17 +08:00
|
|
|
//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===//
|
2011-08-22 10:49:39 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-08-22 10:49:39 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-02-18 08:10:17 +08:00
|
|
|
#include "lldb/Target/OperatingSystem.h"
|
2011-08-22 10:49:39 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2013-05-02 05:54:04 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
2011-08-22 10:49:39 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
OperatingSystem *OperatingSystem::FindPlugin(Process *process,
|
|
|
|
const char *plugin_name) {
|
2016-02-18 08:10:17 +08:00
|
|
|
OperatingSystemCreateInstance create_callback = nullptr;
|
2011-08-22 10:49:39 +08:00
|
|
|
if (plugin_name) {
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString const_plugin_name(plugin_name);
|
|
|
|
create_callback =
|
|
|
|
PluginManager::GetOperatingSystemCreateCallbackForPluginName(
|
|
|
|
const_plugin_name);
|
2011-08-22 10:49:39 +08:00
|
|
|
if (create_callback) {
|
2019-02-13 14:25:41 +08:00
|
|
|
std::unique_ptr<OperatingSystem> instance_up(
|
2013-04-19 06:45:39 +08:00
|
|
|
create_callback(process, true));
|
2019-02-13 14:25:41 +08:00
|
|
|
if (instance_up)
|
|
|
|
return instance_up.release();
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
|
|
|
} else {
|
2016-02-18 08:10:17 +08:00
|
|
|
for (uint32_t idx = 0;
|
|
|
|
(create_callback =
|
|
|
|
PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=
|
|
|
|
nullptr;
|
|
|
|
++idx) {
|
2019-02-13 14:25:41 +08:00
|
|
|
std::unique_ptr<OperatingSystem> instance_up(
|
2013-04-19 06:45:39 +08:00
|
|
|
create_callback(process, false));
|
2019-02-13 14:25:41 +08:00
|
|
|
if (instance_up)
|
|
|
|
return instance_up.release();
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-02-18 08:10:17 +08:00
|
|
|
return nullptr;
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OperatingSystem::OperatingSystem(Process *process) : m_process(process) {}
|
|
|
|
|
2016-02-18 08:10:17 +08:00
|
|
|
OperatingSystem::~OperatingSystem() = default;
|
2013-05-02 05:54:04 +08:00
|
|
|
|
|
|
|
bool OperatingSystem::IsOperatingSystemPluginThread(
|
|
|
|
const lldb::ThreadSP &thread_sp) {
|
|
|
|
if (thread_sp)
|
|
|
|
return thread_sp->IsOperatingSystemPluginThread();
|
|
|
|
return false;
|
|
|
|
}
|