2010-06-09 00:52:24 +08:00
|
|
|
//===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Target/ThreadPlanStepOverRange.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
|
|
|
|
#include "lldb/lldb-private-log.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2011-02-16 05:59:32 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepOut.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepThrough.h"
|
|
|
|
|
|
|
|
using namespace lldb_private;
|
2010-11-06 09:53:30 +08:00
|
|
|
using namespace lldb;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// ThreadPlanStepOverRange: Step through a stack range, either stepping over or into
|
|
|
|
// based on the value of \a type.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ThreadPlanStepOverRange::ThreadPlanStepOverRange
|
|
|
|
(
|
|
|
|
Thread &thread,
|
|
|
|
const AddressRange &range,
|
|
|
|
const SymbolContext &addr_context,
|
|
|
|
lldb::RunMode stop_others,
|
|
|
|
bool okay_to_discard
|
|
|
|
) :
|
2010-06-19 12:45:32 +08:00
|
|
|
ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-04-10 06:37:39 +08:00
|
|
|
// Step over range plans can be master plans, since you could hit a breakpoint while stepping over, step around
|
|
|
|
// a bit, then continue to finish up the step over.
|
|
|
|
SetIsMasterPlan (true);
|
2010-06-09 00:52:24 +08:00
|
|
|
SetOkayToDiscard (okay_to_discard);
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlanStepOverRange::~ThreadPlanStepOverRange ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level)
|
|
|
|
{
|
|
|
|
if (level == lldb::eDescriptionLevelBrief)
|
|
|
|
s->Printf("step over");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->Printf ("stepping through range (stepping over functions): ");
|
2011-10-15 08:24:48 +08:00
|
|
|
DumpRanges(s);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString s;
|
2011-02-16 05:59:32 +08:00
|
|
|
s.Address (m_thread.GetRegisterContext()->GetPC(),
|
2012-02-21 08:09:25 +08:00
|
|
|
m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
|
2010-06-09 00:52:24 +08:00
|
|
|
log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're out of the range but in the same frame or in our caller's frame
|
|
|
|
// then we should stop.
|
|
|
|
// When stepping out we only step if we are forcing running one thread.
|
|
|
|
bool stop_others;
|
|
|
|
if (m_stop_others == lldb::eOnlyThisThread)
|
|
|
|
stop_others = true;
|
|
|
|
else
|
|
|
|
stop_others = false;
|
|
|
|
|
|
|
|
ThreadPlan* new_plan = NULL;
|
2012-03-01 08:50:50 +08:00
|
|
|
|
|
|
|
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
|
|
|
|
|
|
|
|
if (frame_order == eFrameCompareOlder)
|
2010-11-05 08:18:21 +08:00
|
|
|
{
|
|
|
|
// If we're in an older frame then we should stop.
|
|
|
|
//
|
|
|
|
// A caveat to this is if we think the frame is older but we're actually in a trampoline.
|
|
|
|
// I'm going to make the assumption that you wouldn't RETURN to a trampoline. So if we are
|
|
|
|
// in a trampoline we think the frame is older because the trampoline confused the backtracer.
|
|
|
|
// As below, we step through first, and then try to figure out how to get back out again.
|
|
|
|
|
|
|
|
new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
|
|
|
|
|
|
|
|
if (new_plan != NULL && log)
|
|
|
|
log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
|
|
|
|
}
|
2012-03-01 08:50:50 +08:00
|
|
|
else if (frame_order == eFrameCompareYounger)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-03-01 08:50:50 +08:00
|
|
|
// Make sure we really are in a new frame. Do that by unwinding and seeing if the
|
|
|
|
// start function really is our start function...
|
|
|
|
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);
|
|
|
|
if (older_context == m_addr_context)
|
|
|
|
{
|
|
|
|
new_plan = m_thread.QueueThreadPlanForStepOut (false,
|
|
|
|
NULL,
|
|
|
|
true,
|
|
|
|
stop_others,
|
|
|
|
eVoteNo,
|
|
|
|
eVoteNoOpinion,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2012-03-09 12:10:47 +08:00
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-03-09 12:10:47 +08:00
|
|
|
// If we're still in the range, keep going.
|
|
|
|
if (InRange())
|
|
|
|
{
|
|
|
|
SetNextBranchBreakpoint();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!InSymbol())
|
|
|
|
{
|
|
|
|
// This one is a little tricky. Sometimes we may be in a stub or something similar,
|
|
|
|
// in which case we need to get out of there. But if we are in a stub then it's
|
|
|
|
// likely going to be hard to get out from here. It is probably easiest to step into the
|
|
|
|
// stub, and then it will be straight-forward to step out.
|
|
|
|
new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-03-09 12:10:47 +08:00
|
|
|
// If we get to this point, we're not going to use a previously set "next branch" breakpoint, so delete it:
|
|
|
|
ClearNextBranchBreakpoint();
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (new_plan == NULL)
|
|
|
|
m_no_more_plans = true;
|
|
|
|
else
|
|
|
|
m_no_more_plans = false;
|
|
|
|
|
|
|
|
if (new_plan == NULL)
|
|
|
|
{
|
|
|
|
// For efficiencies sake, we know we're done here so we don't have to do this
|
|
|
|
// calculation again in MischiefManaged.
|
|
|
|
SetPlanComplete();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|