LLDB  mainline
OperatingSystem.cpp
Go to the documentation of this file.
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
11 #include "lldb/Target/Thread.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 OperatingSystem *OperatingSystem::FindPlugin(Process *process,
17  const char *plugin_name) {
18  OperatingSystemCreateInstance create_callback = nullptr;
19  if (plugin_name) {
20  ConstString const_plugin_name(plugin_name);
21  create_callback =
22  PluginManager::GetOperatingSystemCreateCallbackForPluginName(
23  const_plugin_name);
24  if (create_callback) {
25  std::unique_ptr<OperatingSystem> instance_up(
26  create_callback(process, true));
27  if (instance_up)
28  return instance_up.release();
29  }
30  } else {
31  for (uint32_t idx = 0;
32  (create_callback =
33  PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=
34  nullptr;
35  ++idx) {
36  std::unique_ptr<OperatingSystem> instance_up(
37  create_callback(process, false));
38  if (instance_up)
39  return instance_up.release();
40  }
41  }
42  return nullptr;
43 }
44 
45 OperatingSystem::OperatingSystem(Process *process) : m_process(process) {}
46 
48  const lldb::ThreadSP &thread_sp) {
49  if (thread_sp)
50  return thread_sp->IsOperatingSystemPluginThread();
51  return false;
52 }
lldb_private::Process
Definition: Process.h:340
OperatingSystem.h
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::OperatingSystem
Definition: OperatingSystem.h:27
Thread.h
uint32_t
PluginManager.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb
Definition: SBAddress.h:15
lldb_private::OperatingSystem::IsOperatingSystemPluginThread
virtual bool IsOperatingSystemPluginThread(const lldb::ThreadSP &thread_sp)
Definition: OperatingSystem.cpp:47