summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/PluginManager.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-03-08 22:40:15 +0000
committerGreg Clayton <gclayton@apple.com>2011-03-08 22:40:15 +0000
commite996fd30be59b65b0607607aa907af7178568994 (patch)
treebe26b775d619b8375f6c874826fc14ef493fe76d /lldb/source/Core/PluginManager.cpp
parent6111db9e9cde94262624891fd29d8225f4bc9de1 (diff)
downloadbcm5719-llvm-e996fd30be59b65b0607607aa907af7178568994.tar.gz
bcm5719-llvm-e996fd30be59b65b0607607aa907af7178568994.zip
LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS that supports LLDB should be registering a "default" platform that will be used unless a new platform is selected. Platforms are responsible for things such as: - getting process information by name or by processs ID - finding platform files. This is useful for remote debugging where there is an SDK with files that might already or need to be cached for debug access. - getting a list of platform supported architectures in the exact order they should be selected. This helps the native x86 platform on MacOSX select the correct x86_64/i386 slice from universal binaries. - Connect to remote platforms for remote debugging - Resolving an executable including finding an executable inside platform specific bundles (macosx uses .app bundles that contain files) and also selecting the appropriate slice of universal files for a given platform. So by default there is always a local platform, but remote platforms can be connected to. I will soon be adding a new "platform" command that will support the following commands: (lldb) platform connect --name machine1 macosx connect://host:port Connected to "machine1" platform. (lldb) platform disconnect macosx This allows LLDB to be well setup to do remote debugging and also once connected process listing and finding for things like: (lldb) process attach --name x<TAB> The currently selected platform plug-in can now auto complete any available processes that start with "x". The responsibilities for the platform plug-in will soon grow and expand. llvm-svn: 127286
Diffstat (limited to 'lldb/source/Core/PluginManager.cpp')
-rw-r--r--lldb/source/Core/PluginManager.cpp210
1 files changed, 173 insertions, 37 deletions
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 3c2907ed239..12bb4868652 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1194,17 +1194,153 @@ PluginManager::GetLogChannelCreateCallbackForPluginName (const char *name)
return NULL;
}
-#pragma mark Process
+#pragma mark Platform
-struct ProcessInstance
+struct PlatformInstance
{
- ProcessInstance() :
+ PlatformInstance() :
name(),
description(),
create_callback(NULL)
{
}
+
+ std::string name;
+ std::string description;
+ PlatformCreateInstance create_callback;
+};
+
+typedef std::vector<PlatformInstance> PlatformInstances;
+static bool
+AccessPlatformInstances (PluginAction action, PlatformInstance &instance, uint32_t index)
+{
+ static PlatformInstances g_plugin_instances;
+
+ switch (action)
+ {
+ case ePluginRegisterInstance:
+ if (instance.create_callback)
+ {
+ g_plugin_instances.push_back (instance);
+ return true;
+ }
+ break;
+
+ case ePluginUnregisterInstance:
+ if (instance.create_callback)
+ {
+ PlatformInstances::iterator pos, end = g_plugin_instances.end();
+ for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->create_callback == instance.create_callback)
+ {
+ g_plugin_instances.erase(pos);
+ return true;
+ }
+ }
+ }
+ break;
+
+ case ePluginGetInstanceAtIndex:
+ if (index < g_plugin_instances.size())
+ {
+ instance = g_plugin_instances[index];
+ return true;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return false;
+}
+
+
+bool
+PluginManager::RegisterPlugin (const char *name,
+ const char *description,
+ PlatformCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ PlatformInstance instance;
+ assert (name && name[0]);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ return AccessPlatformInstances (ePluginRegisterInstance, instance, 0);
+ }
+ return false;
+}
+
+const char *
+PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
+{
+ PlatformInstance instance;
+ if (AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx))
+ return instance.name.c_str();
+ return NULL;
+}
+
+const char *
+PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx)
+{
+ PlatformInstance instance;
+ if (AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx))
+ return instance.description.c_str();
+ return NULL;
+}
+
+bool
+PluginManager::UnregisterPlugin (PlatformCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ PlatformInstance instance;
+ instance.create_callback = create_callback;
+ return AccessPlatformInstances (ePluginUnregisterInstance, instance, 0);
+ }
+ return false;
+}
+
+PlatformCreateInstance
+PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx)
+{
+ PlatformInstance instance;
+ if (AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx))
+ return instance.create_callback;
+ return NULL;
+}
+
+PlatformCreateInstance
+PluginManager::GetPlatformCreateCallbackForPluginName (const char *name)
+{
+ if (name && name[0])
+ {
+ PlatformInstance instance;
+ std::string ss_name(name);
+ for (uint32_t idx = 0; AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+ {
+ if (instance.name == ss_name)
+ return instance.create_callback;
+ }
+ }
+ return NULL;
+}
+
+#pragma mark Process
+
+struct ProcessInstance
+{
+ ProcessInstance() :
+ name(),
+ description(),
+ create_callback(NULL)
+ {
+ }
+
std::string name;
std::string description;
ProcessCreateInstance create_callback;
@@ -1216,42 +1352,42 @@ static bool
AccessProcessInstances (PluginAction action, ProcessInstance &instance, uint32_t index)
{
static ProcessInstances g_plugin_instances;
-
+
switch (action)
{
- case ePluginRegisterInstance:
- if (instance.create_callback)
- {
- g_plugin_instances.push_back (instance);
- return true;
- }
- break;
-
- case ePluginUnregisterInstance:
- if (instance.create_callback)
- {
- ProcessInstances::iterator pos, end = g_plugin_instances.end();
- for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
+ case ePluginRegisterInstance:
+ if (instance.create_callback)
{
- if (pos->create_callback == instance.create_callback)
+ g_plugin_instances.push_back (instance);
+ return true;
+ }
+ break;
+
+ case ePluginUnregisterInstance:
+ if (instance.create_callback)
+ {
+ ProcessInstances::iterator pos, end = g_plugin_instances.end();
+ for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
{
- g_plugin_instances.erase(pos);
- return true;
+ if (pos->create_callback == instance.create_callback)
+ {
+ g_plugin_instances.erase(pos);
+ return true;
+ }
}
}
- }
- break;
-
- case ePluginGetInstanceAtIndex:
- if (index < g_plugin_instances.size())
- {
- instance = g_plugin_instances[index];
- return true;
- }
- break;
-
- default:
- break;
+ break;
+
+ case ePluginGetInstanceAtIndex:
+ if (index < g_plugin_instances.size())
+ {
+ instance = g_plugin_instances[index];
+ return true;
+ }
+ break;
+
+ default:
+ break;
}
return false;
}
@@ -1260,10 +1396,10 @@ AccessProcessInstances (PluginAction action, ProcessInstance &instance, uint32_t
bool
PluginManager::RegisterPlugin
(
- const char *name,
- const char *description,
- ProcessCreateInstance create_callback
-)
+ const char *name,
+ const char *description,
+ ProcessCreateInstance create_callback
+ )
{
if (create_callback)
{
OpenPOWER on IntegriCloud