Most thread plans don't handle eStopReasonInstrumentation stop reasons,
but that wasn't added to the list of reasons they don't explain. That
would mean we keep stepping after hitting the AsanDie breakpoint rather
than stopping when the Asan event occurred.
<rdar://problem/21925479>
llvm-svn: 243035
diff --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp
index 094a6bf..78b999b 100644
--- a/lldb/source/Target/ThreadPlan.cpp
+++ b/lldb/source/Target/ThreadPlan.cpp
@@ -206,6 +206,24 @@
return GetPlanRunState();
}
+bool
+ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason)
+{
+ switch (reason)
+ {
+ case eStopReasonWatchpoint:
+ case eStopReasonSignal:
+ case eStopReasonException:
+ case eStopReasonExec:
+ case eStopReasonThreadExiting:
+ case eStopReasonInstrumentation:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
//----------------------------------------------------------------------
// ThreadPlanNull
//----------------------------------------------------------------------
diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp
index 3ee5792..b3c8249 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -476,7 +476,7 @@
// The only variation is that if we are doing "step by running to next branch" in which case
// if we hit our branch breakpoint we don't set the plan to complete.
- bool return_value;
+ bool return_value = false;
if (m_virtual_step)
{
@@ -488,30 +488,24 @@
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
-
- switch (reason)
+
+ if (reason == eStopReasonBreakpoint)
{
- case eStopReasonBreakpoint:
if (NextRangeBreakpointExplainsStop(stop_info_sp))
{
return_value = true;
- break;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- if (log)
- log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
- }
+ }
+ else if (IsUsuallyUnexplainedStopReason(reason))
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+ if (log)
+ log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return_value = false;
- break;
- default:
+ }
+ else
+ {
return_value = true;
- break;
}
}
else
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp
index 8b702a2..9b39d1c 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -262,9 +262,7 @@
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
- {
- case eStopReasonBreakpoint:
+ if (reason == eStopReasonBreakpoint)
{
// If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
BreakpointSiteSP site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue()));
@@ -310,16 +308,10 @@
}
return false;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
+ else if (IsUsuallyUnexplainedStopReason(reason))
return false;
-
- default:
+ else
return true;
- }
}
return true;
}
diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp
index aba8922..955b32f 100644
--- a/lldb/source/Target/ThreadPlanStepOverRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp
@@ -368,27 +368,22 @@
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
+ if (reason == eStopReasonTrace)
{
- case eStopReasonTrace:
return_value = true;
- break;
- case eStopReasonBreakpoint:
+ }
+ else if (reason == eStopReasonBreakpoint)
+ {
if (NextRangeBreakpointExplainsStop(stop_info_sp))
return_value = true;
else
return_value = false;
- break;
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- default:
+ }
+ else
+ {
if (log)
log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return_value = false;
- break;
}
}
else
diff --git a/lldb/source/Target/ThreadPlanStepUntil.cpp b/lldb/source/Target/ThreadPlanStepUntil.cpp
index 4c3d4a6..a747ee8 100644
--- a/lldb/source/Target/ThreadPlanStepUntil.cpp
+++ b/lldb/source/Target/ThreadPlanStepUntil.cpp
@@ -183,122 +183,117 @@
{
StopReason reason = stop_info_sp->GetStopReason();
- switch (reason)
+ if (reason == eStopReasonBreakpoint)
{
- case eStopReasonBreakpoint:
+ // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
+ BreakpointSiteSP this_site = m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue());
+ if (!this_site)
{
- // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
- BreakpointSiteSP this_site = m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue());
- if (!this_site)
- {
- m_explains_stop = false;
- return;
- }
-
- if (this_site->IsBreakpointAtThisSite (m_return_bp_id))
- {
- // If we are at our "step out" breakpoint, and the stack depth has shrunk, then
- // this is indeed our stop.
- // If the stack depth has grown, then we've hit our step out breakpoint recursively.
- // If we are the only breakpoint at that location, then we do explain the stop, and
- // we'll just continue.
- // If there was another breakpoint here, then we don't explain the stop, but we won't
- // mark ourselves Completed, because maybe that breakpoint will continue, and then
- // we'll finish the "until".
- bool done;
- StackID cur_frame_zero_id;
-
- if (m_stack_id < cur_frame_zero_id)
- done = true;
- else
- done = false;
-
- if (done)
- {
- m_stepped_out = true;
- SetPlanComplete();
- }
- else
- m_should_stop = false;
-
- if (this_site->GetNumberOfOwners() == 1)
- m_explains_stop = true;
- else
- m_explains_stop = false;
- return;
- }
- else
- {
- // Check if we've hit one of our "until" breakpoints.
- until_collection::iterator pos, end = m_until_points.end();
- for (pos = m_until_points.begin(); pos != end; pos++)
- {
- if (this_site->IsBreakpointAtThisSite ((*pos).second))
- {
- // If we're at the right stack depth, then we're done.
-
- bool done;
- StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
-
- if (frame_zero_id == m_stack_id)
- done = true;
- else if (frame_zero_id < m_stack_id)
- done = false;
- else
- {
- StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
-
- // But if we can't even unwind one frame we should just get out of here & stop...
- if (older_frame_sp)
- {
- const SymbolContext &older_context
- = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
- SymbolContext stack_context;
- m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context);
-
- if (older_context == stack_context)
- done = true;
- else
- done = false;
- }
- else
- done = false;
- }
-
- if (done)
- SetPlanComplete();
- else
- m_should_stop = false;
-
- // Otherwise we've hit this breakpoint recursively. If we're the
- // only breakpoint here, then we do explain the stop, and we'll continue.
- // If not then we should let higher plans handle this stop.
- if (this_site->GetNumberOfOwners() == 1)
- m_explains_stop = true;
- else
- {
- m_should_stop = true;
- m_explains_stop = false;
- }
- return;
- }
- }
- }
- // If we get here we haven't hit any of our breakpoints, so let the higher
- // plans take care of the stop.
m_explains_stop = false;
return;
}
- case eStopReasonWatchpoint:
- case eStopReasonSignal:
- case eStopReasonException:
- case eStopReasonExec:
- case eStopReasonThreadExiting:
- m_explains_stop = false;
- break;
- default:
- m_explains_stop = true;
- break;
+
+ if (this_site->IsBreakpointAtThisSite (m_return_bp_id))
+ {
+ // If we are at our "step out" breakpoint, and the stack depth has shrunk, then
+ // this is indeed our stop.
+ // If the stack depth has grown, then we've hit our step out breakpoint recursively.
+ // If we are the only breakpoint at that location, then we do explain the stop, and
+ // we'll just continue.
+ // If there was another breakpoint here, then we don't explain the stop, but we won't
+ // mark ourselves Completed, because maybe that breakpoint will continue, and then
+ // we'll finish the "until".
+ bool done;
+ StackID cur_frame_zero_id;
+
+ if (m_stack_id < cur_frame_zero_id)
+ done = true;
+ else
+ done = false;
+
+ if (done)
+ {
+ m_stepped_out = true;
+ SetPlanComplete();
+ }
+ else
+ m_should_stop = false;
+
+ if (this_site->GetNumberOfOwners() == 1)
+ m_explains_stop = true;
+ else
+ m_explains_stop = false;
+ return;
+ }
+ else
+ {
+ // Check if we've hit one of our "until" breakpoints.
+ until_collection::iterator pos, end = m_until_points.end();
+ for (pos = m_until_points.begin(); pos != end; pos++)
+ {
+ if (this_site->IsBreakpointAtThisSite ((*pos).second))
+ {
+ // If we're at the right stack depth, then we're done.
+
+ bool done;
+ StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+
+ if (frame_zero_id == m_stack_id)
+ done = true;
+ else if (frame_zero_id < m_stack_id)
+ done = false;
+ else
+ {
+ StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
+
+ // But if we can't even unwind one frame we should just get out of here & stop...
+ if (older_frame_sp)
+ {
+ const SymbolContext &older_context
+ = older_frame_sp->GetSymbolContext(eSymbolContextEverything);
+ SymbolContext stack_context;
+ m_stack_id.GetSymbolContextScope()->CalculateSymbolContext(&stack_context);
+
+ if (older_context == stack_context)
+ done = true;
+ else
+ done = false;
+ }
+ else
+ done = false;
+ }
+
+ if (done)
+ SetPlanComplete();
+ else
+ m_should_stop = false;
+
+ // Otherwise we've hit this breakpoint recursively. If we're the
+ // only breakpoint here, then we do explain the stop, and we'll continue.
+ // If not then we should let higher plans handle this stop.
+ if (this_site->GetNumberOfOwners() == 1)
+ m_explains_stop = true;
+ else
+ {
+ m_should_stop = true;
+ m_explains_stop = false;
+ }
+ return;
+ }
+ }
+ }
+ // If we get here we haven't hit any of our breakpoints, so let the higher
+ // plans take care of the stop.
+ m_explains_stop = false;
+ return;
+ }
+ else if (IsUsuallyUnexplainedStopReason(reason))
+ {
+ m_explains_stop = false;
+ }
+ else
+ {
+ m_explains_stop = true;
}
}
}