2016-02-18 08:10:17 +08:00
|
|
|
//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===//
|
2011-08-22 10:49:39 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
2016-02-18 08:10:17 +08:00
|
|
|
// Project includes
|
|
|
|
#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)
|
|
|
|
{
|
2013-04-19 06:45:39 +08:00
|
|
|
std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, true));
|
2016-02-18 08:10:17 +08:00
|
|
|
if (instance_ap)
|
2011-08-22 10:49:39 +08:00
|
|
|
return instance_ap.release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-18 08:10:17 +08:00
|
|
|
for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
2011-08-22 10:49:39 +08:00
|
|
|
{
|
2013-04-19 06:45:39 +08:00
|
|
|
std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, false));
|
2016-02-18 08:10:17 +08:00
|
|
|
if (instance_ap)
|
2011-08-22 10:49:39 +08:00
|
|
|
return instance_ap.release();
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|