Add setting to require hardware breakpoints.

When debugging read-only memory we cannot use software breakpoint. We
already have support for hardware breakpoints and users can specify them
with `-H`. However, there's no option to force LLDB to use hardware
breakpoints internally, for example while stepping.

This patch adds a setting target.require-hardware-breakpoint that forces
LLDB to always use hardware breakpoints. Because hardware breakpoints
are a limited resource and can fail to resolve, this patch also extends
error handling in thread plans, where breakpoints are used for stepping.

Differential revision: https://reviews.llvm.org/D54221

llvm-svn: 346920
This commit is contained in:
Jonas Devlieghere
2018-11-15 01:18:15 +00:00
parent df14b94243
commit e103ae92ef
41 changed files with 666 additions and 234 deletions

View File

@@ -58,7 +58,10 @@ ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread,
->GetTarget()
.CreateBreakpoint(m_backstop_addr, true, false)
.get();
if (return_bp != nullptr) {
if (return_bp->IsHardware() && !return_bp->HasResolvedLocations())
m_could_not_resolve_hw_bp = true;
return_bp->SetThreadID(m_thread.GetID());
m_backstop_bkpt_id = return_bp->GetID();
return_bp->SetBreakpointKind("step-through-backstop");
@@ -135,7 +138,26 @@ void ThreadPlanStepThrough::GetDescription(Stream *s,
}
bool ThreadPlanStepThrough::ValidatePlan(Stream *error) {
return m_sub_plan_sp.get() != nullptr;
if (m_could_not_resolve_hw_bp) {
if (error)
error->PutCString(
"Could not create hardware breakpoint for thread plan.");
return false;
}
if (m_backstop_bkpt_id == LLDB_INVALID_BREAK_ID) {
if (error)
error->PutCString("Could not create backstop breakpoint.");
return false;
}
if (!m_sub_plan_sp.get()) {
if (error)
error->PutCString("Does not have a subplan.");
return false;
}
return true;
}
bool ThreadPlanStepThrough::DoPlanExplainsStop(Event *event_ptr) {
@@ -211,6 +233,7 @@ void ThreadPlanStepThrough::ClearBackstopBreakpoint() {
if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) {
m_thread.GetProcess()->GetTarget().RemoveBreakpointByID(m_backstop_bkpt_id);
m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
m_could_not_resolve_hw_bp = false;
}
}