[Lldb-commits] [lldb] r263049 - Add an "offset" option to "break set -n" and "break set -f -l".
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 9 10:59:13 PST 2016
Author: jingham
Date: Wed Mar 9 12:59:13 2016
New Revision: 263049
URL: http://llvm.org/viewvc/llvm-project?rev=263049&view=rev
Log:
Add an "offset" option to "break set -n" and "break set -f -l".
That way you can set offset breakpoints that will move as the function they are
contained in moves (which address breakpoints can't do...)
I don't align the new address to instruction boundaries yet, so you have to get
this right yourself for now.
<rdar://problem/13365575>
Modified:
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme
lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
lldb/trunk/scripts/interface/SBTarget.i
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Wed Mar 9 12:59:13 2016
@@ -621,6 +621,9 @@ public:
BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
lldb::SBBreakpoint
+ BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset);
+
+ lldb::SBBreakpoint
BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr);
// This version uses name_type_mask = eFunctionNameTypeAuto
@@ -657,6 +660,15 @@ public:
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char *symbol_name[],
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ lldb::addr_t offset,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
lldb::SBBreakpoint
BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = nullptr);
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Wed Mar 9 12:59:13 2016
@@ -60,7 +60,7 @@ public:
/// @result
/// Returns breakpoint location id.
//------------------------------------------------------------------
- BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType);
+ BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType, lldb::addr_t offset = 0);
//------------------------------------------------------------------
/// The Destructor is virtual, all significant breakpoint resolvers derive
@@ -78,6 +78,29 @@ public:
SetBreakpoint (Breakpoint *bkpt);
//------------------------------------------------------------------
+ /// This updates the offset for this breakpoint. All the locations currently
+ /// set for this breakpoint will have their offset adjusted when this is called.
+ ///
+ /// @param[in] offset
+ /// The offset to add to all locations.
+ //------------------------------------------------------------------
+ void
+ SetOffset (lldb::addr_t offset);
+
+ //------------------------------------------------------------------
+ /// This updates the offset for this breakpoint. All the locations currently
+ /// set for this breakpoint will have their offset adjusted when this is called.
+ ///
+ /// @param[in] offset
+ /// The offset to add to all locations.
+ //------------------------------------------------------------------
+ lldb::addr_t
+ GetOffset () const
+ {
+ return m_offset;
+ }
+
+ //------------------------------------------------------------------
/// In response to this method the resolver scans all the modules in the breakpoint's
/// target, and adds any new locations it finds.
///
@@ -145,8 +168,12 @@ protected:
/// matching addresses to unique entries, and skip the prologue if asked to do so, and then set
/// breakpoint locations in this breakpoint for all the resultant addresses.
void SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident);
+
+ lldb::BreakpointLocationSP
+ AddLocation(Address loc_addr, bool *new_location = NULL);
Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
+ lldb::addr_t m_offset; // A random offset the user asked us to add to any breakpoints we set.
private:
// Subclass identifier (for llvm isa/dyn_cast)
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h Wed Mar 9 12:59:13 2016
@@ -31,6 +31,7 @@ public:
BreakpointResolverFileLine (Breakpoint *bkpt,
const FileSpec &resolver,
uint32_t line_no,
+ lldb::addr_t m_offset,
bool check_inlines,
bool skip_prologue,
bool exact_match);
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h Wed Mar 9 12:59:13 2016
@@ -37,6 +37,7 @@ public:
uint32_t name_type_mask,
lldb::LanguageType language,
Breakpoint::MatchType type,
+ lldb::addr_t offset,
bool skip_prologue);
// This one takes an array of names. It is always MatchType = Exact.
@@ -45,6 +46,7 @@ public:
size_t num_names,
uint32_t name_type_mask,
lldb::LanguageType language,
+ lldb::addr_t offset,
bool skip_prologue);
// This one takes a C++ array of names. It is always MatchType = Exact.
@@ -52,18 +54,21 @@ public:
std::vector<std::string> names,
uint32_t name_type_mask,
lldb::LanguageType language,
+ lldb::addr_t offset,
bool skip_prologue);
// Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex,
lldb::LanguageType language,
+ lldb::addr_t offset,
bool skip_prologue);
BreakpointResolverName (Breakpoint *bkpt,
const char *class_name,
const char *method,
Breakpoint::MatchType type,
+ lldb::addr_t offset,
bool skip_prologue);
~BreakpointResolverName() override;
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Wed Mar 9 12:59:13 2016
@@ -767,6 +767,7 @@ public:
CreateBreakpoint (const FileSpecList *containingModules,
const FileSpec &file,
uint32_t line_no,
+ lldb::addr_t offset,
LazyBool check_inlines,
LazyBool skip_prologue,
bool internal,
@@ -823,6 +824,7 @@ public:
const char *func_name,
uint32_t func_name_type_mask,
lldb::LanguageType language,
+ lldb::addr_t offset,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
@@ -844,8 +846,9 @@ public:
const FileSpecList *containingSourceFiles,
const char *func_names[],
size_t num_names,
- uint32_t func_name_type_mask,
+ uint32_t func_name_type_mask,
lldb::LanguageType language,
+ lldb::addr_t offset,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
@@ -856,6 +859,7 @@ public:
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
lldb::LanguageType language,
+ lldb::addr_t m_offset,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme Wed Mar 9 12:59:13 2016
@@ -33,7 +33,7 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
- buildConfiguration = "Debug"
+ buildConfiguration = "DebugClang"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Wed Mar 9 12:59:13 2016
@@ -87,7 +87,7 @@
buildConfiguration = "DebugClang"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- launchStyle = "0"
+ launchStyle = "1"
useCustomWorkingDirectory = "NO"
customWorkingDirectory = "/Volumes/work/gclayton/Documents/devb/attach"
ignoresPersistentStateOnLaunch = "YES"
Modified: lldb/trunk/scripts/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBTarget.i?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/interface/SBTarget.i Wed Mar 9 12:59:13 2016
@@ -586,6 +586,9 @@ public:
BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
lldb::SBBreakpoint
+ BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset);
+
+ lldb::SBBreakpoint
BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
lldb::SBBreakpoint
@@ -601,18 +604,59 @@ public:
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
+%typemap(in) (const char **symbol_name, uint32_t num_names) {
+ using namespace lldb_private;
+ /* Check if is a list */
+ if (PythonList::Check($input)) {
+ PythonList list(PyRefType::Borrowed, $input);
+ $2 = list.GetSize();
+ int i = 0;
+ $1 = (char**)malloc(($2+1)*sizeof(char*));
+ for (i = 0; i < $2; i++) {
+ PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>();
+ if (!py_str.IsAllocated()) {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby");
+ free($1);
+ return nullptr;
+ }
+
+ $1[i] = const_cast<char*>(py_str.GetString().data());
+ }
+ $1[i] = 0;
+ } else if ($input == Py_None) {
+ $1 = NULL;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+//%typecheck(SWIG_TYPECHECK_STRING_ARRAY) (const char *symbol_name[], uint32_t num_names) {
+// $1 = 1;
+// $2 = 1;
+//}
+
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char **symbol_name,
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
lldb::SBBreakpoint
- BreakpointCreateByNames (const char *symbol_name[],
+ BreakpointCreateByNames (const char **symbol_name,
uint32_t num_names,
uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
- BreakpointCreateByNames (const char *symbol_name[],
+ BreakpointCreateByNames (const char **symbol_name,
uint32_t num_names,
uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
lldb::LanguageType symbol_language,
+ lldb::addr_t offset,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Wed Mar 9 12:59:13 2016
@@ -799,6 +799,14 @@ SBBreakpoint
SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
uint32_t line)
{
+ return BreakpointCreateByLocation(sb_file_spec, line, 0);
+}
+
+SBBreakpoint
+SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
+ uint32_t line,
+ lldb::addr_t offset)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -812,7 +820,15 @@ SBTarget::BreakpointCreateByLocation (co
const bool internal = false;
const bool hardware = false;
const LazyBool move_to_nearest_code = eLazyBoolCalculate;
- *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal, hardware, move_to_nearest_code);
+ *sb_bp = target_sp->CreateBreakpoint (NULL,
+ *sb_file_spec,
+ line,
+ offset,
+ check_inlines,
+ skip_prologue,
+ internal,
+ hardware,
+ move_to_nearest_code);
}
if (log)
@@ -844,15 +860,16 @@ SBTarget::BreakpointCreateByName (const
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
+ const lldb::addr_t offset = 0;
if (module_name && module_name[0])
{
FileSpecList module_spec_list;
module_spec_list.Append (FileSpec (module_name, false));
- *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware);
+ *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
}
else
{
- *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware);
+ *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
}
}
@@ -904,6 +921,7 @@ SBTarget::BreakpointCreateByName (const
symbol_name,
name_type_mask,
symbol_language,
+ 0,
skip_prologue,
internal,
hardware);
@@ -935,6 +953,18 @@ SBTarget::BreakpointCreateByNames (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
+ return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, module_list, comp_unit_list);
+}
+
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateByNames (const char *symbol_names[],
+ uint32_t num_names,
+ uint32_t name_type_mask,
+ LanguageType symbol_language,
+ lldb::addr_t offset,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -949,8 +979,9 @@ SBTarget::BreakpointCreateByNames (const
comp_unit_list.get(),
symbol_names,
num_names,
- name_type_mask,
+ name_type_mask,
symbol_language,
+ offset,
skip_prologue,
internal,
hardware);
Modified: lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolver.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolver.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolver.cpp Wed Mar 9 12:59:13 2016
@@ -32,8 +32,9 @@ using namespace lldb;
//----------------------------------------------------------------------
// BreakpointResolver:
//----------------------------------------------------------------------
-BreakpointResolver::BreakpointResolver (Breakpoint *bkpt, const unsigned char resolverTy) :
+BreakpointResolver::BreakpointResolver (Breakpoint *bkpt, const unsigned char resolverTy, lldb::addr_t offset) :
m_breakpoint (bkpt),
+ m_offset(offset),
SubclassID (resolverTy)
{
}
@@ -176,7 +177,7 @@ BreakpointResolver::SetSCMatchesByLine (
}
}
- BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
+ BreakpointLocationSP bp_loc_sp (AddLocation(line_start));
if (log && bp_loc_sp && !m_breakpoint->IsInternal())
{
StreamString s;
@@ -202,3 +203,22 @@ BreakpointResolver::SetSCMatchesByLine (
}
}
}
+
+BreakpointLocationSP
+BreakpointResolver::AddLocation(Address loc_addr, bool *new_location)
+{
+ loc_addr.Slide(m_offset);
+ return m_breakpoint->AddLocation(loc_addr, new_location);
+}
+
+
+void
+BreakpointResolver::SetOffset (lldb::addr_t offset)
+{
+ // There may already be an offset, so we are actually adjusting location addresses by the difference.
+ // lldb::addr_t slide = offset - m_offset;
+ // FIXME: We should go fix up all the already set locations for the new slide.
+
+ m_offset = offset;
+}
+
Modified: lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp Wed Mar 9 12:59:13 2016
@@ -121,8 +121,8 @@ BreakpointResolverAddress::SearchCallbac
}
}
- BreakpointLocationSP bp_loc_sp(m_breakpoint->AddLocation(m_addr));
m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ BreakpointLocationSP bp_loc_sp(AddLocation(m_addr));
if (bp_loc_sp && !m_breakpoint->IsInternal())
{
StreamString s;
Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Wed Mar 9 12:59:13 2016
@@ -31,11 +31,12 @@ BreakpointResolverFileLine::BreakpointRe
Breakpoint *bkpt,
const FileSpec &file_spec,
uint32_t line_no,
+ lldb::addr_t offset,
bool check_inlines,
bool skip_prologue,
bool exact_match
) :
- BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver),
+ BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver, offset),
m_file_spec (file_spec),
m_line_number (line_no),
m_inlines (check_inlines),
@@ -117,6 +118,7 @@ BreakpointResolverFileLine::CopyForBreak
lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileLine(&breakpoint,
m_file_spec,
m_line_number,
+ m_offset,
m_inlines,
m_skip_prologue,
m_exact_match));
Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Wed Mar 9 12:59:13 2016
@@ -31,8 +31,9 @@ BreakpointResolverName::BreakpointResolv
uint32_t name_type_mask,
LanguageType language,
Breakpoint::MatchType type,
+ lldb::addr_t offset,
bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
m_class_name (),
m_regex (),
m_match_type (type),
@@ -60,8 +61,9 @@ BreakpointResolverName::BreakpointResolv
size_t num_names,
uint32_t name_type_mask,
LanguageType language,
+ lldb::addr_t offset,
bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
m_match_type (Breakpoint::Exact),
m_language (language),
m_skip_prologue (skip_prologue)
@@ -76,8 +78,9 @@ BreakpointResolverName::BreakpointResolv
std::vector<std::string> names,
uint32_t name_type_mask,
LanguageType language,
+ lldb::addr_t offset,
bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
m_match_type (Breakpoint::Exact),
m_language (language),
m_skip_prologue (skip_prologue)
@@ -91,8 +94,9 @@ BreakpointResolverName::BreakpointResolv
BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex,
lldb::LanguageType language,
+ lldb::addr_t offset,
bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
m_class_name (nullptr),
m_regex (func_regex),
m_match_type (Breakpoint::Regexp),
@@ -101,12 +105,16 @@ BreakpointResolverName::BreakpointResolv
{
}
-BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
- const char *class_name,
- const char *method,
- Breakpoint::MatchType type,
- bool skip_prologue ) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
+BreakpointResolverName::BreakpointResolverName
+(
+ Breakpoint *bkpt,
+ const char *class_name,
+ const char *method,
+ Breakpoint::MatchType type,
+ lldb::addr_t offset,
+ bool skip_prologue
+) :
+ BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
m_class_name (class_name),
m_regex (),
m_match_type (type),
@@ -124,7 +132,7 @@ BreakpointResolverName::BreakpointResolv
BreakpointResolverName::~BreakpointResolverName() = default;
BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs) :
- BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver),
+ BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver, rhs.m_offset),
m_lookups(rhs.m_lookups),
m_class_name(rhs.m_class_name),
m_regex(rhs.m_regex),
@@ -344,7 +352,7 @@ BreakpointResolverName::SearchCallback(S
{
if (filter.AddressPasses(break_addr))
{
- BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(break_addr, &new_location));
+ BreakpointLocationSP bp_loc_sp (AddLocation(break_addr, &new_location));
bp_loc_sp->SetIsReExported(is_reexported);
if (bp_loc_sp && new_location && !m_breakpoint->IsInternal())
{
Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Mar 9 12:59:13 2016
@@ -277,6 +277,16 @@ public:
m_breakpoint_names.push_back (option_arg);
break;
+ case 'R':
+ {
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+ lldb::addr_t tmp_offset_addr;
+ tmp_offset_addr = Args::StringToAddress(&exe_ctx, option_arg, 0, &error);
+ if (error.Success())
+ m_offset_addr = tmp_offset_addr;
+ }
+ break;
+
case 'o':
m_one_shot = true;
break;
@@ -353,6 +363,7 @@ public:
m_source_text_regexp.clear();
m_modules.Clear();
m_load_addr = LLDB_INVALID_ADDRESS;
+ m_offset_addr = 0;
m_ignore_count = 0;
m_thread_id = LLDB_INVALID_THREAD_ID;
m_thread_index = UINT32_MAX;
@@ -395,6 +406,7 @@ public:
std::string m_source_text_regexp;
FileSpecList m_modules;
lldb::addr_t m_load_addr;
+ lldb::addr_t m_offset_addr;
uint32_t m_ignore_count;
lldb::tid_t m_thread_id;
uint32_t m_thread_index;
@@ -453,6 +465,10 @@ protected:
Breakpoint *bp = nullptr;
FileSpec module_spec;
const bool internal = false;
+
+ // If the user didn't specify skip-prologue, having an offset should turn that off.
+ if (m_options.m_offset_addr != 0 && m_options.m_skip_prologue == eLazyBoolCalculate)
+ m_options.m_skip_prologue = eLazyBoolNo;
switch (break_type)
{
@@ -484,6 +500,7 @@ protected:
bp = target->CreateBreakpoint (&(m_options.m_modules),
file,
m_options.m_line_num,
+ m_options.m_offset_addr,
check_inlines,
m_options.m_skip_prologue,
internal,
@@ -531,6 +548,7 @@ protected:
m_options.m_func_names,
name_type_mask,
m_options.m_language,
+ m_options.m_offset_addr,
m_options.m_skip_prologue,
internal,
m_options.m_hardware).get();
@@ -725,6 +743,7 @@ private:
#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
+#define LLDB_OPT_OFFSET_APPLIES (LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
#define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 )
#define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) )
@@ -838,6 +857,10 @@ CommandObjectBreakpointSet::CommandOptio
{ LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBreakpointName,
"Adds this to the list of names for this breakopint."},
+ { LLDB_OPT_OFFSET_APPLIES, false, "address-slide", 'R', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddress,
+ "Add the specified offset to whatever address(es) the breakpoint resolves to. "
+ "At present this applies the offset directly as given, and doesn't try to align it to instruction boundaries."},
+
{ LLDB_OPT_MOVE_TO_NEAREST_CODE, false, "move-to-nearest-code", 'm', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Move breakpoints to nearest code. If not set the target.move-to-nearest-code setting is used." },
Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Wed Mar 9 12:59:13 2016
@@ -5278,6 +5278,7 @@ public:
BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint (NULL, // Don't limit the breakpoint to certain modules
m_file_sp->GetFileSpec(), // Source file
m_selected_line + 1, // Source line number (m_selected_line is zero based)
+ 0, // No offset
eLazyBoolCalculate, // Check inlines using global setting
eLazyBoolCalculate, // Skip prologue using global setting,
false, // internal
@@ -5314,6 +5315,7 @@ public:
BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint (NULL, // Don't limit the breakpoint to certain modules
m_file_sp->GetFileSpec(), // Source file
m_selected_line + 1, // Source line number (m_selected_line is zero based)
+ 0, // No offset
eLazyBoolCalculate, // Check inlines using global setting
eLazyBoolCalculate, // Skip prologue using global setting,
false, // internal
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Wed Mar 9 12:59:13 2016
@@ -1551,6 +1551,7 @@ DynamicLoaderDarwinKernel::SetNotificati
"OSKextLoadedKextSummariesUpdated",
eFunctionNameTypeFull,
eLanguageTypeUnknown,
+ 0,
skip_prologue,
internal_bp,
hardware).get();
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=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Wed Mar 9 12:59:13 2016
@@ -412,6 +412,7 @@ ItaniumABILanguageRuntime::CreateExcepti
exception_names.size(),
eFunctionNameTypeBase,
eLanguageTypeUnknown,
+ 0,
eLazyBoolNo));
return resolver_sp;
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=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Wed Mar 9 12:59:13 2016
@@ -136,6 +136,7 @@ AppleObjCRuntimeV1::CreateExceptionResol
eFunctionNameTypeBase,
eLanguageTypeUnknown,
Breakpoint::Exact,
+ 0,
eLazyBoolNo));
// FIXME: don't do catch yet.
return resolver_sp;
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=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Mar 9 12:59:13 2016
@@ -730,6 +730,7 @@ AppleObjCRuntimeV2::CreateExceptionResol
eFunctionNameTypeBase,
eLanguageTypeUnknown,
Breakpoint::Exact,
+ 0,
eLazyBoolNo));
// FIXME: We don't do catch breakpoints for ObjC yet.
// Should there be some way for the runtime to specify what it can do in this regard?
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Wed Mar 9 12:59:13 2016
@@ -1157,6 +1157,7 @@ PlatformDarwin::SetThreadCreationBreakpo
llvm::array_lengthof(g_bp_names),
eFunctionNameTypeFull,
eLanguageTypeUnknown,
+ 0,
skip_prologue,
internal,
hardware);
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=263049&r1=263048&r2=263049&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Wed Mar 9 12:59:13 2016
@@ -342,6 +342,7 @@ BreakpointSP
Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpec &file,
uint32_t line_no,
+ lldb::addr_t offset,
LazyBool check_inlines,
LazyBool skip_prologue,
bool internal,
@@ -393,12 +394,13 @@ Target::CreateBreakpoint (const FileSpec
if (move_to_nearest_code == eLazyBoolCalculate)
move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
- BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine(nullptr,
- remapped_file,
- line_no,
- check_inlines,
- skip_prologue,
- !static_cast<bool>(move_to_nearest_code)));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (nullptr,
+ remapped_file,
+ line_no,
+ offset,
+ check_inlines,
+ skip_prologue,
+ !static_cast<bool>(move_to_nearest_code)));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
@@ -447,8 +449,9 @@ BreakpointSP
Target::CreateBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const char *func_name,
- uint32_t func_name_type_mask,
+ uint32_t func_name_type_mask,
LanguageType language,
+ lldb::addr_t offset,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -463,12 +466,13 @@ Target::CreateBreakpoint (const FileSpec
if (language == lldb::eLanguageTypeUnknown)
language = GetLanguage();
- BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
- func_name,
- func_name_type_mask,
- language,
- Breakpoint::Exact,
- skip_prologue));
+ BreakpointResolverSP resolver_sp (new BreakpointResolverName (nullptr,
+ func_name,
+ func_name_type_mask,
+ language,
+ Breakpoint::Exact,
+ offset,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -480,6 +484,7 @@ Target::CreateBreakpoint (const FileSpec
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
LanguageType language,
+ lldb::addr_t offset,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -495,11 +500,13 @@ Target::CreateBreakpoint (const FileSpec
if (language == lldb::eLanguageTypeUnknown)
language = GetLanguage();
- BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
- func_names,
- func_name_type_mask,
- language,
- skip_prologue));
+
+ BreakpointResolverSP resolver_sp (new BreakpointResolverName (nullptr,
+ func_names,
+ func_name_type_mask,
+ language,
+ offset,
+ skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -510,8 +517,9 @@ Target::CreateBreakpoint (const FileSpec
const FileSpecList *containingSourceFiles,
const char *func_names[],
size_t num_names,
- uint32_t func_name_type_mask,
+ uint32_t func_name_type_mask,
LanguageType language,
+ lldb::addr_t offset,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -522,16 +530,23 @@ Target::CreateBreakpoint (const FileSpec
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
if (skip_prologue == eLazyBoolCalculate)
- skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
+ {
+ if (offset == 0)
+ skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo;
+ else
+ skip_prologue = eLazyBoolNo;
+ }
if (language == lldb::eLanguageTypeUnknown)
language = GetLanguage();
- BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
- func_names,
- num_names,
- func_name_type_mask,
- language,
- skip_prologue));
+ BreakpointResolverSP resolver_sp (new BreakpointResolverName (nullptr,
+ func_names,
+ num_names,
+ func_name_type_mask,
+ language,
+ offset,
+ skip_prologue));
+ resolver_sp->SetOffset(offset);
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
return bp_sp;
@@ -610,10 +625,11 @@ Target::CreateFuncRegexBreakpoint (const
bool skip =
(skip_prologue == eLazyBoolCalculate) ? GetSkipPrologue()
: static_cast<bool>(skip_prologue);
- BreakpointResolverSP resolver_sp(new BreakpointResolverName(nullptr,
- func_regex,
- requested_language,
- skip));
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName (nullptr,
+ func_regex,
+ requested_language,
+ 0,
+ skip));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
}
More information about the lldb-commits
mailing list