ThreadPlanStepOverRange.cpp [plain text]
#include "lldb/Target/ThreadPlanStepOverRange.h"
#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"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
using namespace lldb_private;
using namespace lldb;
ThreadPlanStepOverRange::ThreadPlanStepOverRange
(
Thread &thread,
const AddressRange &range,
const SymbolContext &addr_context,
lldb::RunMode stop_others
) :
ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others)
{
}
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): ");
DumpRanges(s);
}
}
bool
ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
if (log)
{
StreamString s;
s.Address (m_thread.GetRegisterContext()->GetPC(),
m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
}
bool stop_others;
if (m_stop_others == lldb::eOnlyThisThread)
stop_others = true;
else
stop_others = false;
ThreadPlan* new_plan = NULL;
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
if (frame_order == eFrameCompareOlder)
{
new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
if (new_plan != NULL && log)
log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
}
else if (frame_order == eFrameCompareYounger)
{
StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1);
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 (m_stack_id, false, stop_others);
}
}
}
else
{
if (InRange())
{
SetNextBranchBreakpoint();
return false;
}
if (!InSymbol())
{
new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
}
}
ClearNextBranchBreakpoint();
if (new_plan == NULL)
m_no_more_plans = true;
else
m_no_more_plans = false;
if (new_plan == NULL)
{
SetPlanComplete();
return true;
}
else
return false;
}
bool
ThreadPlanStepOverRange::PlanExplainsStop ()
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
StopInfoSP stop_info_sp = GetPrivateStopReason();
if (stop_info_sp)
{
StopReason reason = stop_info_sp->GetStopReason();
switch (reason)
{
case eStopReasonBreakpoint:
if (NextRangeBreakpointExplainsStop(stop_info_sp))
return true;
else
return false;
break;
case eStopReasonWatchpoint:
case eStopReasonSignal:
case eStopReasonException:
if (log)
log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
return false;
break;
default:
break;
}
}
return true;
}