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>

llvm-svn: 268823
This commit is contained in:
Jim Ingham 2016-05-06 23:44:10 +00:00
parent 1ed1aeaa94
commit 9b8eb155d8
1 changed files with 33 additions and 6 deletions

View File

@ -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::DefaultStepFromHereCallback (ThreadPlan *current_plan,
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)