diff options
11 files changed, 243 insertions, 78 deletions
diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index 90073d886c1..368806e9838 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/lldb-public.h" #include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Breakpoint/BreakpointResolverName.h" #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" #include "lldb/Core/ValueObject.h" @@ -70,6 +71,13 @@ public: return false; } + static lldb::BreakpointSP + CreateExceptionBreakpoint (Target &target, + lldb::LanguageType language, + bool catch_bp, + bool throw_bp, + bool is_internal = false); + protected: //------------------------------------------------------------------ // Classes that inherit from LanguageRuntime can see and modify these @@ -77,10 +85,49 @@ protected: // The Target is the one that knows how to create breakpoints, so this function is meant to be used either // by the target or internally in Set/ClearExceptionBreakpoints. - - virtual lldb::BreakpointSP - CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal = false) = 0; + class ExceptionBreakpointResolver : public BreakpointResolver + { + public: + ExceptionBreakpointResolver (Breakpoint *bkpt, + lldb::LanguageType language, + bool catch_bp, + bool throw_bp); + + virtual ~ExceptionBreakpointResolver() {}; + + virtual Searcher::CallbackReturn + SearchCallback (SearchFilter &filter, + SymbolContext &context, + Address *addr, + bool containing); + + virtual Searcher::Depth + GetDepth (); + + virtual void + GetDescription (Stream *s); + + virtual void + Dump (Stream *s) const {}; + + /// Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const BreakpointResolverName *) { return true; } + static inline bool classof(const BreakpointResolver *V) { + return V->getResolverID() == BreakpointResolver::ExceptionResolver; + } + protected: + bool SetActualResolver(); + lldb::BreakpointResolverSP m_actual_resolver_sp; + lldb::ProcessWP m_process_wp; + lldb::LanguageType m_language; + bool m_catch_bp; + bool m_throw_bp; + }; + + virtual lldb::BreakpointResolverSP + CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0; + LanguageRuntime(Process *process); Process *m_process; private: diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index a2834659a2e..5b7f36c7fb1 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -468,6 +468,9 @@ public: uint32_t func_name_type_mask, bool internal = false, LazyBool skip_prologue = eLazyBoolCalculate); + + lldb::BreakpointSP + CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal = false); // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names @@ -1108,6 +1111,17 @@ public: DISALLOW_COPY_AND_ASSIGN (SettingsController); }; + //------------------------------------------------------------------ + // Methods. + //------------------------------------------------------------------ + lldb::SearchFilterSP + GetSearchFilterForModule (const FileSpec *containingModule); + + lldb::SearchFilterSP + GetSearchFilterForModuleList (const FileSpecList *containingModuleList); + + lldb::SearchFilterSP + GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles); protected: //------------------------------------------------------------------ @@ -1142,19 +1156,6 @@ protected: lldb::user_id_t m_stop_hook_next_id; bool m_suppress_stop_hooks; - //------------------------------------------------------------------ - // Methods. - //------------------------------------------------------------------ - lldb::SearchFilterSP - GetSearchFilterForModule (const FileSpec *containingModule); - - lldb::SearchFilterSP - GetSearchFilterForModuleList (const FileSpecList *containingModuleList); - - lldb::SearchFilterSP - GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles); - - static void ImageSearchPathsChanged (const PathMappingList &path_list, void *baton); diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index ebf2a093fc4..8b80c90de29 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -258,36 +258,31 @@ ItaniumABILanguageRuntime::GetPluginVersion() static const char *exception_names[] = {"__cxa_throw", "__cxa_allocate", "__cxa_rethrow", "__cxa_catch"}; static const int num_throw_names = 3; -BreakpointSP -ItaniumABILanguageRuntime::CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal) +BreakpointResolverSP +ItaniumABILanguageRuntime::CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) { - BreakpointSP exc_breakpt_sp; + BreakpointResolverSP resolver_sp; + if (catch_bp && throw_bp) - exc_breakpt_sp = m_process->GetTarget().CreateBreakpoint (NULL, - NULL, - exception_names, - sizeof (exception_names)/sizeof (char *), - eFunctionNameTypeBase, - is_internal, - eLazyBoolNo); + resolver_sp.reset (new BreakpointResolverName (bkpt, + exception_names, + sizeof (exception_names)/sizeof (char *), + eFunctionNameTypeBase, + eLazyBoolNo)); else if (throw_bp) - exc_breakpt_sp = m_process->GetTarget().CreateBreakpoint (NULL, - NULL, - exception_names, - num_throw_names, - eFunctionNameTypeBase, - is_internal, - eLazyBoolNo); + resolver_sp.reset (new BreakpointResolverName (bkpt, + exception_names, + num_throw_names, + eFunctionNameTypeBase, + eLazyBoolNo)); else if (catch_bp) - exc_breakpt_sp = m_process->GetTarget().CreateBreakpoint (NULL, - NULL, - exception_names + num_throw_names, - sizeof (exception_names)/sizeof (char *) - num_throw_names, - eFunctionNameTypeBase, - is_internal, - eLazyBoolNo); + resolver_sp.reset (new BreakpointResolverName (bkpt, + exception_names + num_throw_names, + sizeof (exception_names)/sizeof (char *) - num_throw_names, + eFunctionNameTypeBase, + eLazyBoolNo)); - return exc_breakpt_sp; + return resolver_sp; } void @@ -301,7 +296,11 @@ ItaniumABILanguageRuntime::SetExceptionBreakpoints () const bool is_internal = true; if (!m_cxx_exception_bp_sp) - m_cxx_exception_bp_sp = CreateExceptionBreakpoint (catch_bp, throw_bp, is_internal); + m_cxx_exception_bp_sp = LanguageRuntime::CreateExceptionBreakpoint (m_process->GetTarget(), + GetLanguageType(), + catch_bp, + throw_bp, + is_internal); else m_cxx_exception_bp_sp->SetEnabled (true); diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h index ae7fa991b2b..507739223f4 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h @@ -74,8 +74,8 @@ namespace lldb_private { ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason); protected: - virtual lldb::BreakpointSP - CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal = false); + virtual lldb::BreakpointResolverSP + CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp); private: ItaniumABILanguageRuntime(Process *process) : lldb_private::CPPLanguageRuntime(process) { } // Call CreateInstance instead. diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 8f955f9dc57..3beab917eac 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -295,7 +295,11 @@ AppleObjCRuntime::SetExceptionBreakpoints () const bool is_internal = true; if (!m_objc_exception_bp_sp) - m_objc_exception_bp_sp = CreateExceptionBreakpoint (catch_bp, throw_bp, is_internal); + m_objc_exception_bp_sp = LanguageRuntime::CreateExceptionBreakpoint (m_process->GetTarget(), + GetLanguageType(), + catch_bp, + throw_bp, + is_internal); else m_objc_exception_bp_sp->SetEnabled(true); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 7f3e8dfad2e..09dc6d135e7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -104,22 +104,18 @@ AppleObjCRuntimeV1::GetPluginVersion() return 1; } -BreakpointSP -AppleObjCRuntimeV1::CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal) +BreakpointResolverSP +AppleObjCRuntimeV1::CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) { - BreakpointSP exc_breakpt_sp; - if (!m_process) - return exc_breakpt_sp; + BreakpointResolverSP resolver_sp; - - // FIXME: Only do throw for now... - if (throw_bp) - exc_breakpt_sp = m_process->GetTarget().CreateBreakpoint (NULL, - NULL, - "objc_exception_throw", - eFunctionNameTypeBase, - is_internal); - return exc_breakpt_sp; + if (catch_bp && throw_bp) + resolver_sp.reset (new BreakpointResolverName (bkpt, + "objc_exception_throw", + eFunctionNameTypeBase, + Breakpoint::Exact, + eLazyBoolNo)); + return resolver_sp; } struct BufStruct { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h index 38a36f189a4..df8b6b469ce 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h @@ -91,8 +91,8 @@ public: } protected: - virtual lldb::BreakpointSP - CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal = false); + virtual lldb::BreakpointResolverSP + CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp); private: AppleObjCRuntimeV1(Process *process) : diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index ff6241491d7..2134f3b2656 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -444,22 +444,18 @@ AppleObjCRuntimeV2::GetPluginVersion() return 1; } -BreakpointSP -AppleObjCRuntimeV2::CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal) +BreakpointResolverSP +AppleObjCRuntimeV2::CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) { - BreakpointSP exc_breakpt_sp; - if (!m_process) - return exc_breakpt_sp; - - - // FIXME: Only do throw for now... - if (throw_bp) - exc_breakpt_sp = m_process->GetTarget().CreateBreakpoint (NULL, - NULL, - "objc_exception_throw", - eFunctionNameTypeBase, - is_internal); - return exc_breakpt_sp; + BreakpointResolverSP resolver_sp; + + if (catch_bp && throw_bp) + resolver_sp.reset (new BreakpointResolverName (bkpt, + "objc_exception_throw", + eFunctionNameTypeBase, + Breakpoint::Exact, + eLazyBoolNo)); + return resolver_sp; } ClangUtilityFunction * diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 47a1f40d77d..057fa62a9e7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -97,8 +97,8 @@ public: GetSymbolVendor(); protected: - virtual lldb::BreakpointSP - CreateExceptionBreakpoint (bool catch_bp, bool throw_bp, bool is_internal = false); + virtual lldb::BreakpointResolverSP + CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp); private: diff --git a/lldb/source/Target/LanguageRuntime.cpp b/lldb/source/Target/LanguageRuntime.cpp index 3b5b3299844..b6a9a5793b4 100644 --- a/lldb/source/Target/LanguageRuntime.cpp +++ b/lldb/source/Target/LanguageRuntime.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/Target.h" #include "lldb/Core/PluginManager.h" using namespace lldb; @@ -46,3 +47,118 @@ LanguageRuntime::LanguageRuntime(Process *process) : LanguageRuntime::~LanguageRuntime() { } + +BreakpointSP +LanguageRuntime::CreateExceptionBreakpoint( + Target &target, + lldb::LanguageType language, + bool catch_bp, + bool throw_bp, + bool is_internal) +{ + BreakpointSP exc_breakpt_sp; + BreakpointResolverSP resolver_sp(new ExceptionBreakpointResolver(NULL, language, catch_bp, throw_bp)); + SearchFilterSP filter_sp(target.GetSearchFilterForModule(NULL)); + + exc_breakpt_sp = target.CreateBreakpoint (filter_sp, resolver_sp, is_internal); + + return exc_breakpt_sp; +} + +LanguageRuntime::ExceptionBreakpointResolver::ExceptionBreakpointResolver (Breakpoint *bkpt, + LanguageType language, + bool catch_bp, + bool throw_bp) : + BreakpointResolver (bkpt, ExceptionResolver), + m_language (language), + m_catch_bp (catch_bp), + m_throw_bp (throw_bp) + +{ +} + +void +LanguageRuntime::ExceptionBreakpointResolver::GetDescription (Stream *s) +{ + s->Printf ("Exception breakpoint (catch: %s throw: %s) using: ", + m_catch_bp ? "on" : "off", + m_throw_bp ? "on" : "off"); + + SetActualResolver(); + if (m_actual_resolver_sp) + { + s->Printf (" using: "); + m_actual_resolver_sp->GetDescription (s); + } + else + s->Printf ("."); +} + +bool +LanguageRuntime::ExceptionBreakpointResolver::SetActualResolver() +{ + ProcessSP process_sp = m_process_wp.lock(); + + // See if our process weak pointer is still good: + if (!process_sp) + { + // If not, our resolver is no good, so chuck that. Then see if we can get the + // target's new process. + m_actual_resolver_sp.reset(); + if (m_breakpoint) + { + Target &target = m_breakpoint->GetTarget(); + process_sp = target.GetProcessSP(); + if (process_sp) + { + m_process_wp = process_sp; + process_sp = m_process_wp.lock(); + } + } + } + + if (process_sp) + { + if (m_actual_resolver_sp) + return true; + else + { + // If we have a process but not a resolver, set one now. + LanguageRuntime *runtime = process_sp->GetLanguageRuntime(m_language); + if (runtime) + { + m_actual_resolver_sp = runtime->CreateExceptionResolver (m_breakpoint, m_catch_bp, m_throw_bp); + return m_actual_resolver_sp; + } + else + return false; + } + } + else + return false; +} + +Searcher::CallbackReturn +LanguageRuntime::ExceptionBreakpointResolver::SearchCallback (SearchFilter &filter, + SymbolContext &context, + Address *addr, + bool containing) +{ + + if (!SetActualResolver()) + { + return eCallbackReturnStop; + } + else + return m_actual_resolver_sp->SearchCallback (filter, context, addr, containing); +} + +Searcher::Depth +LanguageRuntime::ExceptionBreakpointResolver::GetDepth () +{ + if (!SetActualResolver()) + return eDepthTarget; + else + return m_actual_resolver_sp->GetDepth(); +} + diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 01fb9747db9..f3b8a7832ab 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -385,6 +385,12 @@ Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules, return CreateBreakpoint (filter_sp, resolver_sp, internal); } +lldb::BreakpointSP +Target::CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal) +{ + return LanguageRuntime::CreateExceptionBreakpoint (*this, language, catch_bp, throw_bp, internal); +} + BreakpointSP Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal) { |