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/StoppointCallbackContext.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointSite.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
#include "lldb/Breakpoint/Breakpoint.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.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ThreadPlanBase::ThreadPlanBase (Thread &thread) :
|
2010-06-19 12:45:32 +08:00
|
|
|
ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes, eVoteNoOpinion)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-12 03:26:09 +08:00
|
|
|
// Set the tracer to a default tracer.
|
2010-11-18 10:47:07 +08:00
|
|
|
// FIXME: need to add a thread settings variable to pix various tracers...
|
|
|
|
#define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
|
|
|
|
|
|
|
|
#ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
|
|
|
|
ThreadPlanTracerSP new_tracer_sp (new ThreadPlanAssemblyTracer (m_thread));
|
|
|
|
#else
|
2010-11-12 03:26:09 +08:00
|
|
|
ThreadPlanTracerSP new_tracer_sp (new ThreadPlanTracer (m_thread));
|
2010-11-18 10:47:07 +08:00
|
|
|
#endif
|
2010-11-12 03:26:09 +08:00
|
|
|
new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
|
|
|
|
SetThreadPlanTracer(new_tracer_sp);
|
2012-04-10 06:37:39 +08:00
|
|
|
SetIsMasterPlan (true);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlanBase::~ThreadPlanBase ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThreadPlanBase::GetDescription (Stream *s, lldb::DescriptionLevel level)
|
|
|
|
{
|
|
|
|
s->Printf ("Base thread plan.");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanBase::ValidatePlan (Stream *error)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
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
|
|
|
ThreadPlanBase::DoPlanExplainsStop (Event *event_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-12 03:26:09 +08:00
|
|
|
// The base plan should defer to its tracer, since by default it
|
|
|
|
// always handles the stop.
|
|
|
|
if (TracerExplainsStop())
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
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;
|
|
|
|
else
|
|
|
|
return eVoteNoOpinion;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return eVoteNoOpinion;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
ThreadPlanBase::ShouldStop (Event *event_ptr)
|
|
|
|
{
|
|
|
|
m_stop_vote = eVoteYes;
|
|
|
|
m_run_vote = eVoteYes;
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2011-02-08 13:20:59 +08:00
|
|
|
|
2013-06-04 09:40:51 +08:00
|
|
|
StopInfoSP stop_info_sp = GetPrivateStopInfo ();
|
2010-10-20 08:39:53 +08:00
|
|
|
if (stop_info_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-06-04 09:40:51 +08:00
|
|
|
StopReason reason = stop_info_sp->GetStopReason ();
|
2010-06-09 00:52:24 +08:00
|
|
|
switch (reason)
|
|
|
|
{
|
2010-08-04 09:40:35 +08:00
|
|
|
case eStopReasonInvalid:
|
|
|
|
case eStopReasonNone:
|
2011-01-24 14:34:17 +08:00
|
|
|
// This
|
|
|
|
m_run_vote = eVoteNoOpinion;
|
2010-08-04 09:40:35 +08:00
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case eStopReasonBreakpoint:
|
2011-09-22 06:47:15 +08:00
|
|
|
case eStopReasonWatchpoint:
|
2013-02-23 05:23:43 +08:00
|
|
|
if (stop_info_sp->ShouldStopSynchronous(event_ptr))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-08-04 09:40:35 +08:00
|
|
|
// 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.
|
2011-02-08 13:20:59 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (breakpoint hit.)", m_thread.GetID());
|
2010-08-04 09:40:35 +08:00
|
|
|
m_thread.DiscardThreadPlans(false);
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
// 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".
|
2010-10-20 08:39:53 +08:00
|
|
|
if (stop_info_sp->ShouldNotify (event_ptr))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-08-04 09:40:35 +08:00
|
|
|
m_stop_vote = eVoteYes;
|
|
|
|
m_run_vote = eVoteYes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
m_run_vote = eVoteNo;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
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.
|
2011-02-08 13:20:59 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (exception.)", m_thread.GetID());
|
2010-08-04 09:40:35 +08:00
|
|
|
m_thread.DiscardThreadPlans(false);
|
|
|
|
return true;
|
|
|
|
|
2012-12-05 08:16:59 +08:00
|
|
|
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;
|
2012-12-21 07:08:03 +08:00
|
|
|
|
|
|
|
case eStopReasonThreadExiting:
|
2010-08-04 09:40:35 +08:00
|
|
|
case eStopReasonSignal:
|
2010-10-20 08:39:53 +08:00
|
|
|
if (stop_info_sp->ShouldStop(event_ptr))
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2011-02-08 13:20:59 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64 " (signal.)", m_thread.GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
m_thread.DiscardThreadPlans(false);
|
|
|
|
return true;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-08-04 09:40:35 +08:00
|
|
|
// We're not going to stop, but while we are here, let's figure out
|
|
|
|
// whether to report this.
|
2010-10-20 08:39:53 +08:00
|
|
|
if (stop_info_sp->ShouldNotify(event_ptr))
|
2010-08-04 09:40:35 +08:00
|
|
|
m_stop_vote = eVoteYes;
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2010-08-04 09:40:35 +08:00
|
|
|
m_stop_vote = eVoteNo;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
else
|
|
|
|
{
|
2011-01-24 14:34:17 +08:00
|
|
|
m_run_vote = eVoteNoOpinion;
|
2010-08-04 09:40:35 +08:00
|
|
|
m_stop_vote = eVoteNo;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// If there's no explicit reason to stop, then we will continue.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanBase::StopOthers ()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
StateType
|
2010-11-12 03:26:09 +08:00
|
|
|
ThreadPlanBase::GetPlanRunState ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return eStateRunning;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanBase::WillStop ()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-24 14:34:17 +08:00
|
|
|
bool
|
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
|
|
|
ThreadPlanBase::DoWillResume (lldb::StateType resume_state, bool current_plan)
|
2011-01-24 14:34:17 +08:00
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// The base plan is never done.
|
|
|
|
bool
|
|
|
|
ThreadPlanBase::MischiefManaged ()
|
|
|
|
{
|
|
|
|
// The base plan is never done.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|