Author: jingham Date: Fri May 6 18:44:10 2016 New Revision: 268823 URL: http://llvm.org/viewvc/llvm-project?rev=268823&view=rev Log: Fix the way the ShouldStopHere checker handles the general case of "stepping through line 0 code". That's good 'cause it means all the different kinds of source line stepping won't leave user in the middle of compiler implementation code or code inlined from odd places, etc. But it turns out that the compiler also marks functions it MIGHT inline as all being of line 0. That would mean we single step through this code instead of just stepping out. That is both inefficient, and more error prone 'cause these little nuggets tend to be bits of hand-written assembly and the like and are hard to step through.
This change just checks and if the entire function is marked with line 0, we step out rather than step through. <rdar://problem/25966460> Modified: lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp Modified: lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp?rev=268823&r1=268822&r2=268823&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp Fri May 6 18:44:10 2016 @@ -11,10 +11,11 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Log.h" +#include "lldb/Symbol/Symbol.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanShouldStopHere.h" -#include "lldb/Core/Log.h" using namespace lldb; using namespace lldb_private; @@ -113,19 +114,45 @@ ThreadPlanShouldStopHere::DefaultStepFro ThreadPlanSP return_plan_sp; // If we are stepping through code at line number 0, then we need to step over this range. Otherwise // we will step out. + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get(); if (!frame) return return_plan_sp; SymbolContext sc; sc = frame->GetSymbolContext (eSymbolContextLineEntry); + sc = frame->GetSymbolContext (eSymbolContextLineEntry|eSymbolContextSymbol); if (sc.line_entry.line == 0) { AddressRange range = sc.line_entry.range; - return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOverRange(false, - range, - sc, - eOnlyDuringStepping, - eLazyBoolNo); + + // If the whole function is marked line 0 just step out, that's easier & faster than continuing + // to step through it. + bool just_step_out = false; + if (sc.symbol && sc.symbol->ValueIsAddress()) + { + Address symbol_end = sc.symbol->GetAddress(); + symbol_end.Slide(sc.symbol->GetByteSize() - 1); + if (range.ContainsFileAddress(sc.symbol->GetAddress()) && range.ContainsFileAddress(symbol_end)) + { + if (log) + log->Printf("Stopped in a function with only line 0 lines, just stepping out."); + just_step_out = true; + } + } + if (!just_step_out) + { + if (log) + log->Printf ("ThreadPlanShouldStopHere::DefaultStepFromHereCallback Queueing StepInRange plan to step through line 0 code."); + + return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepInRange(false, + range, + sc, + NULL, + eOnlyDuringStepping, + eLazyBoolCalculate, + eLazyBoolNo); + } } if (!return_plan_sp) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits