1ac7ddfbfSEd Maste //===-- OperatingSystem.cpp --------------------------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste //                     The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste 
10ac7ddfbfSEd Maste 
11ac7ddfbfSEd Maste #include "lldb/Target/OperatingSystem.h"
12ac7ddfbfSEd Maste // C Includes
13ac7ddfbfSEd Maste // C++ Includes
14ac7ddfbfSEd Maste // Other libraries and framework includes
15ac7ddfbfSEd Maste #include "lldb/Core/PluginManager.h"
16ac7ddfbfSEd Maste #include "lldb/Target/Thread.h"
17ac7ddfbfSEd Maste 
18ac7ddfbfSEd Maste using namespace lldb;
19ac7ddfbfSEd Maste using namespace lldb_private;
20ac7ddfbfSEd Maste 
21ac7ddfbfSEd Maste 
22ac7ddfbfSEd Maste OperatingSystem*
23ac7ddfbfSEd Maste OperatingSystem::FindPlugin (Process *process, const char *plugin_name)
24ac7ddfbfSEd Maste {
25ac7ddfbfSEd Maste     OperatingSystemCreateInstance create_callback = NULL;
26ac7ddfbfSEd Maste     if (plugin_name)
27ac7ddfbfSEd Maste     {
28ac7ddfbfSEd Maste         ConstString const_plugin_name(plugin_name);
29ac7ddfbfSEd Maste         create_callback  = PluginManager::GetOperatingSystemCreateCallbackForPluginName (const_plugin_name);
30ac7ddfbfSEd Maste         if (create_callback)
31ac7ddfbfSEd Maste         {
32ac7ddfbfSEd Maste             std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, true));
33ac7ddfbfSEd Maste             if (instance_ap.get())
34ac7ddfbfSEd Maste                 return instance_ap.release();
35ac7ddfbfSEd Maste         }
36ac7ddfbfSEd Maste     }
37ac7ddfbfSEd Maste     else
38ac7ddfbfSEd Maste     {
39ac7ddfbfSEd Maste         for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != NULL; ++idx)
40ac7ddfbfSEd Maste         {
41ac7ddfbfSEd Maste             std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, false));
42ac7ddfbfSEd Maste             if (instance_ap.get())
43ac7ddfbfSEd Maste                 return instance_ap.release();
44ac7ddfbfSEd Maste         }
45ac7ddfbfSEd Maste     }
46ac7ddfbfSEd Maste     return NULL;
47ac7ddfbfSEd Maste }
48ac7ddfbfSEd Maste 
49ac7ddfbfSEd Maste 
50ac7ddfbfSEd Maste OperatingSystem::OperatingSystem (Process *process) :
51ac7ddfbfSEd Maste     m_process (process)
52ac7ddfbfSEd Maste {
53ac7ddfbfSEd Maste }
54ac7ddfbfSEd Maste 
55ac7ddfbfSEd Maste OperatingSystem::~OperatingSystem()
56ac7ddfbfSEd Maste {
57ac7ddfbfSEd Maste }
58ac7ddfbfSEd Maste 
59ac7ddfbfSEd Maste 
60ac7ddfbfSEd Maste bool
61ac7ddfbfSEd Maste OperatingSystem::IsOperatingSystemPluginThread (const lldb::ThreadSP &thread_sp)
62ac7ddfbfSEd Maste {
63ac7ddfbfSEd Maste     if (thread_sp)
64ac7ddfbfSEd Maste         return thread_sp->IsOperatingSystemPluginThread();
65ac7ddfbfSEd Maste     return false;
66ac7ddfbfSEd Maste }
67ac7ddfbfSEd Maste 
68