156d9a1b3SGreg Clayton //===-- OperatingSystem.cpp --------------------------------------------*- C++ -*-===//
256d9a1b3SGreg Clayton //
356d9a1b3SGreg Clayton //                     The LLVM Compiler Infrastructure
456d9a1b3SGreg Clayton //
556d9a1b3SGreg Clayton // This file is distributed under the University of Illinois Open Source
656d9a1b3SGreg Clayton // License. See LICENSE.TXT for details.
756d9a1b3SGreg Clayton //
856d9a1b3SGreg Clayton //===----------------------------------------------------------------------===//
956d9a1b3SGreg Clayton 
1056d9a1b3SGreg Clayton 
1156d9a1b3SGreg Clayton #include "lldb/Target/OperatingSystem.h"
1256d9a1b3SGreg Clayton // C Includes
1356d9a1b3SGreg Clayton // C++ Includes
1456d9a1b3SGreg Clayton // Other libraries and framework includes
1556d9a1b3SGreg Clayton #include "lldb/Core/PluginManager.h"
16160c9d81SGreg Clayton #include "lldb/Target/Thread.h"
1756d9a1b3SGreg Clayton 
1856d9a1b3SGreg Clayton using namespace lldb;
1956d9a1b3SGreg Clayton using namespace lldb_private;
2056d9a1b3SGreg Clayton 
2156d9a1b3SGreg Clayton 
2256d9a1b3SGreg Clayton OperatingSystem*
2356d9a1b3SGreg Clayton OperatingSystem::FindPlugin (Process *process, const char *plugin_name)
2456d9a1b3SGreg Clayton {
2556d9a1b3SGreg Clayton     OperatingSystemCreateInstance create_callback = NULL;
2656d9a1b3SGreg Clayton     if (plugin_name)
2756d9a1b3SGreg Clayton     {
28*57abc5d6SGreg Clayton         ConstString const_plugin_name(plugin_name);
29*57abc5d6SGreg Clayton         create_callback  = PluginManager::GetOperatingSystemCreateCallbackForPluginName (const_plugin_name);
3056d9a1b3SGreg Clayton         if (create_callback)
3156d9a1b3SGreg Clayton         {
327b0992d9SGreg Clayton             std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, true));
3356d9a1b3SGreg Clayton             if (instance_ap.get())
3456d9a1b3SGreg Clayton                 return instance_ap.release();
3556d9a1b3SGreg Clayton         }
3656d9a1b3SGreg Clayton     }
3756d9a1b3SGreg Clayton     else
3856d9a1b3SGreg Clayton     {
3956d9a1b3SGreg Clayton         for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != NULL; ++idx)
4056d9a1b3SGreg Clayton         {
417b0992d9SGreg Clayton             std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, false));
4256d9a1b3SGreg Clayton             if (instance_ap.get())
4356d9a1b3SGreg Clayton                 return instance_ap.release();
4456d9a1b3SGreg Clayton         }
4556d9a1b3SGreg Clayton     }
4656d9a1b3SGreg Clayton     return NULL;
4756d9a1b3SGreg Clayton }
4856d9a1b3SGreg Clayton 
4956d9a1b3SGreg Clayton 
5056d9a1b3SGreg Clayton OperatingSystem::OperatingSystem (Process *process) :
5156d9a1b3SGreg Clayton     m_process (process)
5256d9a1b3SGreg Clayton {
5356d9a1b3SGreg Clayton }
5456d9a1b3SGreg Clayton 
5556d9a1b3SGreg Clayton OperatingSystem::~OperatingSystem()
5656d9a1b3SGreg Clayton {
5756d9a1b3SGreg Clayton }
58160c9d81SGreg Clayton 
59160c9d81SGreg Clayton 
60160c9d81SGreg Clayton bool
61160c9d81SGreg Clayton OperatingSystem::IsOperatingSystemPluginThread (const lldb::ThreadSP &thread_sp)
62160c9d81SGreg Clayton {
63160c9d81SGreg Clayton     if (thread_sp)
64160c9d81SGreg Clayton         return thread_sp->IsOperatingSystemPluginThread();
65160c9d81SGreg Clayton     return false;
66160c9d81SGreg Clayton }
67160c9d81SGreg Clayton 
68