diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Core/PluginManager.cpp | 99 | ||||
-rw-r--r-- | lldb/source/Core/UserSettingsController.cpp | 12 |
3 files changed, 114 insertions, 3 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 75253fd9f2a..673b077fc62 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -22,6 +22,7 @@ #include "lldb/Core/FormatManager.h" #include "lldb/Core/InputReader.h" #include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamAsynchronousIO.h" @@ -125,7 +126,8 @@ g_properties[] = { "term-width", OptionValue::eTypeSInt64 , true, 80 , NULL, NULL, "The maximum number of columns to use for displaying text." }, { "thread-format", OptionValue::eTypeString , true, 0 , DEFAULT_THREAD_FORMAT, NULL, "The default thread format string to use when displaying thread information." }, { "use-external-editor", OptionValue::eTypeBoolean, true, false, NULL, NULL, "Whether to use an external editor or not." }, -{ NULL, OptionValue::eTypeInvalid, true, 0 , NULL, NULL, NULL } + + { NULL, OptionValue::eTypeInvalid, true, 0 , NULL, NULL, NULL } }; enum @@ -438,6 +440,8 @@ Debugger::InstanceInitialize () this); } } + + PluginManager::DebuggerInitialize (*this); } DebuggerSP diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 63bde64b63b..94ab5b54b41 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -14,10 +14,12 @@ #include <string> #include <vector> +#include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/Mutex.h" +#include "lldb/Interpreter/OptionValueProperties.h" #include "llvm/ADT/StringRef.h" @@ -436,13 +438,15 @@ struct DynamicLoaderInstance DynamicLoaderInstance() : name(), description(), - create_callback(NULL) + create_callback(NULL), + debugger_init_callback (NULL) { } std::string name; std::string description; DynamicLoaderCreateInstance create_callback; + DebuggerInitializeCallback debugger_init_callback; }; typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances; @@ -468,7 +472,8 @@ PluginManager::RegisterPlugin ( const char *name, const char *description, - DynamicLoaderCreateInstance create_callback + DynamicLoaderCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback ) { if (create_callback) @@ -479,6 +484,7 @@ PluginManager::RegisterPlugin if (description && description[0]) instance.description = description; instance.create_callback = create_callback; + instance.debugger_init_callback = debugger_init_callback; Mutex::Locker locker (GetDynamicLoaderMutex ()); GetDynamicLoaderInstances ().push_back (instance); } @@ -1802,3 +1808,92 @@ PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name) return NULL; } +void +PluginManager::DebuggerInitialize (Debugger &debugger) +{ + Mutex::Locker locker (GetDynamicLoaderMutex ()); + DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); + + DynamicLoaderInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->debugger_init_callback) + pos->debugger_init_callback (debugger); + } +} + +static lldb::OptionValuePropertiesSP +GetDebuggerPropertyForPlugins (Debugger &debugger, + const ConstString &plugin_type_name, + const ConstString &plugin_type_desc, + bool can_create) +{ + lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties()); + if (parent_properties_sp) + { + static ConstString g_property_name("plugin"); + + OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, g_property_name); + if (!plugin_properties_sp && can_create) + { + plugin_properties_sp.reset (new OptionValueProperties (g_property_name)); + parent_properties_sp->AppendProperty (g_property_name, + ConstString("Settings specify to plugins."), + true, + plugin_properties_sp); + } + + if (plugin_properties_sp) + { + lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, plugin_type_name); + if (!plugin_type_properties_sp && can_create) + { + plugin_type_properties_sp.reset (new OptionValueProperties (plugin_type_name)); + plugin_properties_sp->AppendProperty (plugin_type_name, + plugin_type_desc, + true, + plugin_type_properties_sp); + } + return plugin_type_properties_sp; + } + } + return lldb::OptionValuePropertiesSP(); +} + +lldb::OptionValuePropertiesSP +PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name) +{ + lldb::OptionValuePropertiesSP properties_sp; + lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger, + ConstString("dynamic-loader"), + ConstString(), // not creating to so we don't need the description + false)); + if (plugin_type_properties_sp) + properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name); + return properties_sp; +} + +bool +PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, + bool is_global_property) +{ + if (properties_sp) + { + lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger, + ConstString("dynamic-loader"), + ConstString("Settings for dynamic loader plug-ins"), + true)); + if (plugin_type_properties_sp) + { + plugin_type_properties_sp->AppendProperty (properties_sp->GetName(), + description, + is_global_property, + properties_sp); + return true; + } + } + return false; +} + diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 68e1a625043..1b574539f0e 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -95,3 +95,15 @@ Properties::Apropos (const char *keyword, std::vector<const Property *> &matchin } return matching_properties.size(); } + + +lldb::OptionValuePropertiesSP +Properties::GetSubProperty (const ExecutionContext *exe_ctx, + const ConstString &name) +{ + OptionValuePropertiesSP properties_sp (GetValueProperties ()); + if (properties_sp) + return properties_sp->GetSubProperty (exe_ctx, name); + return lldb::OptionValuePropertiesSP(); +} + |