Author: jingham Date: Thu Jul 23 14:55:02 2015 New Revision: 243035 URL: http://llvm.org/viewvc/llvm-project?rev=243035&view=rev Log: 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> Modified: lldb/trunk/include/lldb/Target/InstrumentationRuntimeStopInfo.h lldb/trunk/include/lldb/Target/ThreadPlan.h lldb/trunk/source/Target/ThreadPlan.cpp lldb/trunk/source/Target/ThreadPlanStepInRange.cpp lldb/trunk/source/Target/ThreadPlanStepOut.cpp lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Modified: lldb/trunk/include/lldb/Target/InstrumentationRuntimeStopInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/InstrumentationRuntimeStopInfo.h?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/InstrumentationRuntimeStopInfo.h (original) +++ lldb/trunk/include/lldb/Target/InstrumentationRuntimeStopInfo.h Thu Jul 23 14:55:02 2015 @@ -37,6 +37,12 @@ public: virtual const char * GetDescription (); + + virtual bool + DoShouldNotify (Event *event_ptr) + { + return true; + } static lldb::StopInfoSP CreateStopReasonWithInstrumentationData (Thread &thread, std::string description, StructuredData::ObjectSP additional_data); Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlan.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlan.h Thu Jul 23 14:55:02 2015 @@ -613,6 +613,9 @@ protected: virtual lldb::StateType GetPlanRunState () = 0; + bool + IsUsuallyUnexplainedStopReason(lldb::StopReason); + Thread &m_thread; Vote m_stop_vote; Vote m_run_vote; Modified: lldb/trunk/source/Target/ThreadPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlan.cpp (original) +++ lldb/trunk/source/Target/ThreadPlan.cpp Thu Jul 23 14:55:02 2015 @@ -206,6 +206,24 @@ ThreadPlan::RunState () 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 //---------------------------------------------------------------------- Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Thu Jul 23 14:55:02 2015 @@ -476,7 +476,7 @@ ThreadPlanStepInRange::DoPlanExplainsSto // 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 @@ ThreadPlanStepInRange::DoPlanExplainsSto 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 Modified: lldb/trunk/source/Target/ThreadPlanStepOut.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOut.cpp?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOut.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOut.cpp Thu Jul 23 14:55:02 2015 @@ -262,9 +262,7 @@ ThreadPlanStepOut::DoPlanExplainsStop (E 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 @@ ThreadPlanStepOut::DoPlanExplainsStop (E } return false; } - case eStopReasonWatchpoint: - case eStopReasonSignal: - case eStopReasonException: - case eStopReasonExec: - case eStopReasonThreadExiting: + else if (IsUsuallyUnexplainedStopReason(reason)) return false; - - default: + else return true; - } } return true; } Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Thu Jul 23 14:55:02 2015 @@ -368,27 +368,22 @@ ThreadPlanStepOverRange::DoPlanExplainsS { 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 Modified: lldb/trunk/source/Target/ThreadPlanStepUntil.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepUntil.cpp?rev=243035&r1=243034&r2=243035&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepUntil.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Thu Jul 23 14:55:02 2015 @@ -183,122 +183,117 @@ ThreadPlanStepUntil::AnalyzeStop() { 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; - } + m_explains_stop = false; + return; + } - if (this_site->IsBreakpointAtThisSite (m_return_bp_id)) + 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) { - // 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; + 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++) { - // 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 (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 { - // 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) { - 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; - } + 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; } - - if (done) - SetPlanComplete(); else - m_should_stop = false; + 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; + // 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 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; } } } _______________________________________________ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits