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"
16*160c9d81SGreg 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     {
2856d9a1b3SGreg Clayton         create_callback  = PluginManager::GetOperatingSystemCreateCallbackForPluginName (plugin_name);
2956d9a1b3SGreg Clayton         if (create_callback)
3056d9a1b3SGreg Clayton         {
317b0992d9SGreg Clayton             std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, true));
3256d9a1b3SGreg Clayton             if (instance_ap.get())
3356d9a1b3SGreg Clayton                 return instance_ap.release();
3456d9a1b3SGreg Clayton         }
3556d9a1b3SGreg Clayton     }
3656d9a1b3SGreg Clayton     else
3756d9a1b3SGreg Clayton     {
3856d9a1b3SGreg Clayton         for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != NULL; ++idx)
3956d9a1b3SGreg Clayton         {
407b0992d9SGreg Clayton             std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, false));
4156d9a1b3SGreg Clayton             if (instance_ap.get())
4256d9a1b3SGreg Clayton                 return instance_ap.release();
4356d9a1b3SGreg Clayton         }
4456d9a1b3SGreg Clayton     }
4556d9a1b3SGreg Clayton     return NULL;
4656d9a1b3SGreg Clayton }
4756d9a1b3SGreg Clayton 
4856d9a1b3SGreg Clayton 
4956d9a1b3SGreg Clayton OperatingSystem::OperatingSystem (Process *process) :
5056d9a1b3SGreg Clayton     m_process (process)
5156d9a1b3SGreg Clayton {
5256d9a1b3SGreg Clayton }
5356d9a1b3SGreg Clayton 
5456d9a1b3SGreg Clayton OperatingSystem::~OperatingSystem()
5556d9a1b3SGreg Clayton {
5656d9a1b3SGreg Clayton }
57*160c9d81SGreg Clayton 
58*160c9d81SGreg Clayton 
59*160c9d81SGreg Clayton bool
60*160c9d81SGreg Clayton OperatingSystem::IsOperatingSystemPluginThread (const lldb::ThreadSP &thread_sp)
61*160c9d81SGreg Clayton {
62*160c9d81SGreg Clayton     if (thread_sp)
63*160c9d81SGreg Clayton         return thread_sp->IsOperatingSystemPluginThread();
64*160c9d81SGreg Clayton     return false;
65*160c9d81SGreg Clayton }
66*160c9d81SGreg Clayton 
67