summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp77
1 files changed, 72 insertions, 5 deletions
diff --git a/contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index 8e454e7..143e447 100644
--- a/contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/contrib/llvm/tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -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
//------------------------------------------------------------------
@@ -37,7 +90,6 @@ typedef enum
JIT_UNREGISTER_FN
} jit_actions_t;
-#pragma pack(push, 4)
template <typename ptr_t>
struct jit_code_entry
{
@@ -54,7 +106,6 @@ struct jit_descriptor
ptr_t relevant_entry; // pointer
ptr_t first_entry; // pointer
};
-#pragma pack(pop)
JITLoaderGDB::JITLoaderGDB (lldb_private::Process *process) :
JITLoader(process),
@@ -70,6 +121,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 +152,7 @@ void
JITLoaderGDB::ModulesDidLoad(ModuleList &module_list)
{
if (!DidSetJITBreakpoint() && m_process->IsAlive())
- SetJITBreakpoint(module_list);
+ SetJITBreakpoint(module_list);
}
//------------------------------------------------------------------
@@ -97,11 +161,13 @@ JITLoaderGDB::ModulesDidLoad(ModuleList &module_list)
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 +473,8 @@ JITLoaderGDB::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
- CreateInstance);
+ CreateInstance,
+ DebuggerInitialize);
}
void
OpenPOWER on IntegriCloud