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