<rdar://problem/13635174>

Added a way to set hardware breakpoints from the "breakpoint set" command with the new "--hardware" option. Hardware breakpoints are not a request, they currently are a requirement. So when breakpoints are specified as hardware breakpoints, they might fail to be set when they are able to be resolved and should be used sparingly. This is currently hooked up for GDB remote debugging. 

Linux and FreeBSD should quickly enable this feature if possible, or return an error for any breakpoints that are hardware breakpoint sites in the "virtual Error Process::EnableBreakpointSite (BreakpointSite *bp_site);" function.

llvm-svn: 192491
This commit is contained in:
Greg Clayton 2013-10-11 19:48:25 +00:00
parent 877615ccfd
commit eb023e75dc
25 changed files with 208 additions and 119 deletions

View File

@ -576,6 +576,12 @@ public:
InvokeCallback (StoppointCallbackContext *context,
lldb::break_id_t bp_loc_id);
bool
IsHardware() const
{
return m_hardware;
}
protected:
friend class Target;
//------------------------------------------------------------------
@ -590,7 +596,10 @@ protected:
/// variants that make breakpoints for some common cases.
//------------------------------------------------------------------
// This is the generic constructor
Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp);
Breakpoint(Target &target,
lldb::SearchFilterSP &filter_sp,
lldb::BreakpointResolverSP &resolver_sp,
bool hardware);
friend class BreakpointLocation; // To call the following two when determining whether to stop.
@ -609,12 +618,13 @@ private:
// For Breakpoint only
//------------------------------------------------------------------
bool m_being_created;
bool m_hardware; // If this breakpoint is required to use a hardware breakpoint
Target &m_target; // The target that holds this breakpoint.
lldb::SearchFilterSP m_filter_sp; // The filter that constrains the breakpoint's domain.
lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint.
BreakpointOptions m_options; // Settable breakpoint options
BreakpointLocationList m_locations; // The list of locations currently found for this breakpoint.
std::string m_kind_description;
std::string m_kind_description;
void
SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind);

View File

@ -374,8 +374,8 @@ private:
BreakpointLocation (lldb::break_id_t bid,
Breakpoint &owner,
const Address &addr,
lldb::tid_t tid = LLDB_INVALID_THREAD_ID,
bool hardware = false);
lldb::tid_t tid,
bool hardware);
//------------------------------------------------------------------
// Data members:

View File

@ -72,20 +72,20 @@ public:
uint32_t
GetHardwareIndex () const
{
return m_hw_index;
return m_hardware_index;
}
bool
HardwarePreferred () const
HardwareRequired () const
{
return m_hw_preferred;
return m_hardware;
}
virtual bool
IsHardware () const
{
return m_hw_index != LLDB_INVALID_INDEX32;
return m_hardware_index != LLDB_INVALID_INDEX32;
}
@ -103,7 +103,7 @@ public:
void
SetHardwareIndex (uint32_t index)
{
m_hw_index = index;
m_hardware_index = index;
}
@ -120,8 +120,8 @@ protected:
lldb::break_id_t m_loc_id; // Stoppoint location ID
lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't
// store a full Address since that's not needed for the breakpoint sites.
bool m_hw_preferred; // 1 if this point has been requested to be set using hardware (which may fail due to lack of resources)
uint32_t m_hw_index; // The hardware resource index for this breakpoint/watchpoint
bool m_hardware; // True if this point has been is required to use hardware (which may fail due to lack of resources)
uint32_t m_hardware_index; // The hardware resource index for this breakpoint/watchpoint
uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length of the trap opcode for
// software breakpoints, or the optional length in bytes for
// hardware breakpoints, or the length of the watchpoint.

View File

@ -503,26 +503,30 @@ public:
CreateBreakpoint (const FileSpecList *containingModules,
const FileSpec &file,
uint32_t line_no,
LazyBool check_inlines = eLazyBoolCalculate,
LazyBool skip_prologue = eLazyBoolCalculate,
bool internal = false);
LazyBool check_inlines,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
// Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
lldb::BreakpointSP
CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *source_file_list,
RegularExpression &source_regex,
bool internal = false);
bool internal,
bool request_hardware);
// Use this to create a breakpoint from a load address
lldb::BreakpointSP
CreateBreakpoint (lldb::addr_t load_addr,
bool internal = false);
bool internal,
bool request_hardware);
// Use this to create Address breakpoints:
lldb::BreakpointSP
CreateBreakpoint (Address &addr,
bool internal = false);
bool internal,
bool request_hardware);
// Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
// When "skip_prologue is set to eLazyBoolCalculate, we use the current target
@ -531,8 +535,9 @@ public:
CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regexp,
LazyBool skip_prologue = eLazyBoolCalculate,
bool internal = false);
LazyBool skip_prologue,
bool internal,
bool request_hardware);
// Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
// When "skip_prologue is set to eLazyBoolCalculate, we use the current target
@ -542,11 +547,12 @@ public:
const FileSpecList *containingSourceFiles,
const char *func_name,
uint32_t func_name_type_mask,
LazyBool skip_prologue = eLazyBoolCalculate,
bool internal = false);
LazyBool skip_prologue,
bool internal,
bool request_hardware);
lldb::BreakpointSP
CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal = false);
CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal);
// 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
@ -557,23 +563,26 @@ public:
const char *func_names[],
size_t num_names,
uint32_t func_name_type_mask,
LazyBool skip_prologue = eLazyBoolCalculate,
bool internal = false);
LazyBool skip_prologue,
bool internal,
bool request_hardware);
lldb::BreakpointSP
CreateBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
LazyBool skip_prologue = eLazyBoolCalculate,
bool internal = false);
LazyBool skip_prologue,
bool internal,
bool request_hardware);
// Use this to create a general breakpoint:
lldb::BreakpointSP
CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
lldb::BreakpointResolverSP &resolver_sp,
bool internal = false);
bool internal,
bool request_hardware);
// Use this to create a watchpoint:
lldb::WatchpointSP

View File

@ -1261,7 +1261,8 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
}
SBSymbolContext
SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope)
SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr,
uint32_t resolve_scope)
{
SBSymbolContext sc;
if (addr.IsValid())
@ -1275,13 +1276,15 @@ SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolv
SBBreakpoint
SBTarget::BreakpointCreateByLocation (const char *file, uint32_t line)
SBTarget::BreakpointCreateByLocation (const char *file,
uint32_t line)
{
return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
}
SBBreakpoint
SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line)
SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
uint32_t line)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1294,7 +1297,8 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t l
const LazyBool check_inlines = eLazyBoolCalculate;
const LazyBool skip_prologue = eLazyBoolCalculate;
const bool internal = false;
*sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal);
const bool hardware = false;
*sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal, hardware);
}
if (log)
@ -1315,7 +1319,8 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t l
}
SBBreakpoint
SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name)
SBTarget::BreakpointCreateByName (const char *symbol_name,
const char *module_name)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1326,16 +1331,17 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_na
Mutex::Locker api_locker (target_sp->GetAPIMutex());
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
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, skip_prologue, internal);
*sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
}
else
{
*sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal);
*sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
}
}
@ -1350,8 +1356,8 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_na
lldb::SBBreakpoint
SBTarget::BreakpointCreateByName (const char *symbol_name,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
uint32_t name_type_mask = eFunctionNameTypeAuto;
return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list);
@ -1359,9 +1365,9 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
lldb::SBBreakpoint
SBTarget::BreakpointCreateByName (const char *symbol_name,
uint32_t name_type_mask,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
uint32_t name_type_mask,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1370,14 +1376,16 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
if (target_sp && symbol_name && symbol_name[0])
{
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
Mutex::Locker api_locker (target_sp->GetAPIMutex());
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
comp_unit_list.get(),
symbol_name,
name_type_mask,
skip_prologue,
internal);
comp_unit_list.get(),
symbol_name,
name_type_mask,
skip_prologue,
internal,
hardware);
}
if (log)
@ -1404,6 +1412,7 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[],
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
comp_unit_list.get(),
@ -1411,7 +1420,8 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[],
num_names,
name_type_mask,
skip_prologue,
internal);
internal,
hardware);
}
if (log)
@ -1437,7 +1447,8 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[],
}
SBBreakpoint
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name)
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
const char *module_name)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1448,6 +1459,7 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo
Mutex::Locker api_locker (target_sp->GetAPIMutex());
RegularExpression regexp(symbol_name_regex);
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
if (module_name && module_name[0])
@ -1455,11 +1467,11 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo
FileSpecList module_spec_list;
module_spec_list.Append (FileSpec (module_name, false));
*sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal);
*sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal, hardware);
}
else
{
*sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal);
*sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal, hardware);
}
}
@ -1474,8 +1486,8 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo
lldb::SBBreakpoint
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1486,9 +1498,10 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
Mutex::Locker api_locker (target_sp->GetAPIMutex());
RegularExpression regexp(symbol_name_regex);
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
*sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal);
*sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal, hardware);
}
if (log)
@ -1510,7 +1523,8 @@ SBTarget::BreakpointCreateByAddress (addr_t address)
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
*sb_bp = target_sp->CreateBreakpoint (address, false);
const bool hardware = false;
*sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
}
if (log)
@ -1522,7 +1536,9 @@ SBTarget::BreakpointCreateByAddress (addr_t address)
}
lldb::SBBreakpoint
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name)
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
const lldb::SBFileSpec &source_file,
const char *module_name)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1533,6 +1549,7 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::S
Mutex::Locker api_locker (target_sp->GetAPIMutex());
RegularExpression regexp(source_regex);
FileSpecList source_file_spec_list;
const bool hardware = false;
source_file_spec_list.Append (source_file.ref());
if (module_name && module_name[0])
@ -1540,11 +1557,11 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::S
FileSpecList module_spec_list;
module_spec_list.Append (FileSpec (module_name, false));
*sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false);
*sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false, hardware);
}
else
{
*sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false);
*sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false, hardware);
}
}
@ -1561,8 +1578,8 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::S
lldb::SBBreakpoint
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
const SBFileSpecList &module_list,
const lldb::SBFileSpecList &source_file_list)
const SBFileSpecList &module_list,
const lldb::SBFileSpecList &source_file_list)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1571,8 +1588,9 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
if (target_sp && source_regex && source_regex[0])
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
const bool hardware = false;
RegularExpression regexp(source_regex);
*sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false);
*sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false, hardware);
}
if (log)
@ -1586,8 +1604,8 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
lldb::SBBreakpoint
SBTarget::BreakpointCreateForException (lldb::LanguageType language,
bool catch_bp,
bool throw_bp)
bool catch_bp,
bool throw_bp)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -1596,7 +1614,8 @@ SBTarget::BreakpointCreateForException (lldb::LanguageType language,
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
*sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp);
const bool hardware = false;
*sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware);
}
if (log)

View File

@ -45,8 +45,9 @@ Breakpoint::GetEventIdentifier ()
//----------------------------------------------------------------------
// Breakpoint constructor
//----------------------------------------------------------------------
Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp) :
Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool hardware) :
m_being_created(true),
m_hardware(hardware),
m_target (target),
m_filter_sp (filter_sp),
m_resolver_sp (resolver_sp),

View File

@ -484,7 +484,7 @@ BreakpointLocation::ResolveBreakpointSite ()
if (process == NULL)
return false;
lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), false);
lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware());
if (new_id == LLDB_INVALID_BREAK_ID)
{

View File

@ -41,7 +41,7 @@ BreakpointLocationList::Create (const Address &addr)
Mutex::Locker locker (m_mutex);
// The location ID is just the size of the location list + 1
lldb::break_id_t bp_loc_id = ++m_next_id;
BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr));
BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware()));
m_locations.push_back (bp_loc_sp);
m_address_to_location[addr] = bp_loc_sp;
return bp_loc_sp;

View File

@ -23,8 +23,8 @@ using namespace lldb_private;
StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, bool hardware) :
m_loc_id(bid),
m_addr(addr),
m_hw_preferred(hardware),
m_hw_index(LLDB_INVALID_INDEX32),
m_hardware(hardware),
m_hardware_index(LLDB_INVALID_INDEX32),
m_byte_size(0),
m_hit_count(0)
{
@ -33,8 +33,8 @@ StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, bool hardware
StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, uint32_t byte_size, bool hardware) :
m_loc_id(bid),
m_addr(addr),
m_hw_preferred(hardware),
m_hw_index(LLDB_INVALID_INDEX32),
m_hardware(hardware),
m_hardware_index(LLDB_INVALID_INDEX32),
m_byte_size(byte_size),
m_hit_count(0)
{

View File

@ -106,6 +106,7 @@ public:
m_queue_name(),
m_catch_bp (false),
m_throw_bp (true),
m_hardware (false),
m_language (eLanguageTypeUnknown),
m_skip_prologue (eLazyBoolCalculate),
m_one_shot (false)
@ -183,13 +184,18 @@ public:
break;
case 'h':
{
bool success;
m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
}
break;
{
bool success;
m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
}
break;
case 'H':
m_hardware = true;
break;
case 'i':
{
m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
@ -311,6 +317,7 @@ public:
m_queue_name.clear();
m_catch_bp = false;
m_throw_bp = true;
m_hardware = false;
m_language = eLanguageTypeUnknown;
m_skip_prologue = eLazyBoolCalculate;
m_one_shot = false;
@ -345,6 +352,7 @@ public:
std::string m_queue_name;
bool m_catch_bp;
bool m_throw_bp;
bool m_hardware; // Request to use hardware breakpoints
lldb::LanguageType m_language;
LazyBool m_skip_prologue;
bool m_one_shot;
@ -423,12 +431,15 @@ protected:
m_options.m_line_num,
check_inlines,
m_options.m_skip_prologue,
internal).get();
internal,
m_options.m_hardware).get();
}
break;
case eSetTypeAddress: // Breakpoint by address
bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
bp = target->CreateBreakpoint (m_options.m_load_addr,
internal,
m_options.m_hardware).get();
break;
case eSetTypeFunctionName: // Breakpoint by function name
@ -443,7 +454,8 @@ protected:
m_options.m_func_names,
name_type_mask,
m_options.m_skip_prologue,
internal).get();
internal,
m_options.m_hardware).get();
}
break;
@ -464,7 +476,8 @@ protected:
&(m_options.m_filenames),
regexp,
m_options.m_skip_prologue,
internal).get();
internal,
m_options.m_hardware).get();
}
break;
case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
@ -496,12 +509,19 @@ protected:
result.SetStatus (eReturnStatusFailed);
return false;
}
bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules),
&(m_options.m_filenames),
regexp,
internal,
m_options.m_hardware).get();
}
break;
case eSetTypeException:
{
bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
bp = target->CreateExceptionBreakpoint (m_options.m_language,
m_options.m_catch_bp,
m_options.m_throw_bp,
m_options.m_hardware).get();
}
break;
default:
@ -625,6 +645,9 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, 0, eArgTypeThreadName,
"The breakpoint stops only for the thread whose thread name matches this argument."},
{ LLDB_OPT_SET_ALL, false, "hardware", 'H', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,
"Require the breakpoint to use hardware breakpoints."},
{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, 0, eArgTypeQueueName,
"The breakpoint stops only for threads in the queue whose name is given by this argument."},

View File

@ -1503,6 +1503,7 @@ DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded ()
const bool internal_bp = true;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolNo;
FileSpecList module_spec_list;
module_spec_list.Append (m_kernel.GetModule()->GetFileSpec());
@ -1511,7 +1512,8 @@ DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded ()
"OSKextLoadedKextSummariesUpdated",
eFunctionNameTypeFull,
skip_prologue,
internal_bp).get();
internal_bp,
hardware).get();
bp->SetCallback (DynamicLoaderDarwinKernel::BreakpointHitCallback, this, true);
m_break_id = bp->GetID();

View File

@ -1543,7 +1543,7 @@ DynamicLoaderMacOSXDYLD::SetNotificationBreakpoint ()
if (m_process->GetTarget().GetSectionLoadList().ResolveLoadAddress(m_dyld_all_image_infos.notification, so_addr))
{
Breakpoint *dyld_break = m_process->GetTarget().CreateBreakpoint (so_addr, true).get();
Breakpoint *dyld_break = m_process->GetTarget().CreateBreakpoint (so_addr, true, false).get();
dyld_break->SetCallback (DynamicLoaderMacOSXDYLD::NotifyBreakpointHit, this, true);
dyld_break->SetBreakpointKind ("shared-library-event");
m_break_id = dyld_break->GetID();

View File

@ -260,7 +260,7 @@ DynamicLoaderPOSIXDYLD::ProbeEntry()
if ((entry = GetEntryPoint()) == LLDB_INVALID_ADDRESS)
return;
entry_break = m_process->GetTarget().CreateBreakpoint(entry, true).get();
entry_break = m_process->GetTarget().CreateBreakpoint(entry, true, false).get();
entry_break->SetCallback(EntryBreakpointHit, this, true);
entry_break->SetBreakpointKind("shared-library-event");
}
@ -293,7 +293,7 @@ DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint()
if (m_dyld_bid == LLDB_INVALID_BREAK_ID)
{
Breakpoint *dyld_break = target.CreateBreakpoint (break_addr, true).get();
Breakpoint *dyld_break = target.CreateBreakpoint (break_addr, true, false).get();
dyld_break->SetCallback(RendezvousBreakpointHit, this, true);
dyld_break->SetBreakpointKind ("shared-library-event");
m_dyld_bid = dyld_break->GetID();

View File

@ -402,7 +402,7 @@ ItaniumABILanguageRuntime::CreateExceptionBreakpoint (bool catch_bp,
FileSpecList filter_modules;
BreakpointResolverSP exception_resolver_sp = CreateExceptionResolver (NULL, catch_bp, throw_bp, for_expressions);
SearchFilterSP filter_sp (CreateExceptionSearchFilter ());
return target.CreateBreakpoint (filter_sp, exception_resolver_sp, is_internal);
return target.CreateBreakpoint (filter_sp, exception_resolver_sp, is_internal, false);
}
void

View File

@ -478,7 +478,7 @@ AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols ()
lldb::addr_t changed_addr = changed_symbol->GetAddress().GetOpcodeLoadAddress (&target);
if (changed_addr != LLDB_INVALID_ADDRESS)
{
BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, true);
BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, true, false);
if (trampolines_changed_bp_sp)
{
m_trampolines_changed_bp_id = trampolines_changed_bp_sp->GetID();

View File

@ -1232,6 +1232,7 @@ PlatformDarwin::SetThreadCreationBreakpoint (Target &target)
}
bool internal = true;
bool hardware = false;
LazyBool skip_prologue = eLazyBoolNo;
bp_sp = target.CreateBreakpoint (&bp_modules,
NULL,
@ -1239,7 +1240,8 @@ PlatformDarwin::SetThreadCreationBreakpoint (Target &target)
sizeof(g_bp_names)/sizeof(const char *),
eFunctionNameTypeFull,
skip_prologue,
internal);
internal,
hardware);
bp_sp->SetBreakpointKind("thread-creation");
return bp_sp;

View File

@ -2223,7 +2223,7 @@ ProcessGDBRemote::EnableBreakpointSite (BreakpointSite *bp_site)
{
const size_t bp_op_size = GetSoftwareBreakpointTrapOpcode (bp_site);
if (bp_site->HardwarePreferred())
if (bp_site->HardwareRequired())
{
// Try and set hardware breakpoint, and if that fails, fall through
// and set a software breakpoint?
@ -2233,12 +2233,19 @@ ProcessGDBRemote::EnableBreakpointSite (BreakpointSite *bp_site)
{
bp_site->SetEnabled(true);
bp_site->SetType (BreakpointSite::eHardware);
return error;
}
else
{
error.SetErrorString("failed to set hardware breakpoint (hardware breakpoint resources might be exhausted or unavailable)");
}
}
else
{
error.SetErrorString("hardware breakpoints are not supported");
}
return error;
}
if (m_gdb_comm.SupportsGDBStoppointPacket (eBreakpointSoftware))
else if (m_gdb_comm.SupportsGDBStoppointPacket (eBreakpointSoftware))
{
if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, true, addr, bp_op_size) == 0)
{

View File

@ -268,8 +268,8 @@ LanguageRuntime::CreateExceptionBreakpoint (Target &target,
{
BreakpointResolverSP resolver_sp(new ExceptionBreakpointResolver(language, catch_bp, throw_bp));
SearchFilterSP filter_sp(new ExceptionSearchFilter(target.shared_from_this(), language));
BreakpointSP exc_breakpt_sp (target.CreateBreakpoint (filter_sp, resolver_sp, is_internal));
bool hardware = false;
BreakpointSP exc_breakpt_sp (target.CreateBreakpoint (filter_sp, resolver_sp, is_internal, hardware));
if (is_internal)
exc_breakpt_sp->SetBreakpointKind("exception");

View File

@ -2094,11 +2094,21 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
bp_site_sp.reset (new BreakpointSite (&m_breakpoint_site_list, owner, load_addr, use_hardware));
if (bp_site_sp)
{
if (EnableBreakpointSite (bp_site_sp.get()).Success())
Error error = EnableBreakpointSite (bp_site_sp.get());
if (error.Success())
{
owner->SetBreakpointSite (bp_site_sp);
return m_breakpoint_site_list.Add (bp_site_sp);
}
else
{
// Report error for setting breakpoint...
m_target.GetDebugger().GetErrorFile().Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
load_addr,
owner->GetBreakpoint().GetID(),
owner->GetID(),
error.AsCString() ? error.AsCString() : "unkown error");
}
}
}
}

View File

@ -245,11 +245,12 @@ BreakpointSP
Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *source_file_spec_list,
RegularExpression &source_regex,
bool internal)
bool internal,
bool hardware)
{
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, source_file_spec_list));
BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, source_regex));
return CreateBreakpoint (filter_sp, resolver_sp, internal);
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
@ -259,7 +260,8 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
uint32_t line_no,
LazyBool check_inlines,
LazyBool skip_prologue,
bool internal)
bool internal,
bool hardware)
{
if (check_inlines == eLazyBoolCalculate)
{
@ -302,12 +304,12 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
line_no,
check_inlines,
skip_prologue));
return CreateBreakpoint (filter_sp, resolver_sp, internal);
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
BreakpointSP
Target::CreateBreakpoint (lldb::addr_t addr, bool internal)
Target::CreateBreakpoint (lldb::addr_t addr, bool internal, bool hardware)
{
Address so_addr;
// Attempt to resolve our load address if possible, though it is ok if
@ -320,16 +322,16 @@ Target::CreateBreakpoint (lldb::addr_t addr, bool internal)
// The address didn't resolve, so just set this as an absolute address
so_addr.SetOffset (addr);
}
BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal));
BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal, hardware));
return bp_sp;
}
BreakpointSP
Target::CreateBreakpoint (Address &addr, bool internal)
Target::CreateBreakpoint (Address &addr, bool internal, bool hardware)
{
SearchFilterSP filter_sp(new SearchFilterForNonModuleSpecificSearches (shared_from_this()));
BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr));
return CreateBreakpoint (filter_sp, resolver_sp, internal);
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
BreakpointSP
@ -338,7 +340,8 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
const char *func_name,
uint32_t func_name_type_mask,
LazyBool skip_prologue,
bool internal)
bool internal,
bool hardware)
{
BreakpointSP bp_sp;
if (func_name)
@ -353,7 +356,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
func_name_type_mask,
Breakpoint::Exact,
skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal);
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
return bp_sp;
}
@ -364,7 +367,8 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
const std::vector<std::string> &func_names,
uint32_t func_name_type_mask,
LazyBool skip_prologue,
bool internal)
bool internal,
bool hardware)
{
BreakpointSP bp_sp;
size_t num_names = func_names.size();
@ -379,7 +383,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
func_names,
func_name_type_mask,
skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal);
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
return bp_sp;
}
@ -391,7 +395,8 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
size_t num_names,
uint32_t func_name_type_mask,
LazyBool skip_prologue,
bool internal)
bool internal,
bool hardware)
{
BreakpointSP bp_sp;
if (num_names > 0)
@ -406,7 +411,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules,
num_names,
func_name_type_mask,
skip_prologue));
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal);
bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
return bp_sp;
}
@ -476,14 +481,15 @@ Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regex,
LazyBool skip_prologue,
bool internal)
bool internal,
bool hardware)
{
SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL,
func_regex,
skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue));
return CreateBreakpoint (filter_sp, resolver_sp, internal);
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware);
}
lldb::BreakpointSP
@ -493,12 +499,12 @@ Target::CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_
}
BreakpointSP
Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal)
Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal, bool request_hardware)
{
BreakpointSP bp_sp;
if (filter_sp && resolver_sp)
{
bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp));
bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp, request_hardware));
resolver_sp->SetBreakpoint (bp_sp.get());
if (internal)

View File

@ -88,7 +88,7 @@ ThreadPlanRunToAddress::SetInitialBreakpoints ()
for (size_t i = 0; i < num_addresses; i++)
{
Breakpoint *breakpoint;
breakpoint = m_thread.CalculateTarget()->CreateBreakpoint (m_addresses[i], true).get();
breakpoint = m_thread.CalculateTarget()->CreateBreakpoint (m_addresses[i], true, false).get();
if (breakpoint != NULL)
{
m_break_ids[i] = breakpoint->GetID();

View File

@ -102,7 +102,7 @@ ThreadPlanStepOut::ThreadPlanStepOut
if (m_return_addr == LLDB_INVALID_ADDRESS)
return;
Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true).get();
Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true, false).get();
if (return_bp != NULL)
{
return_bp->SetThreadID(m_thread.GetID());

View File

@ -382,7 +382,7 @@ ThreadPlanStepRange::SetNextBranchBreakpoint ()
{
const bool is_internal = true;
run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal);
m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
if (m_next_branch_bp_sp)
{
if (log)

View File

@ -56,7 +56,7 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_i
if (return_frame_sp)
{
m_backstop_addr = return_frame_sp->GetFrameCodeAddress().GetLoadAddress(m_thread.CalculateTarget().get());
Breakpoint *return_bp = m_thread.GetProcess()->GetTarget().CreateBreakpoint (m_backstop_addr, true).get();
Breakpoint *return_bp = m_thread.GetProcess()->GetTarget().CreateBreakpoint (m_backstop_addr, true, false).get();
if (return_bp != NULL)
{
return_bp->SetThreadID(m_thread.GetID());

View File

@ -68,7 +68,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
{
// TODO: add inline functionality
m_return_addr = return_frame_sp->GetStackID().GetPC();
Breakpoint *return_bp = target_sp->CreateBreakpoint (m_return_addr, true).get();
Breakpoint *return_bp = target_sp->CreateBreakpoint (m_return_addr, true, false).get();
if (return_bp != NULL)
{
return_bp->SetThreadID(thread_id);
@ -82,7 +82,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
// Now set breakpoints on all our return addresses:
for (size_t i = 0; i < num_addresses; i++)
{
Breakpoint *until_bp = target_sp->CreateBreakpoint (address_list[i], true).get();
Breakpoint *until_bp = target_sp->CreateBreakpoint (address_list[i], true, false).get();
if (until_bp != NULL)
{
until_bp->SetThreadID(thread_id);