2010-06-09 00:52:24 +08:00
|
|
|
//===-- ThreadPlan.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-05 08:20:57 +08:00
|
|
|
#include "lldb/lldb-python.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2010-11-12 03:26:09 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
|
|
|
#include "lldb/Core/State.h"
|
2010-09-04 01:10:42 +08:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
|
|
|
#include "lldb/Target/Thread.h"
|
2010-11-12 03:26:09 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// ThreadPlan constructor
|
|
|
|
//----------------------------------------------------------------------
|
2010-06-19 12:45:32 +08:00
|
|
|
ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote) :
|
2010-07-16 20:32:33 +08:00
|
|
|
m_thread (thread),
|
|
|
|
m_stop_vote (stop_vote),
|
|
|
|
m_run_vote (run_vote),
|
2010-06-19 12:45:32 +08:00
|
|
|
m_kind (kind),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_name (name),
|
|
|
|
m_plan_complete_mutex (Mutex::eMutexTypeRecursive),
|
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
|
|
|
m_cached_plan_explains_stop (eLazyBoolCalculate),
|
2010-07-16 20:32:33 +08:00
|
|
|
m_plan_complete (false),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_plan_private (false),
|
2012-05-04 05:19:36 +08:00
|
|
|
m_okay_to_discard (true),
|
2012-05-02 02:38:37 +08:00
|
|
|
m_is_master_plan (false),
|
|
|
|
m_plan_succeeded(true)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SetID (GetNextID());
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ThreadPlan::~ThreadPlan()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
bool
|
|
|
|
ThreadPlan::PlanExplainsStop (Event *event_ptr)
|
|
|
|
{
|
|
|
|
if (m_cached_plan_explains_stop == eLazyBoolCalculate)
|
|
|
|
{
|
|
|
|
bool actual_value = DoPlanExplainsStop(event_ptr);
|
|
|
|
m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo;
|
|
|
|
return actual_value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_cached_plan_explains_stop == eLazyBoolYes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
ThreadPlan::IsPlanComplete ()
|
|
|
|
{
|
2010-07-14 08:18:15 +08:00
|
|
|
Mutex::Locker locker(m_plan_complete_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_plan_complete;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-02 02:38:37 +08:00
|
|
|
ThreadPlan::SetPlanComplete (bool success)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-14 08:18:15 +08:00
|
|
|
Mutex::Locker locker(m_plan_complete_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
m_plan_complete = true;
|
2012-05-02 02:38:37 +08:00
|
|
|
m_plan_succeeded = success;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlan::MischiefManaged ()
|
|
|
|
{
|
2010-07-14 08:18:15 +08:00
|
|
|
Mutex::Locker locker(m_plan_complete_mutex);
|
2012-05-10 09:35:39 +08:00
|
|
|
// Mark the plan is complete, but don't override the success flag.
|
2010-06-09 00:52:24 +08:00
|
|
|
m_plan_complete = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vote
|
|
|
|
ThreadPlan::ShouldReportStop (Event *event_ptr)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-09-04 01:10:42 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_stop_vote == eVoteNoOpinion)
|
|
|
|
{
|
|
|
|
ThreadPlan *prev_plan = GetPreviousPlan ();
|
|
|
|
if (prev_plan)
|
2010-09-04 01:10:42 +08:00
|
|
|
{
|
|
|
|
Vote prev_vote = prev_plan->ShouldReportStop (event_ptr);
|
|
|
|
if (log)
|
2012-03-01 08:50:50 +08:00
|
|
|
log->Printf ("ThreadPlan::ShouldReportStop() returning previous thread plan vote: %s",
|
|
|
|
GetVoteAsCString (prev_vote));
|
2010-09-04 01:10:42 +08:00
|
|
|
return prev_vote;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-04 01:10:42 +08:00
|
|
|
if (log)
|
2010-09-04 06:45:01 +08:00
|
|
|
log->Printf ("ThreadPlan::ShouldReportStop() returning vote: %s", GetVoteAsCString (m_stop_vote));
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_stop_vote;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vote
|
|
|
|
ThreadPlan::ShouldReportRun (Event *event_ptr)
|
|
|
|
{
|
|
|
|
if (m_run_vote == eVoteNoOpinion)
|
|
|
|
{
|
|
|
|
ThreadPlan *prev_plan = GetPreviousPlan ();
|
|
|
|
if (prev_plan)
|
|
|
|
return prev_plan->ShouldReportRun (event_ptr);
|
|
|
|
}
|
|
|
|
return m_run_vote;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlan::StopOthers ()
|
|
|
|
{
|
|
|
|
ThreadPlan *prev_plan;
|
|
|
|
prev_plan = GetPreviousPlan ();
|
|
|
|
if (prev_plan == NULL)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return prev_plan->StopOthers();
|
|
|
|
}
|
|
|
|
|
2010-11-30 10:22:11 +08:00
|
|
|
void
|
|
|
|
ThreadPlan::SetStopOthers (bool new_value)
|
|
|
|
{
|
|
|
|
// SetStopOthers doesn't work up the hierarchy. You have to set the
|
|
|
|
// explicit ThreadPlan you want to affect.
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
ThreadPlan::WillResume (StateType resume_state, bool current_plan)
|
|
|
|
{
|
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
|
|
|
m_cached_plan_explains_stop = eLazyBoolCalculate;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (current_plan)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-09-04 01:10:42 +08:00
|
|
|
{
|
2011-01-07 06:15:06 +08:00
|
|
|
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
2010-09-04 01:10:42 +08:00
|
|
|
addr_t pc = reg_ctx->GetPC();
|
|
|
|
addr_t sp = reg_ctx->GetSP();
|
|
|
|
addr_t fp = reg_ctx->GetFP();
|
2013-06-22 08:27:45 +08:00
|
|
|
log->Printf("%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64 ", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
|
2012-03-01 08:50:50 +08:00
|
|
|
"plan = '%s', state = %s, stop others = %d",
|
2010-09-04 06:45:01 +08:00
|
|
|
__FUNCTION__,
|
2013-06-22 08:27:45 +08:00
|
|
|
m_thread.GetIndexID(),
|
|
|
|
&m_thread,
|
2010-09-04 01:10:42 +08:00
|
|
|
m_thread.GetID(),
|
|
|
|
(uint64_t)pc,
|
|
|
|
(uint64_t)sp,
|
|
|
|
(uint64_t)fp,
|
|
|
|
m_name.c_str(),
|
|
|
|
StateAsCString(resume_state),
|
|
|
|
StopOthers());
|
|
|
|
}
|
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
|
|
|
return DoWillResume (resume_state, current_plan);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::user_id_t
|
|
|
|
ThreadPlan::GetNextID()
|
|
|
|
{
|
|
|
|
static uint32_t g_nextPlanID = 0;
|
|
|
|
return ++g_nextPlanID;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThreadPlan::DidPush()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThreadPlan::WillPop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlan::OkayToDiscard()
|
|
|
|
{
|
|
|
|
if (!IsMasterPlan())
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return m_okay_to_discard;
|
|
|
|
}
|
|
|
|
|
2010-11-12 03:26:09 +08:00
|
|
|
lldb::StateType
|
|
|
|
ThreadPlan::RunState ()
|
|
|
|
{
|
|
|
|
if (m_tracer_sp && m_tracer_sp->TracingEnabled() && m_tracer_sp->SingleStepEnabled())
|
|
|
|
return eStateStepping;
|
|
|
|
else
|
|
|
|
return GetPlanRunState();
|
|
|
|
}
|