2016-02-18 00:10:17 +00:00
|
|
|
//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===//
|
2011-08-22 02:49:39 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00: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 02:49:39 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2016-02-18 00:10:17 +00:00
|
|
|
#include "lldb/Target/OperatingSystem.h"
|
2011-08-22 02:49:39 +00:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2013-05-01 21:54:04 +00:00
|
|
|
#include "lldb/Target/Thread.h"
|
2011-08-22 02:49:39 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
OperatingSystem *OperatingSystem::FindPlugin(Process *process,
|
|
|
|
|
const char *plugin_name) {
|
2016-02-18 00:10:17 +00:00
|
|
|
OperatingSystemCreateInstance create_callback = nullptr;
|
2011-08-22 02:49:39 +00:00
|
|
|
if (plugin_name) {
|
2013-05-10 21:47:16 +00:00
|
|
|
ConstString const_plugin_name(plugin_name);
|
|
|
|
|
create_callback =
|
|
|
|
|
PluginManager::GetOperatingSystemCreateCallbackForPluginName(
|
|
|
|
|
const_plugin_name);
|
2011-08-22 02:49:39 +00:00
|
|
|
if (create_callback) {
|
2019-02-13 06:25:41 +00:00
|
|
|
std::unique_ptr<OperatingSystem> instance_up(
|
2013-04-18 22:45:39 +00:00
|
|
|
create_callback(process, true));
|
2019-02-13 06:25:41 +00:00
|
|
|
if (instance_up)
|
|
|
|
|
return instance_up.release();
|
2011-08-22 02:49:39 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2016-02-18 00:10:17 +00:00
|
|
|
for (uint32_t idx = 0;
|
|
|
|
|
(create_callback =
|
|
|
|
|
PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=
|
|
|
|
|
nullptr;
|
|
|
|
|
++idx) {
|
2019-02-13 06:25:41 +00:00
|
|
|
std::unique_ptr<OperatingSystem> instance_up(
|
2013-04-18 22:45:39 +00:00
|
|
|
create_callback(process, false));
|
2019-02-13 06:25:41 +00:00
|
|
|
if (instance_up)
|
|
|
|
|
return instance_up.release();
|
2011-08-22 02:49:39 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2016-02-18 00:10:17 +00:00
|
|
|
return nullptr;
|
2011-08-22 02:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OperatingSystem::OperatingSystem(Process *process) : m_process(process) {}
|
|
|
|
|
|
2016-02-18 00:10:17 +00:00
|
|
|
OperatingSystem::~OperatingSystem() = default;
|
2013-05-01 21:54:04 +00:00
|
|
|
|
|
|
|
|
bool OperatingSystem::IsOperatingSystemPluginThread(
|
|
|
|
|
const lldb::ThreadSP &thread_sp) {
|
|
|
|
|
if (thread_sp)
|
|
|
|
|
return thread_sp->IsOperatingSystemPluginThread();
|
|
|
|
|
return false;
|
|
|
|
|
}
|