Eugene Zelenko | 9394d772 | 2016-02-18 00:10:17 +0000 | [diff] [blame] | 1 | //===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===// |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 10 | // C Includes |
| 11 | // C++ Includes |
| 12 | // Other libraries and framework includes |
Eugene Zelenko | 9394d772 | 2016-02-18 00:10:17 +0000 | [diff] [blame] | 13 | // Project includes |
| 14 | #include "lldb/Target/OperatingSystem.h" |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 15 | #include "lldb/Core/PluginManager.h" |
Greg Clayton | 160c9d8 | 2013-05-01 21:54:04 +0000 | [diff] [blame] | 16 | #include "lldb/Target/Thread.h" |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace lldb; |
| 19 | using namespace lldb_private; |
| 20 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 21 | OperatingSystem *OperatingSystem::FindPlugin(Process *process, |
| 22 | const char *plugin_name) { |
| 23 | OperatingSystemCreateInstance create_callback = nullptr; |
| 24 | if (plugin_name) { |
| 25 | ConstString const_plugin_name(plugin_name); |
| 26 | create_callback = |
| 27 | PluginManager::GetOperatingSystemCreateCallbackForPluginName( |
| 28 | const_plugin_name); |
| 29 | if (create_callback) { |
| 30 | std::unique_ptr<OperatingSystem> instance_ap( |
| 31 | create_callback(process, true)); |
| 32 | if (instance_ap) |
| 33 | return instance_ap.release(); |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 34 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 35 | } else { |
| 36 | for (uint32_t idx = 0; |
| 37 | (create_callback = |
| 38 | PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != |
| 39 | nullptr; |
| 40 | ++idx) { |
| 41 | std::unique_ptr<OperatingSystem> instance_ap( |
| 42 | create_callback(process, false)); |
| 43 | if (instance_ap) |
| 44 | return instance_ap.release(); |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 45 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 46 | } |
| 47 | return nullptr; |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 50 | OperatingSystem::OperatingSystem(Process *process) : m_process(process) {} |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 51 | |
Eugene Zelenko | 9394d772 | 2016-02-18 00:10:17 +0000 | [diff] [blame] | 52 | OperatingSystem::~OperatingSystem() = default; |
Greg Clayton | 160c9d8 | 2013-05-01 21:54:04 +0000 | [diff] [blame] | 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 54 | bool OperatingSystem::IsOperatingSystemPluginThread( |
| 55 | const lldb::ThreadSP &thread_sp) { |
| 56 | if (thread_sp) |
| 57 | return thread_sp->IsOperatingSystemPluginThread(); |
| 58 | return false; |
Greg Clayton | 160c9d8 | 2013-05-01 21:54:04 +0000 | [diff] [blame] | 59 | } |