summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-10-19 18:02:49 +0000
committerGreg Clayton <gclayton@apple.com>2012-10-19 18:02:49 +0000
commite8cd0c9859bfae9b173e89f566b6f4d6b010b19f (patch)
tree712804cb727d621b59a2f1c4e61e571f3ebb92fe /lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
parentdb97454f8ee2d47ef1f6000e812321ac1abc54d8 (diff)
downloadbcm5719-llvm-e8cd0c9859bfae9b173e89f566b6f4d6b010b19f.tar.gz
bcm5719-llvm-e8cd0c9859bfae9b173e89f566b6f4d6b010b19f.zip
Added the infrastructure necessary for plug-ins to be able to add their own settings instead of having settings added to existing ones. In particular "target.disable-kext-loading" was added to "target" where it should actually be specific to the the dynamic loader plugin. Now the plug-in manager has the ability to create settings at the root level starting with "plugin". Each plug-in type can add new sub dictionaries, and then each plug-in can register a setting dictionary under its own short name. For example the DynamicLoaderDarwinKernel plug-in now registers a setting dictionary at:
plugin dynamic-loader macosx-kernel (bool) disable-kext-loading To settings can be set using: (lldb) settings set plugin.dynamic-loader.macosx-kernel.disable-kext-loading true I currently only hooked up the DynamicLoader plug-ins, but the code is very easy to duplicate when and if we need settings for other plug-ins. llvm-svn: 166294
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp')
-rw-r--r--lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp71
1 files changed, 69 insertions, 2 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 667c9d7e13c..dfaed50b3e0 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -39,6 +39,60 @@
using namespace lldb;
using namespace lldb_private;
+static PropertyDefinition
+g_properties[] =
+{
+ { "disable-kext-loading" , OptionValue::eTypeBoolean, false, false, NULL, NULL, "Disable kext image loading in a Darwin kernel debug session." },
+ { NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
+};
+
+enum {
+ ePropertyDisableKextLoading
+};
+
+class DynamicLoaderDarwinKernelProperties : public Properties
+{
+public:
+
+ static ConstString &
+ GetSettingName ()
+ {
+ static ConstString g_setting_name("macosx-kernel");
+ return g_setting_name;
+ }
+
+ DynamicLoaderDarwinKernelProperties() :
+ Properties ()
+ {
+ m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ virtual
+ ~DynamicLoaderDarwinKernelProperties()
+ {
+ }
+
+ bool
+ GetDisableKextLoading() const
+ {
+ const uint32_t idx = ePropertyDisableKextLoading;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+ }
+
+};
+
+typedef STD_SHARED_PTR(DynamicLoaderDarwinKernelProperties) DynamicLoaderDarwinKernelPropertiesSP;
+
+static const DynamicLoaderDarwinKernelPropertiesSP &
+GetGlobalProperties()
+{
+ static DynamicLoaderDarwinKernelPropertiesSP g_settings_sp;
+ if (!g_settings_sp)
+ g_settings_sp.reset (new DynamicLoaderDarwinKernelProperties ());
+ return g_settings_sp;
+}
+
//----------------------------------------------------------------------
// Create an instance of this class. This function is filled into
// the plugin info class that gets handed out by the plugin factory and
@@ -190,7 +244,7 @@ DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::LoadImageUsingMemoryModule (
ModuleSP memory_module_sp;
// If this is a kext and the user asked us to ignore kexts, don't try to load it.
- if (kernel_image == false && target.GetDisableKextLoading() == true)
+ if (kernel_image == false && GetGlobalProperties()->GetDisableKextLoading() == true)
{
return false;
}
@@ -872,7 +926,8 @@ DynamicLoaderDarwinKernel::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
}
void
@@ -881,6 +936,18 @@ DynamicLoaderDarwinKernel::Terminate()
PluginManager::UnregisterPlugin (CreateInstance);
}
+void
+DynamicLoaderDarwinKernel::DebuggerInitialize (lldb_private::Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForDynamicLoaderPlugin (debugger, DynamicLoaderDarwinKernelProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForDynamicLoaderPlugin (debugger,
+ GetGlobalProperties()->GetValueProperties(),
+ ConstString ("Properties for the DynamicLoaderDarwinKernel plug-in."),
+ is_global_setting);
+ }
+}
const char *
DynamicLoaderDarwinKernel::GetPluginNameStatic()
OpenPOWER on IntegriCloud