[Lldb-commits] [lldb] r247821 - Add plugin.jit-loader.gdb.enable-jit-breakpoint property to make JIT loader breakpoint optional.
Oleksiy Vyalov via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 16 10:38:36 PDT 2015
Author: ovyalov
Date: Wed Sep 16 12:38:36 2015
New Revision: 247821
URL: http://llvm.org/viewvc/llvm-project?rev=247821&view=rev
Log:
Add plugin.jit-loader.gdb.enable-jit-breakpoint property to make JIT loader breakpoint optional.
http://reviews.llvm.org/D12890
Modified:
lldb/trunk/include/lldb/Core/PluginManager.h
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=247821&r1=247820&r2=247821&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Wed Sep 16 12:38:36 2015
@@ -470,6 +470,16 @@ public:
const lldb::OptionValuePropertiesSP &properties_sp,
const ConstString &description,
bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForJITLoaderPlugin (Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool
+ CreateSettingForJITLoaderPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property);
};
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=247821&r1=247820&r2=247821&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Wed Sep 16 12:38:36 2015
@@ -2661,32 +2661,40 @@ GetDebuggerPropertyForPluginsOldStyle (D
return lldb::OptionValuePropertiesSP();
}
+namespace {
+
+typedef lldb::OptionValuePropertiesSP
+GetDebuggerPropertyForPluginsPtr (Debugger&, const ConstString&, const ConstString&, bool can_create);
lldb::OptionValuePropertiesSP
-PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name)
+GetSettingForPlugin (Debugger &debugger,
+ const ConstString &setting_name,
+ const ConstString &plugin_type_name,
+ GetDebuggerPropertyForPluginsPtr get_debugger_property= GetDebuggerPropertyForPlugins)
{
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));
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (get_debugger_property (debugger,
+ plugin_type_name,
+ 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);
+ properties_sp = plugin_type_properties_sp->GetSubProperty (nullptr, setting_name);
return properties_sp;
}
bool
-PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property)
+CreateSettingForPlugin (Debugger &debugger,
+ const ConstString &plugin_type_name,
+ const ConstString &plugin_type_desc,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property,
+ GetDebuggerPropertyForPluginsPtr get_debugger_property = GetDebuggerPropertyForPlugins)
{
if (properties_sp)
{
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("dynamic-loader"),
- ConstString("Settings for dynamic loader plug-ins"),
- true));
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (get_debugger_property (
+ debugger, plugin_type_name, plugin_type_desc, true));
if (plugin_type_properties_sp)
{
plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
@@ -2699,56 +2707,65 @@ PluginManager::CreateSettingForDynamicLo
return false;
}
+const char* kDynamicLoaderPluginName("dynamic-loader");
+const char* kPlatformPluginName("platform");
+const char* kProcessPluginName("process");
+const char* kSymbolFilePluginName("symbol-file");
+const char* kJITLoaderPluginName("jit-loader");
+
+}
lldb::OptionValuePropertiesSP
-PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
+PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger,
+ const ConstString &setting_name)
{
- lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
- ConstString("platform"),
- 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;
+ return GetSettingForPlugin(debugger, setting_name, ConstString(kDynamicLoaderPluginName));
}
bool
-PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
+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 (GetDebuggerPropertyForPluginsOldStyle (debugger,
- ConstString("platform"),
- ConstString("Settings for platform 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;
+ return CreateSettingForPlugin(debugger,
+ ConstString(kDynamicLoaderPluginName),
+ ConstString("Settings for dynamic loader plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
+}
+
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
+{
+ return GetSettingForPlugin(debugger,
+ setting_name,
+ ConstString(kPlatformPluginName),
+ GetDebuggerPropertyForPluginsOldStyle);
+}
+
+bool
+PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property)
+{
+ return CreateSettingForPlugin(debugger,
+ ConstString(kPlatformPluginName),
+ ConstString("Settings for platform plug-ins"),
+ properties_sp,
+ description,
+ is_global_property,
+ GetDebuggerPropertyForPluginsOldStyle);
}
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name)
{
- lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("process"),
- 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;
+ return GetSettingForPlugin(debugger, setting_name, ConstString(kProcessPluginName));
}
bool
@@ -2757,39 +2774,19 @@ PluginManager::CreateSettingForProcessPl
const ConstString &description,
bool is_global_property)
{
- if (properties_sp)
- {
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString("process"),
- ConstString("Settings for process 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;
+ return CreateSettingForPlugin(debugger,
+ ConstString(kProcessPluginName),
+ ConstString("Settings for process plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
}
-
-static const char* kSymbolFilePluginName("symbol-file");
-
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForSymbolFilePlugin (Debugger &debugger,
const ConstString &setting_name)
{
- lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString(kSymbolFilePluginName),
- ConstString(), // not creating to so we don't need the description
- false));
- if (plugin_type_properties_sp)
- properties_sp = plugin_type_properties_sp->GetSubProperty (nullptr, setting_name);
- return properties_sp;
+ return GetSettingForPlugin(debugger, setting_name, ConstString(kSymbolFilePluginName));
}
bool
@@ -2798,20 +2795,31 @@ PluginManager::CreateSettingForSymbolFil
const ConstString &description,
bool is_global_property)
{
- if (properties_sp)
- {
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
- ConstString(kSymbolFilePluginName),
- ConstString("Settings for symbol file 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;
+ return CreateSettingForPlugin(debugger,
+ ConstString(kSymbolFilePluginName),
+ ConstString("Settings for symbol file plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
+}
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForJITLoaderPlugin (Debugger &debugger,
+ const ConstString &setting_name)
+{
+ return GetSettingForPlugin(debugger, setting_name, ConstString(kJITLoaderPluginName));
+}
+
+bool
+PluginManager::CreateSettingForJITLoaderPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property)
+{
+ return CreateSettingForPlugin(debugger,
+ ConstString(kJITLoaderPluginName),
+ ConstString("Settings for JIT loader plug-ins"),
+ properties_sp,
+ description,
+ is_global_property);
}
Modified: lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp?rev=247821&r1=247820&r2=247821&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp Wed Sep 16 12:38:36 2015
@@ -16,6 +16,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/Process.h"
@@ -27,6 +28,58 @@
using namespace lldb;
using namespace lldb_private;
+namespace {
+
+ PropertyDefinition
+ g_properties[] =
+ {
+ { "enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true , nullptr, nullptr, "Enable breakpoint on __jit_debug_register_code." },
+ { nullptr , OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr }
+ };
+
+ enum
+ {
+ ePropertyEnableJITBreakpoint
+ };
+
+
+ class PluginProperties : public Properties
+ {
+ public:
+ static ConstString
+ GetSettingName()
+ {
+ return JITLoaderGDB::GetPluginNameStatic();
+ }
+
+ PluginProperties()
+ {
+ m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ bool
+ GetEnableJITBreakpoint() const
+ {
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr,
+ ePropertyEnableJITBreakpoint,
+ g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
+ }
+
+ };
+
+ typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
+
+ static const JITLoaderGDBPropertiesSP&
+ GetGlobalPluginProperties()
+ {
+ static const auto g_settings_sp(std::make_shared<PluginProperties>());
+ return g_settings_sp;
+ }
+
+} // anonymous namespace end
+
//------------------------------------------------------------------
// Debug Interface Structures
//------------------------------------------------------------------
@@ -70,6 +123,19 @@ JITLoaderGDB::~JITLoaderGDB ()
m_process->GetTarget().RemoveBreakpointByID (m_jit_break_id);
}
+void
+JITLoaderGDB::DebuggerInitialize(Debugger &debugger)
+{
+ if (!PluginManager::GetSettingForJITLoaderPlugin(debugger, PluginProperties::GetSettingName()))
+ {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForJITLoaderPlugin(debugger,
+ GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString ("Properties for the JIT LoaderGDB plug-in."),
+ is_global_setting);
+ }
+}
+
void JITLoaderGDB::DidAttach()
{
Target &target = m_process->GetTarget();
@@ -88,7 +154,7 @@ void
JITLoaderGDB::ModulesDidLoad(ModuleList &module_list)
{
if (!DidSetJITBreakpoint() && m_process->IsAlive())
- SetJITBreakpoint(module_list);
+ SetJITBreakpoint(module_list);
}
//------------------------------------------------------------------
@@ -97,11 +163,13 @@ JITLoaderGDB::ModulesDidLoad(ModuleList
void
JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList &module_list)
{
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
+ if (!GetGlobalPluginProperties()->GetEnableJITBreakpoint())
+ return;
if ( DidSetJITBreakpoint() )
return;
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
if (log)
log->Printf("JITLoaderGDB::%s looking for JIT register hook",
__FUNCTION__);
@@ -407,7 +475,8 @@ JITLoaderGDB::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
}
void
Modified: lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h?rev=247821&r1=247820&r2=247821&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h Wed Sep 16 12:38:36 2015
@@ -42,6 +42,9 @@ public:
JITLoaderGDB (lldb_private::Process *process);
+ static void
+ DebuggerInitialize(lldb_private::Debugger &debugger);
+
virtual
~JITLoaderGDB ();
More information about the lldb-commits
mailing list