ThreadPlanBase.cpp [plain text]
#include "lldb/Target/ThreadPlanBase.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
using namespace lldb;
using namespace lldb_private;
ThreadPlanBase::ThreadPlanBase (Thread &thread) :
ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes, eVoteNoOpinion)
{
#define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
#ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
ThreadPlanTracerSP new_tracer_sp (new ThreadPlanAssemblyTracer (m_thread));
#else
ThreadPlanTracerSP new_tracer_sp (new ThreadPlanTracer (m_thread));
#endif
new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
SetThreadPlanTracer(new_tracer_sp);
SetIsMasterPlan (true);
}
ThreadPlanBase::~ThreadPlanBase ()
{
}
void
ThreadPlanBase::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
s->Printf ("Base thread plan.");
}
bool
ThreadPlanBase::ValidatePlan (Stream *error)
{
return true;
}
bool
ThreadPlanBase::PlanExplainsStop ()
{
if (TracerExplainsStop())
return false;
else
return true;
}
bool
ThreadPlanBase::ShouldStop (Event *event_ptr)
{
m_stop_vote = eVoteYes;
m_run_vote = eVoteYes;
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 eStopReasonInvalid:
case eStopReasonNone:
m_run_vote = eVoteNoOpinion;
m_stop_vote = eVoteNo;
return false;
case eStopReasonBreakpoint:
case eStopReasonWatchpoint:
if (stop_info_sp->ShouldStop(event_ptr))
{
if (log)
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (breakpoint hit.)", m_thread.GetID());
m_thread.DiscardThreadPlans(false);
return true;
}
if (stop_info_sp->ShouldNotify (event_ptr))
{
m_stop_vote = eVoteYes;
m_run_vote = eVoteYes;
}
else
{
m_stop_vote = eVoteNo;
m_run_vote = eVoteNo;
}
return false;
break;
case eStopReasonException:
if (log)
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (exception.)", m_thread.GetID());
m_thread.DiscardThreadPlans(false);
return true;
case eStopReasonExec:
if (log)
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (exec.)", m_thread.GetID());
m_thread.DiscardThreadPlans(false);
return true;
case eStopReasonSignal:
if (stop_info_sp->ShouldStop(event_ptr))
{
if (log)
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (signal.)", m_thread.GetID());
m_thread.DiscardThreadPlans(false);
return true;
}
else
{
if (stop_info_sp->ShouldNotify(event_ptr))
m_stop_vote = eVoteYes;
else
m_stop_vote = eVoteNo;
}
return false;
default:
return true;
}
}
else
{
m_run_vote = eVoteNoOpinion;
m_stop_vote = eVoteNo;
}
return false;
}
bool
ThreadPlanBase::StopOthers ()
{
return false;
}
StateType
ThreadPlanBase::GetPlanRunState ()
{
return eStateRunning;
}
bool
ThreadPlanBase::WillStop ()
{
return true;
}
bool
ThreadPlanBase::WillResume (lldb::StateType resume_state, bool current_plan)
{
m_run_vote = eVoteNoOpinion;
m_stop_vote = eVoteNo;
return true;
}
bool
ThreadPlanBase::MischiefManaged ()
{
return false;
}