[Lldb-commits] [lldb] r152015 - in /lldb/trunk: include/lldb/Target/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/
Jim Ingham
jingham at apple.com
Sun Mar 4 20:47:35 PST 2012
Author: jingham
Date: Sun Mar 4 22:47:34 2012
New Revision: 152015
URL: http://llvm.org/viewvc/llvm-project?rev=152015&view=rev
Log:
Make it possible to set Exception breakpoints when the target doesn't yet
have a process, then fetch the right runtime resolver when the process is made.
Modified:
lldb/trunk/include/lldb/Target/LanguageRuntime.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
lldb/trunk/source/Target/LanguageRuntime.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Sun Mar 4 22:47:34 2012
@@ -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 @@
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 @@
// 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:
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Sun Mar 4 22:47:34 2012
@@ -468,6 +468,9 @@
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 @@
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 @@
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);
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Sun Mar 4 22:47:34 2012
@@ -258,36 +258,31 @@
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 @@
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);
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Sun Mar 4 22:47:34 2012
@@ -74,8 +74,8 @@
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.
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Sun Mar 4 22:47:34 2012
@@ -295,7 +295,11 @@
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);
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Sun Mar 4 22:47:34 2012
@@ -104,22 +104,18 @@
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 {
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h Sun Mar 4 22:47:34 2012
@@ -91,8 +91,8 @@
}
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) :
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Sun Mar 4 22:47:34 2012
@@ -444,22 +444,18 @@
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;
+ 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;
}
ClangUtilityFunction *
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Sun Mar 4 22:47:34 2012
@@ -97,8 +97,8 @@
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:
Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Sun Mar 4 22:47:34 2012
@@ -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()
{
}
+
+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();
+}
+
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=152015&r1=152014&r2=152015&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Sun Mar 4 22:47:34 2012
@@ -385,6 +385,12 @@
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)
{
More information about the lldb-commits
mailing list