diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
commit | e81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch) | |
tree | 9ed5e1a91f242e2cb5911577356e487a55c01b78 /source/Plugins/JITLoader | |
parent | 85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff) | |
download | src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.tar.gz src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.zip |
Vendor import of stripped lldb trunk r256633:
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=292932
Diffstat (limited to 'source/Plugins/JITLoader')
-rw-r--r-- | source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp | 77 | ||||
-rw-r--r-- | source/Plugins/JITLoader/GDB/JITLoaderGDB.h | 36 |
2 files changed, 91 insertions, 22 deletions
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index 8e454e712fe8..143e44794057 100644 --- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/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 diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h index bfa1721d3349..10bd989c328f 100644 --- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h +++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h @@ -13,15 +13,19 @@ // C Includes // C++ Includes #include <map> -#include <vector> -#include <string> +// Other libraries and framework includes +// Project includes #include "lldb/Target/JITLoader.h" #include "lldb/Target/Process.h" class JITLoaderGDB : public lldb_private::JITLoader { public: + JITLoaderGDB(lldb_private::Process *process); + + ~JITLoaderGDB() override; + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ @@ -40,31 +44,29 @@ public: static lldb::JITLoaderSP CreateInstance (lldb_private::Process *process, bool force); - JITLoaderGDB (lldb_private::Process *process); - - virtual - ~JITLoaderGDB (); + static void + DebuggerInitialize(lldb_private::Debugger &debugger); //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ - virtual lldb_private::ConstString - GetPluginName(); + lldb_private::ConstString + GetPluginName() override; - virtual uint32_t - GetPluginVersion(); + uint32_t + GetPluginVersion() override; //------------------------------------------------------------------ // JITLoader interface //------------------------------------------------------------------ - virtual void - DidAttach (); + void + DidAttach() override; - virtual void - DidLaunch (); + void + DidLaunch() override; - virtual void - ModulesDidLoad (lldb_private::ModuleList &module_list); + void + ModulesDidLoad(lldb_private::ModuleList &module_list) override; private: lldb::addr_t @@ -105,4 +107,4 @@ private: }; -#endif +#endif // liblldb_JITLoaderGDB_h_ |