summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/PluginManager.cpp
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2013-11-05 03:57:19 +0000
committerJason Molenda <jmolenda@apple.com>2013-11-05 03:57:19 +0000
commiteef510667b18263f59da78f7614ecf6bc07802a7 (patch)
treea110d7f9472f59a127cbb71a3019311661243e03 /lldb/source/Core/PluginManager.cpp
parentd6b40b51c7e520cb08e86cad64e56d92a645ffc6 (diff)
downloadbcm5719-llvm-eef510667b18263f59da78f7614ecf6bc07802a7.tar.gz
bcm5719-llvm-eef510667b18263f59da78f7614ecf6bc07802a7.zip
Add a new system runtime plugin type - just the top level
class, not any actual plugin implementation yet. <rdar://problem/15314068> llvm-svn: 194044
Diffstat (limited to 'lldb/source/Core/PluginManager.cpp')
-rw-r--r--lldb/source/Core/PluginManager.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 7a2d3772e6c..813cec22752 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -854,6 +854,111 @@ PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString
return NULL;
}
+#pragma mark SystemRuntime
+
+
+struct SystemRuntimeInstance
+{
+ SystemRuntimeInstance() :
+ name(),
+ description(),
+ create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ std::string description;
+ SystemRuntimeCreateInstance create_callback;
+};
+
+typedef std::vector<SystemRuntimeInstance> SystemRuntimeInstances;
+
+static Mutex &
+GetSystemRuntimeMutex ()
+{
+ static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static SystemRuntimeInstances &
+GetSystemRuntimeInstances ()
+{
+ static SystemRuntimeInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin
+(
+ const ConstString &name,
+ const char *description,
+ SystemRuntimeCreateInstance create_callback
+)
+{
+ if (create_callback)
+ {
+ SystemRuntimeInstance instance;
+ assert ((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ Mutex::Locker locker (GetSystemRuntimeMutex ());
+ GetSystemRuntimeInstances ().push_back (instance);
+ }
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin (SystemRuntimeCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ Mutex::Locker locker (GetSystemRuntimeMutex ());
+ SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
+
+ SystemRuntimeInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->create_callback == create_callback)
+ {
+ instances.erase(pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+SystemRuntimeCreateInstance
+PluginManager::GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetSystemRuntimeMutex ());
+ SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return NULL;
+}
+
+SystemRuntimeCreateInstance
+PluginManager::GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetSystemRuntimeMutex ());
+ SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
+
+ SystemRuntimeInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->create_callback;
+ }
+ }
+ return NULL;
+}
+
+
#pragma mark ObjectFile
struct ObjectFileInstance
OpenPOWER on IntegriCloud