aboutsummaryrefslogtreecommitdiff
path: root/source/Target/ThreadPlanStepInstruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Target/ThreadPlanStepInstruction.cpp')
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp94
1 files changed, 76 insertions, 18 deletions
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index f644ee88f701..fabf63b1e9d6 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -43,21 +43,28 @@ ThreadPlanStepInstruction::ThreadPlanStepInstruction
m_stop_other_threads (stop_other_threads),
m_step_over (step_over)
{
+ m_takes_iteration_count = true;
+ SetUpState();
+}
+
+ThreadPlanStepInstruction::~ThreadPlanStepInstruction ()
+{
+}
+
+void
+ThreadPlanStepInstruction::SetUpState()
+{
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();
+ StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0));
+ m_stack_id = start_frame_sp->GetStackID();
- m_start_has_symbol = m_start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != NULL;
+ 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();
}
-ThreadPlanStepInstruction::~ThreadPlanStepInstruction ()
-{
-}
-
void
ThreadPlanStepInstruction::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
@@ -106,6 +113,37 @@ ThreadPlanStepInstruction::DoPlanExplainsStop (Event *event_ptr)
}
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)
{
if (m_step_over)
@@ -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;
@@ -147,13 +195,13 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
// StepInstruction should probably have the tri-state RunMode, but for now it is safer to
// run others.
const bool stop_others = false;
- m_thread.QueueThreadPlanForStepOut(false,
- NULL,
- true,
- stop_others,
- eVoteNo,
- eVoteNoOpinion,
- 0);
+ m_thread.QueueThreadPlanForStepOutNoShouldStop(false,
+ NULL,
+ true,
+ stop_others,
+ eVoteNo,
+ eVoteNoOpinion,
+ 0);
return false;
}
else
@@ -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;