2010-06-09 00:52:24 +08:00
|
|
|
//===-- ThreadPlanBase.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/ThreadPlanBase.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
//
|
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointSite.h"
|
|
|
|
#include "lldb/Breakpoint/StoppointCallbackContext.h"
|
2011-02-08 13:20:59 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// ThreadPlanBase: This one always stops, and never has anything particular
|
|
|
|
// to do.
|
|
|
|
// FIXME: The "signal handling" policies should probably go here.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ThreadPlanBase::ThreadPlanBase(Thread &thread)
|
|
|
|
: ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes,
|
|
|
|
eVoteNoOpinion) {
|
|
|
|
// Set the tracer to a default tracer.
|
|
|
|
// FIXME: need to add a thread settings variable to pix various tracers...
|
2010-11-18 10:47:07 +08:00
|
|
|
#define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
|
|
|
|
|
|
|
|
#ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
|
2016-09-07 04:57:50 +08:00
|
|
|
ThreadPlanTracerSP new_tracer_sp(new ThreadPlanAssemblyTracer(m_thread));
|
2010-11-18 10:47:07 +08:00
|
|
|
#else
|
2016-09-07 04:57:50 +08:00
|
|
|
ThreadPlanTracerSP new_tracer_sp(new ThreadPlanTracer(m_thread));
|
2010-11-18 10:47:07 +08:00
|
|
|
#endif
|
2016-09-07 04:57:50 +08:00
|
|
|
new_tracer_sp->EnableTracing(m_thread.GetTraceEnabledState());
|
|
|
|
SetThreadPlanTracer(new_tracer_sp);
|
|
|
|
SetIsMasterPlan(true);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ThreadPlanBase::~ThreadPlanBase() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void ThreadPlanBase::GetDescription(Stream *s, lldb::DescriptionLevel level) {
|
|
|
|
s->Printf("Base thread plan.");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::ValidatePlan(Stream *error) { return true; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::DoPlanExplainsStop(Event *event_ptr) {
|
|
|
|
// The base plan should defer to its tracer, since by default it
|
|
|
|
// always handles the stop.
|
|
|
|
if (TracerExplainsStop())
|
|
|
|
return false;
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
Vote ThreadPlanBase::ShouldReportStop(Event *event_ptr) {
|
|
|
|
StopInfoSP stop_info_sp = m_thread.GetStopInfo();
|
|
|
|
if (stop_info_sp) {
|
|
|
|
bool should_notify = stop_info_sp->ShouldNotify(event_ptr);
|
|
|
|
if (should_notify)
|
|
|
|
return eVoteYes;
|
2010-11-12 03:26:09 +08:00
|
|
|
else
|
2016-09-07 04:57:50 +08:00
|
|
|
return eVoteNoOpinion;
|
|
|
|
} else
|
|
|
|
return eVoteNoOpinion;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
|
|
|
|
m_stop_vote = eVoteYes;
|
|
|
|
m_run_vote = eVoteYes;
|
|
|
|
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
|
|
|
|
|
|
|
|
StopInfoSP stop_info_sp = GetPrivateStopInfo();
|
|
|
|
if (stop_info_sp) {
|
|
|
|
StopReason reason = stop_info_sp->GetStopReason();
|
|
|
|
switch (reason) {
|
|
|
|
case eStopReasonInvalid:
|
|
|
|
case eStopReasonNone:
|
|
|
|
// This
|
|
|
|
m_run_vote = eVoteNoOpinion;
|
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case eStopReasonBreakpoint:
|
|
|
|
case eStopReasonWatchpoint:
|
|
|
|
if (stop_info_sp->ShouldStopSynchronous(event_ptr)) {
|
|
|
|
// If we are going to stop for a breakpoint, then unship the other plans
|
|
|
|
// at this point. Don't force the discard, however, so Master plans can
|
|
|
|
// stay
|
|
|
|
// in place if they want to.
|
|
|
|
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 we aren't going to stop at this breakpoint, and it is internal,
|
|
|
|
// don't report this stop or the subsequent running event.
|
|
|
|
// Otherwise we will post the stopped & running, but the stopped event
|
|
|
|
// will get marked
|
|
|
|
// with "restarted" so the UI will know to wait and expect the consequent
|
|
|
|
// "running".
|
|
|
|
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;
|
|
|
|
|
|
|
|
// TODO: the break below was missing, was this intentional??? If so
|
|
|
|
// please mention it
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStopReasonException:
|
|
|
|
// If we crashed, discard thread plans and stop. Don't force the discard,
|
|
|
|
// however,
|
|
|
|
// since on rerun the target may clean up this exception and continue
|
|
|
|
// normally from there.
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
|
|
|
|
" (exception: %s)",
|
|
|
|
m_thread.GetID(), stop_info_sp->GetDescription());
|
|
|
|
m_thread.DiscardThreadPlans(false);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case eStopReasonExec:
|
|
|
|
// If we crashed, discard thread plans and stop. Don't force the discard,
|
|
|
|
// however,
|
|
|
|
// since on rerun the target may clean up this exception and continue
|
|
|
|
// normally from there.
|
|
|
|
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 eStopReasonThreadExiting:
|
|
|
|
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: %s)",
|
|
|
|
m_thread.GetID(), stop_info_sp->GetDescription());
|
|
|
|
m_thread.DiscardThreadPlans(false);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// We're not going to stop, but while we are here, let's figure out
|
|
|
|
// whether to report this.
|
|
|
|
if (stop_info_sp->ShouldNotify(event_ptr))
|
|
|
|
m_stop_vote = eVoteYes;
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
else
|
2016-09-07 04:57:50 +08:00
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
}
|
|
|
|
return false;
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
default:
|
|
|
|
return true;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
m_run_vote = eVoteNoOpinion;
|
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
// If there's no explicit reason to stop, then we will continue.
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::StopOthers() { return false; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
StateType ThreadPlanBase::GetPlanRunState() { return eStateRunning; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::WillStop() { return true; }
|
2011-01-24 14:34:17 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::DoWillResume(lldb::StateType resume_state,
|
|
|
|
bool current_plan) {
|
|
|
|
// Reset these to the default values so we don't set them wrong, then not get
|
|
|
|
// asked
|
|
|
|
// for a while, then return the wrong answer.
|
|
|
|
m_run_vote = eVoteNoOpinion;
|
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-24 14:34:17 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// The base plan is never done.
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ThreadPlanBase::MischiefManaged() {
|
|
|
|
// The base plan is never done.
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|