mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 21:55:39 +08:00
Add the ability to provide a "count" option to the various "thread step-*" operations. Only
step-inst and step-inst are currently supported, the rest just warn that they are not supported if you try to provide a count. llvm-svn: 212559
This commit is contained in:
@@ -43,21 +43,28 @@ ThreadPlanStepInstruction::ThreadPlanStepInstruction
|
||||
m_stop_other_threads (stop_other_threads),
|
||||
m_step_over (step_over)
|
||||
{
|
||||
m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
|
||||
StackFrameSP m_start_frame_sp(m_thread.GetStackFrameAtIndex(0));
|
||||
m_stack_id = m_start_frame_sp->GetStackID();
|
||||
|
||||
m_start_has_symbol = m_start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != NULL;
|
||||
|
||||
StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
|
||||
if (parent_frame_sp)
|
||||
m_parent_frame_id = parent_frame_sp->GetStackID();
|
||||
m_takes_iteration_count = true;
|
||||
SetUpState();
|
||||
}
|
||||
|
||||
ThreadPlanStepInstruction::~ThreadPlanStepInstruction ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ThreadPlanStepInstruction::SetUpState()
|
||||
{
|
||||
m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
|
||||
StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0));
|
||||
m_stack_id = start_frame_sp->GetStackID();
|
||||
|
||||
m_start_has_symbol = start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != NULL;
|
||||
|
||||
StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
|
||||
if (parent_frame_sp)
|
||||
m_parent_frame_id = parent_frame_sp->GetStackID();
|
||||
}
|
||||
|
||||
void
|
||||
ThreadPlanStepInstruction::GetDescription (Stream *s, lldb::DescriptionLevel level)
|
||||
{
|
||||
@@ -105,6 +112,37 @@ ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ThreadPlanStepInstruction::IsPlanStale ()
|
||||
{
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
||||
StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
|
||||
if (cur_frame_id == m_stack_id)
|
||||
{
|
||||
if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (cur_frame_id < m_stack_id)
|
||||
{
|
||||
// If the current frame is younger than the start frame and we are stepping over, then we need to continue,
|
||||
// but if we are doing just one step, we're done.
|
||||
if (m_step_over)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf ("ThreadPlanStepInstruction::IsPlanStale - Current frame is older than start frame, plan is stale.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
|
||||
{
|
||||
@@ -118,8 +156,18 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
|
||||
{
|
||||
if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
|
||||
{
|
||||
SetPlanComplete();
|
||||
return true;
|
||||
if (--m_iteration_count <= 0)
|
||||
{
|
||||
SetPlanComplete();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are still stepping, reset the start pc, and in case we've stepped out,
|
||||
// reset the current stack id.
|
||||
SetUpState();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@@ -182,8 +230,18 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
|
||||
{
|
||||
if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr)
|
||||
{
|
||||
SetPlanComplete();
|
||||
return true;
|
||||
if (--m_iteration_count <= 0)
|
||||
{
|
||||
SetPlanComplete();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are still stepping, reset the start pc, and in case we've stepped in or out,
|
||||
// reset the current stack id.
|
||||
SetUpState();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user