2010-06-09 00:52:24 +08:00
|
|
|
//===-- Thread.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/lldb-private-log.h"
|
2010-06-16 10:00:15 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
2010-10-04 09:05:56 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2013-05-02 05:54:04 +08:00
|
|
|
#include "lldb/Core/State.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamString.h"
|
2010-09-08 11:14:33 +08:00
|
|
|
#include "lldb/Core/RegularExpression.h"
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2012-09-27 09:15:29 +08:00
|
|
|
#include "lldb/Symbol/Function.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/DynamicLoader.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
2010-09-28 09:25:32 +08:00
|
|
|
#include "lldb/Target/ObjCLanguageRuntime.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
2010-07-24 00:45:51 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
#include "lldb/Target/ThreadPlanCallFunction.h"
|
|
|
|
#include "lldb/Target/ThreadPlanBase.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepInstruction.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepOut.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepOverBreakpoint.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepThrough.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepInRange.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepOverRange.h"
|
|
|
|
#include "lldb/Target/ThreadPlanRunToAddress.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepUntil.h"
|
2010-06-16 10:00:15 +08:00
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2010-08-12 10:14:28 +08:00
|
|
|
#include "lldb/Target/Unwind.h"
|
2011-08-22 10:49:39 +08:00
|
|
|
#include "Plugins/Process/Utility/UnwindLLDB.h"
|
|
|
|
#include "UnwindMacOSXFrameBackchain.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
|
|
|
|
const ThreadPropertiesSP &
|
|
|
|
Thread::GetGlobalProperties()
|
|
|
|
{
|
|
|
|
static ThreadPropertiesSP g_settings_sp;
|
|
|
|
if (!g_settings_sp)
|
|
|
|
g_settings_sp.reset (new ThreadProperties (true));
|
|
|
|
return g_settings_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PropertyDefinition
|
|
|
|
g_properties[] =
|
|
|
|
{
|
|
|
|
{ "step-avoid-regexp", OptionValue::eTypeRegex , true , REG_EXTENDED, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
|
|
|
|
{ "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
|
|
|
|
{ NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ePropertyStepAvoidRegex,
|
|
|
|
ePropertyEnableThreadTrace
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ThreadOptionValueProperties : public OptionValueProperties
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ThreadOptionValueProperties (const ConstString &name) :
|
|
|
|
OptionValueProperties (name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// This constructor is used when creating ThreadOptionValueProperties when it
|
|
|
|
// is part of a new lldb_private::Thread instance. It will copy all current
|
|
|
|
// global property values as needed
|
|
|
|
ThreadOptionValueProperties (ThreadProperties *global_properties) :
|
2012-08-23 02:39:03 +08:00
|
|
|
OptionValueProperties(*global_properties->GetValueProperties())
|
2012-08-23 01:17:09 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const Property *
|
|
|
|
GetPropertyAtIndex (const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
|
|
|
|
{
|
|
|
|
// When gettings the value for a key from the thread options, we will always
|
|
|
|
// try and grab the setting from the current thread if there is one. Else we just
|
|
|
|
// use the one from this instance.
|
|
|
|
if (exe_ctx)
|
|
|
|
{
|
|
|
|
Thread *thread = exe_ctx->GetThreadPtr();
|
|
|
|
if (thread)
|
|
|
|
{
|
|
|
|
ThreadOptionValueProperties *instance_properties = static_cast<ThreadOptionValueProperties *>(thread->GetValueProperties().get());
|
|
|
|
if (this != instance_properties)
|
|
|
|
return instance_properties->ProtectedGetPropertyAtIndex (idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ProtectedGetPropertyAtIndex (idx);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThreadProperties::ThreadProperties (bool is_global) :
|
|
|
|
Properties ()
|
|
|
|
{
|
|
|
|
if (is_global)
|
|
|
|
{
|
|
|
|
m_collection_sp.reset (new ThreadOptionValueProperties(ConstString("thread")));
|
|
|
|
m_collection_sp->Initialize(g_properties);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_collection_sp.reset (new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadProperties::~ThreadProperties()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const RegularExpression *
|
|
|
|
ThreadProperties::GetSymbolsToAvoidRegexp()
|
|
|
|
{
|
|
|
|
const uint32_t idx = ePropertyStepAvoidRegex;
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex (NULL, idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadProperties::GetTraceEnabledState() const
|
|
|
|
{
|
|
|
|
const uint32_t idx = ePropertyEnableThreadTrace;
|
|
|
|
return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
|
|
|
|
}
|
|
|
|
|
2012-10-11 02:32:14 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Thread Event Data
|
|
|
|
//------------------------------------------------------------------
|
2012-08-23 01:17:09 +08:00
|
|
|
|
2012-10-11 02:32:14 +08:00
|
|
|
|
|
|
|
const ConstString &
|
|
|
|
Thread::ThreadEventData::GetFlavorString ()
|
|
|
|
{
|
|
|
|
static ConstString g_flavor ("Thread::ThreadEventData");
|
|
|
|
return g_flavor;
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread::ThreadEventData::ThreadEventData (const lldb::ThreadSP thread_sp) :
|
|
|
|
m_thread_sp (thread_sp),
|
|
|
|
m_stack_id ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread::ThreadEventData::ThreadEventData (const lldb::ThreadSP thread_sp, const StackID &stack_id) :
|
|
|
|
m_thread_sp (thread_sp),
|
|
|
|
m_stack_id (stack_id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread::ThreadEventData::ThreadEventData () :
|
|
|
|
m_thread_sp (),
|
|
|
|
m_stack_id ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread::ThreadEventData::~ThreadEventData ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::ThreadEventData::Dump (Stream *s) const
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const Thread::ThreadEventData *
|
|
|
|
Thread::ThreadEventData::GetEventDataFromEvent (const Event *event_ptr)
|
|
|
|
{
|
|
|
|
if (event_ptr)
|
|
|
|
{
|
|
|
|
const EventData *event_data = event_ptr->GetData();
|
|
|
|
if (event_data && event_data->GetFlavor() == ThreadEventData::GetFlavorString())
|
|
|
|
return static_cast <const ThreadEventData *> (event_ptr->GetData());
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadSP
|
|
|
|
Thread::ThreadEventData::GetThreadFromEvent (const Event *event_ptr)
|
|
|
|
{
|
|
|
|
ThreadSP thread_sp;
|
|
|
|
const ThreadEventData *event_data = GetEventDataFromEvent (event_ptr);
|
|
|
|
if (event_data)
|
|
|
|
thread_sp = event_data->GetThread();
|
|
|
|
return thread_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
StackID
|
|
|
|
Thread::ThreadEventData::GetStackIDFromEvent (const Event *event_ptr)
|
|
|
|
{
|
|
|
|
StackID stack_id;
|
|
|
|
const ThreadEventData *event_data = GetEventDataFromEvent (event_ptr);
|
|
|
|
if (event_data)
|
|
|
|
stack_id = event_data->GetStackID();
|
|
|
|
return stack_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
StackFrameSP
|
|
|
|
Thread::ThreadEventData::GetStackFrameFromEvent (const Event *event_ptr)
|
|
|
|
{
|
|
|
|
const ThreadEventData *event_data = GetEventDataFromEvent (event_ptr);
|
|
|
|
StackFrameSP frame_sp;
|
|
|
|
if (event_data)
|
|
|
|
{
|
|
|
|
ThreadSP thread_sp = event_data->GetThread();
|
|
|
|
if (thread_sp)
|
|
|
|
{
|
|
|
|
frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID (event_data->GetStackID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return frame_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Thread class
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
ConstString &
|
|
|
|
Thread::GetStaticBroadcasterClass ()
|
|
|
|
{
|
|
|
|
static ConstString class_name ("lldb.thread");
|
|
|
|
return class_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread::Thread (Process &process, lldb::tid_t tid) :
|
2012-08-23 01:17:09 +08:00
|
|
|
ThreadProperties (false),
|
2010-06-09 00:52:24 +08:00
|
|
|
UserID (tid),
|
2012-10-11 02:32:14 +08:00
|
|
|
Broadcaster(&process.GetTarget().GetDebugger(), Thread::GetStaticBroadcasterClass().AsCString()),
|
|
|
|
m_process_wp (process.shared_from_this()),
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_sp (),
|
|
|
|
m_stop_info_stop_id (0),
|
2013-01-09 06:10:01 +08:00
|
|
|
m_index_id (process.GetNextThreadIndexID(tid)),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_reg_context_sp (),
|
|
|
|
m_state (eStateUnloaded),
|
2010-08-25 08:35:26 +08:00
|
|
|
m_state_mutex (Mutex::eMutexTypeRecursive),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_plan_stack (),
|
|
|
|
m_completed_plan_stack(),
|
2012-03-29 09:41:38 +08:00
|
|
|
m_frame_mutex (Mutex::eMutexTypeRecursive),
|
2011-08-13 05:40:01 +08:00
|
|
|
m_curr_frames_sp (),
|
|
|
|
m_prev_frames_sp (),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
|
2010-08-12 10:14:28 +08:00
|
|
|
m_resume_state (eStateRunning),
|
2012-02-01 07:09:20 +08:00
|
|
|
m_temporary_resume_state (eStateRunning),
|
2010-11-18 10:47:07 +08:00
|
|
|
m_unwinder_ap (),
|
2011-01-20 10:03:18 +08:00
|
|
|
m_destroy_called (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
|
|
|
m_override_should_notify (eLazyBoolCalculate)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")", this, GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-10-11 02:32:14 +08:00
|
|
|
CheckInWithManager();
|
2010-06-09 00:52:24 +08:00
|
|
|
QueueFundamentalPlan(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Thread::~Thread()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")", this, GetID());
|
2010-11-18 10:47:07 +08:00
|
|
|
/// If you hit this assert, it means your derived class forgot to call DoDestroy in its destructor.
|
|
|
|
assert (m_destroy_called);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::DestroyThread ()
|
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
// Tell any plans on the plan stack that the thread is being destroyed since
|
|
|
|
// any active plans that have a thread go away in the middle of might need
|
|
|
|
// to do cleanup.
|
|
|
|
for (auto plan : m_plan_stack)
|
|
|
|
plan->ThreadDestroyed();
|
|
|
|
|
2012-10-30 04:52:08 +08:00
|
|
|
m_destroy_called = true;
|
2010-11-18 10:47:07 +08:00
|
|
|
m_plan_stack.clear();
|
|
|
|
m_discarded_plan_stack.clear();
|
|
|
|
m_completed_plan_stack.clear();
|
2013-07-30 08:23:06 +08:00
|
|
|
|
|
|
|
// Push a ThreadPlanNull on the plan stack. That way we can continue assuming that the
|
|
|
|
// plan stack is never empty, but if somebody errantly asks questions of a destroyed thread
|
|
|
|
// without checking first whether it is destroyed, they won't crash.
|
|
|
|
ThreadPlanSP null_plan_sp(new ThreadPlanNull (*this));
|
|
|
|
m_plan_stack.push_back (null_plan_sp);
|
|
|
|
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_sp.reset();
|
2012-10-30 04:52:08 +08:00
|
|
|
m_reg_context_sp.reset();
|
|
|
|
m_unwinder_ap.reset();
|
|
|
|
Mutex::Locker locker(m_frame_mutex);
|
|
|
|
m_curr_frames_sp.reset();
|
|
|
|
m_prev_frames_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-10-11 02:32:14 +08:00
|
|
|
void
|
|
|
|
Thread::BroadcastSelectedFrameChange(StackID &new_frame_id)
|
|
|
|
{
|
|
|
|
if (EventTypeHasListeners(eBroadcastBitSelectedFrameChanged))
|
|
|
|
BroadcastEvent(eBroadcastBitSelectedFrameChanged, new ThreadEventData (this->shared_from_this(), new_frame_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
Thread::SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast)
|
|
|
|
{
|
|
|
|
uint32_t ret_value = GetStackFrameList()->SetSelectedFrame(frame);
|
|
|
|
if (broadcast)
|
|
|
|
BroadcastSelectedFrameChange(frame->GetStackID());
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Thread::SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast)
|
|
|
|
{
|
|
|
|
StackFrameSP frame_sp(GetStackFrameList()->GetFrameAtIndex (frame_idx));
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
GetStackFrameList()->SetSelectedFrame(frame_sp.get());
|
|
|
|
if (broadcast)
|
|
|
|
BroadcastSelectedFrameChange(frame_sp->GetStackID());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
bool
|
|
|
|
Thread::SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_stream)
|
|
|
|
{
|
|
|
|
const bool broadcast = true;
|
|
|
|
bool success = SetSelectedFrameByIndex (frame_idx, broadcast);
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
StackFrameSP frame_sp = GetSelectedFrame();
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
bool already_shown = false;
|
|
|
|
SymbolContext frame_sc(frame_sp->GetSymbolContext(eSymbolContextLineEntry));
|
|
|
|
if (GetProcess()->GetTarget().GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0)
|
|
|
|
{
|
|
|
|
already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool show_frame_info = true;
|
|
|
|
bool show_source = !already_shown;
|
|
|
|
return frame_sp->GetStatus (output_stream, show_frame_info, show_source);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-11 02:32:14 +08:00
|
|
|
|
2010-10-20 08:39:53 +08:00
|
|
|
lldb::StopInfoSP
|
2010-08-04 09:40:35 +08:00
|
|
|
Thread::GetStopInfo ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-07-30 08:23:06 +08:00
|
|
|
if (m_destroy_called)
|
|
|
|
return m_stop_info_sp;
|
|
|
|
|
2010-10-20 08:39:53 +08:00
|
|
|
ThreadPlanSP plan_sp (GetCompletedPlan());
|
2013-05-08 02:35:34 +08:00
|
|
|
ProcessSP process_sp (GetProcess());
|
|
|
|
const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX;
|
2012-05-02 02:38:37 +08:00
|
|
|
if (plan_sp && plan_sp->PlanSucceeded())
|
2013-05-08 02:35:34 +08:00
|
|
|
{
|
2011-12-17 09:35:57 +08:00
|
|
|
return StopInfo::CreateStopReasonWithPlan (plan_sp, GetReturnValueObject());
|
2013-05-08 02:35:34 +08:00
|
|
|
}
|
2010-10-20 08:39:53 +08:00
|
|
|
else
|
2011-08-09 08:32:52 +08:00
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
if ((m_stop_info_stop_id == stop_id) || // Stop info is valid, just return what we have (even if empty)
|
|
|
|
(m_stop_info_sp && m_stop_info_sp->IsValid())) // Stop info is valid, just return what we have
|
2013-05-08 02:35:34 +08:00
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
return m_stop_info_sp;
|
2013-05-08 02:35:34 +08:00
|
|
|
}
|
2011-08-09 08:32:52 +08:00
|
|
|
else
|
2013-05-08 02:35:34 +08:00
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
GetPrivateStopInfo ();
|
|
|
|
return m_stop_info_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::StopInfoSP
|
|
|
|
Thread::GetPrivateStopInfo ()
|
|
|
|
{
|
2013-07-30 08:23:06 +08:00
|
|
|
if (m_destroy_called)
|
|
|
|
return m_stop_info_sp;
|
|
|
|
|
2013-05-09 09:55:29 +08:00
|
|
|
ProcessSP process_sp (GetProcess());
|
|
|
|
if (process_sp)
|
|
|
|
{
|
2013-05-14 23:20:12 +08:00
|
|
|
const uint32_t process_stop_id = process_sp->GetStopID();
|
|
|
|
if (m_stop_info_stop_id != process_stop_id)
|
2013-05-09 09:55:29 +08:00
|
|
|
{
|
2013-05-14 23:20:12 +08:00
|
|
|
if (m_stop_info_sp)
|
2013-05-09 09:55:29 +08:00
|
|
|
{
|
2013-05-14 23:20:12 +08:00
|
|
|
if (m_stop_info_sp->IsValid()
|
|
|
|
|| IsStillAtLastBreakpointHit()
|
|
|
|
|| GetCurrentPlan()->IsVirtualStep())
|
|
|
|
SetStopInfo (m_stop_info_sp);
|
|
|
|
else
|
|
|
|
m_stop_info_sp.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_stop_info_sp)
|
|
|
|
{
|
|
|
|
if (CalculateStopInfo() == false)
|
|
|
|
SetStopInfo (StopInfoSP());
|
2013-05-09 09:55:29 +08:00
|
|
|
}
|
2013-05-08 02:35:34 +08:00
|
|
|
}
|
2011-08-09 08:32:52 +08:00
|
|
|
}
|
2013-05-09 09:55:29 +08:00
|
|
|
return m_stop_info_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-05-09 09:55:29 +08:00
|
|
|
|
2012-09-25 10:40:06 +08:00
|
|
|
lldb::StopReason
|
|
|
|
Thread::GetStopReason()
|
|
|
|
{
|
|
|
|
lldb::StopInfoSP stop_info_sp (GetStopInfo ());
|
|
|
|
if (stop_info_sp)
|
2012-09-28 23:55:43 +08:00
|
|
|
return stop_info_sp->GetStopReason();
|
2012-09-25 10:40:06 +08:00
|
|
|
return eStopReasonNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-20 10:03:18 +08:00
|
|
|
void
|
|
|
|
Thread::SetStopInfo (const lldb::StopInfoSP &stop_info_sp)
|
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_sp = stop_info_sp;
|
|
|
|
if (m_stop_info_sp)
|
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
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_sp->MakeStopInfoValid();
|
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
|
|
|
// If we are overriding the ShouldReportStop, do that here:
|
|
|
|
if (m_override_should_notify != eLazyBoolCalculate)
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes);
|
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
|
|
|
}
|
|
|
|
|
2012-02-21 08:09:25 +08:00
|
|
|
ProcessSP process_sp (GetProcess());
|
|
|
|
if (process_sp)
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_stop_id = process_sp->GetStopID();
|
2012-02-21 08:09:25 +08:00
|
|
|
else
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_stop_id = UINT32_MAX;
|
2013-05-22 05:55:59 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
|
|
|
|
if (log)
|
2013-06-04 02:00:07 +08:00
|
|
|
log->Printf("%p: tid = 0x%" PRIx64 ": stop info = %s (stop_id = %u)\n", this, GetID(), stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>", m_stop_info_stop_id);
|
2011-01-20 10:03:18 +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
|
|
|
void
|
|
|
|
Thread::SetShouldReportStop (Vote vote)
|
|
|
|
{
|
|
|
|
if (vote == eVoteNoOpinion)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_override_should_notify = (vote == eVoteYes ? eLazyBoolYes : eLazyBoolNo);
|
2013-05-09 09:55:29 +08:00
|
|
|
if (m_stop_info_sp)
|
|
|
|
m_stop_info_sp->OverrideShouldNotify (m_override_should_notify == eLazyBoolYes);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 10:03:18 +08:00
|
|
|
void
|
|
|
|
Thread::SetStopInfoToNothing()
|
|
|
|
{
|
|
|
|
// Note, we can't just NULL out the private reason, or the native thread implementation will try to
|
|
|
|
// go calculate it again. For now, just set it to a Unix Signal with an invalid signal number.
|
|
|
|
SetStopInfo (StopInfo::CreateStopReasonWithSignal (*this, LLDB_INVALID_SIGNAL_NUMBER));
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
Thread::ThreadStoppedForAReason (void)
|
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
return (bool) GetPrivateStopInfo ();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-01-20 10:03:18 +08:00
|
|
|
bool
|
|
|
|
Thread::CheckpointThreadState (ThreadStateCheckpoint &saved_state)
|
|
|
|
{
|
|
|
|
if (!SaveFrameZeroState(saved_state.register_backup))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
saved_state.stop_info_sp = GetStopInfo();
|
2012-02-21 08:09:25 +08:00
|
|
|
ProcessSP process_sp (GetProcess());
|
|
|
|
if (process_sp)
|
|
|
|
saved_state.orig_stop_id = process_sp->GetStopID();
|
2012-09-08 07:36:43 +08:00
|
|
|
saved_state.current_inlined_depth = GetCurrentInlinedDepth();
|
|
|
|
|
2011-01-20 10:03:18 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-11-27 07:52:18 +08:00
|
|
|
Thread::RestoreRegisterStateFromCheckpoint (ThreadStateCheckpoint &saved_state)
|
2011-01-20 10:03:18 +08:00
|
|
|
{
|
|
|
|
RestoreSaveFrameZero(saved_state.register_backup);
|
2012-11-27 07:52:18 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Thread::RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state)
|
|
|
|
{
|
2011-01-25 10:47:23 +08:00
|
|
|
if (saved_state.stop_info_sp)
|
|
|
|
saved_state.stop_info_sp->MakeStopInfoValid();
|
2011-01-20 10:03:18 +08:00
|
|
|
SetStopInfo(saved_state.stop_info_sp);
|
2012-09-08 07:36:43 +08:00
|
|
|
GetStackFrameList()->SetCurrentInlinedDepth (saved_state.current_inlined_depth);
|
2011-01-20 10:03:18 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
StateType
|
|
|
|
Thread::GetState() const
|
|
|
|
{
|
|
|
|
// If any other threads access this we will need a mutex for it
|
|
|
|
Mutex::Locker locker(m_state_mutex);
|
|
|
|
return m_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::SetState(StateType state)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_state_mutex);
|
|
|
|
m_state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::WillStop()
|
|
|
|
{
|
|
|
|
ThreadPlan *current_plan = GetCurrentPlan();
|
|
|
|
|
|
|
|
// FIXME: I may decide to disallow threads with no plans. In which
|
|
|
|
// case this should go to an assert.
|
|
|
|
|
|
|
|
if (!current_plan)
|
|
|
|
return;
|
|
|
|
|
|
|
|
current_plan->WillStop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::SetupForResume ()
|
|
|
|
{
|
|
|
|
if (GetResumeState() != eStateSuspended)
|
|
|
|
{
|
|
|
|
|
|
|
|
// If we're at a breakpoint push the step-over breakpoint plan. Do this before
|
|
|
|
// telling the current plan it will resume, since we might change what the current
|
|
|
|
// plan is.
|
|
|
|
|
2013-04-03 04:32:37 +08:00
|
|
|
// StopReason stop_reason = lldb::eStopReasonInvalid;
|
|
|
|
// StopInfoSP stop_info_sp = GetStopInfo();
|
|
|
|
// if (stop_info_sp.get())
|
|
|
|
// stop_reason = stop_info_sp->GetStopReason();
|
|
|
|
// if (stop_reason == lldb::eStopReasonBreakpoint)
|
|
|
|
lldb::RegisterContextSP reg_ctx_sp (GetRegisterContext());
|
|
|
|
if (reg_ctx_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
BreakpointSiteSP bp_site_sp = GetProcess()->GetBreakpointSiteList().FindByAddress(reg_ctx_sp->GetPC());
|
|
|
|
if (bp_site_sp)
|
2010-06-19 12:45:32 +08:00
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
// Note, don't assume there's a ThreadPlanStepOverBreakpoint, the target may not require anything
|
|
|
|
// special to step over a breakpoint.
|
|
|
|
|
|
|
|
ThreadPlan *cur_plan = GetCurrentPlan();
|
2010-06-19 12:45:32 +08:00
|
|
|
|
2013-04-03 04:32:37 +08:00
|
|
|
if (cur_plan->GetKind() != ThreadPlan::eKindStepOverBreakpoint)
|
|
|
|
{
|
|
|
|
ThreadPlanStepOverBreakpoint *step_bp_plan = new ThreadPlanStepOverBreakpoint (*this);
|
|
|
|
if (step_bp_plan)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
ThreadPlanSP step_bp_plan_sp;
|
|
|
|
step_bp_plan->SetPrivate (true);
|
|
|
|
|
|
|
|
if (GetCurrentPlan()->RunState() != eStateStepping)
|
|
|
|
{
|
|
|
|
step_bp_plan->SetAutoContinue(true);
|
|
|
|
}
|
|
|
|
step_bp_plan_sp.reset (step_bp_plan);
|
|
|
|
QueueThreadPlan (step_bp_plan_sp, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-05-02 05:54:04 +08:00
|
|
|
Thread::ShouldResume (StateType resume_state)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// At this point clear the completed plan stack.
|
|
|
|
m_completed_plan_stack.clear();
|
|
|
|
m_discarded_plan_stack.clear();
|
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_override_should_notify = eLazyBoolCalculate;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-09-25 10:40:06 +08:00
|
|
|
m_temporary_resume_state = resume_state;
|
2012-02-01 07:09:20 +08:00
|
|
|
|
2013-05-09 09:55:29 +08:00
|
|
|
lldb::ThreadSP backing_thread_sp (GetBackingThread ());
|
|
|
|
if (backing_thread_sp)
|
|
|
|
backing_thread_sp->m_temporary_resume_state = resume_state;
|
|
|
|
|
|
|
|
// Make sure m_stop_info_sp is valid
|
|
|
|
GetPrivateStopInfo();
|
2013-05-02 05:54:04 +08:00
|
|
|
|
2012-02-01 07:09:20 +08:00
|
|
|
// This is a little dubious, but we are trying to limit how often we actually fetch stop info from
|
|
|
|
// the target, 'cause that slows down single stepping. So assume that if we got to the point where
|
|
|
|
// we're about to resume, and we haven't yet had to fetch the stop reason, then it doesn't need to know
|
|
|
|
// about the fact that we are resuming...
|
2012-02-21 08:09:25 +08:00
|
|
|
const uint32_t process_stop_id = GetProcess()->GetStopID();
|
2013-05-09 09:55:29 +08:00
|
|
|
if (m_stop_info_stop_id == process_stop_id &&
|
|
|
|
(m_stop_info_sp && m_stop_info_sp->IsValid()))
|
2012-02-01 07:09:20 +08:00
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
StopInfo *stop_info = GetPrivateStopInfo().get();
|
2012-02-01 07:09:20 +08:00
|
|
|
if (stop_info)
|
|
|
|
stop_info->WillResume (resume_state);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Tell all the plans that we are about to resume in case they need to clear any state.
|
|
|
|
// We distinguish between the plan on the top of the stack and the lower
|
|
|
|
// plans in case a plan needs to do any special business before it runs.
|
|
|
|
|
2013-04-20 08:27:58 +08:00
|
|
|
bool need_to_resume = false;
|
2010-06-09 00:52:24 +08:00
|
|
|
ThreadPlan *plan_ptr = GetCurrentPlan();
|
2013-04-20 08:27:58 +08:00
|
|
|
if (plan_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-04-20 08:27:58 +08:00
|
|
|
need_to_resume = plan_ptr->WillResume(resume_state, true);
|
|
|
|
|
|
|
|
while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
|
|
|
|
{
|
|
|
|
plan_ptr->WillResume (resume_state, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the WillResume for the plan says we are faking a resume, then it will have set an appropriate stop info.
|
|
|
|
// In that case, don't reset it here.
|
|
|
|
|
|
|
|
if (need_to_resume && resume_state != eStateSuspended)
|
|
|
|
{
|
2013-05-09 09:55:29 +08:00
|
|
|
m_stop_info_sp.reset();
|
2013-04-20 08:27:58 +08:00
|
|
|
}
|
2012-09-01 09:02:41 +08:00
|
|
|
}
|
|
|
|
|
2013-05-02 05:54:04 +08:00
|
|
|
if (need_to_resume)
|
|
|
|
{
|
|
|
|
ClearStackFrames();
|
|
|
|
// Let Thread subclasses do any special work they need to prior to resuming
|
|
|
|
WillResume (resume_state);
|
|
|
|
}
|
|
|
|
|
2012-09-01 09:02:41 +08:00
|
|
|
return need_to_resume;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::DidResume ()
|
|
|
|
{
|
|
|
|
SetResumeSignal (LLDB_INVALID_SIGNAL_NUMBER);
|
|
|
|
}
|
|
|
|
|
2013-05-11 01:19:04 +08:00
|
|
|
void
|
|
|
|
Thread::DidStop ()
|
|
|
|
{
|
|
|
|
SetState (eStateStopped);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
Thread::ShouldStop (Event* event_ptr)
|
|
|
|
{
|
|
|
|
ThreadPlan *current_plan = GetCurrentPlan();
|
2013-04-20 08:27:58 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool should_stop = true;
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2012-02-01 07:09:20 +08:00
|
|
|
|
|
|
|
if (GetResumeState () == eStateSuspended)
|
|
|
|
{
|
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", should_stop = 0 (ignore since thread was suspended)",
|
2012-02-01 07:09:20 +08:00
|
|
|
__FUNCTION__,
|
2013-05-02 05:54:04 +08:00
|
|
|
GetID (),
|
|
|
|
GetProtocolID());
|
2012-02-01 07:09:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetTemporaryResumeState () == eStateSuspended)
|
|
|
|
{
|
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", should_stop = 0 (ignore since thread was suspended)",
|
2012-02-01 07:09:20 +08:00
|
|
|
__FUNCTION__,
|
2013-05-02 05:54:04 +08:00
|
|
|
GetID (),
|
|
|
|
GetProtocolID());
|
2012-02-01 07:09:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-14 23:20:12 +08:00
|
|
|
// Based on the current thread plan and process stop info, check if this
|
|
|
|
// thread caused the process to stop. NOTE: this must take place before
|
|
|
|
// the plan is moved from the current plan stack to the completed plan
|
|
|
|
// stack.
|
2012-02-01 07:09:20 +08:00
|
|
|
if (ThreadStoppedForAReason() == false)
|
|
|
|
{
|
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64 ", should_stop = 0 (ignore since no stop reason)",
|
2012-02-01 07:09:20 +08:00
|
|
|
__FUNCTION__,
|
2013-05-02 05:54:04 +08:00
|
|
|
GetID (),
|
|
|
|
GetProtocolID(),
|
2013-04-03 04:32:37 +08:00
|
|
|
GetRegisterContext() ? GetRegisterContext()->GetPC() : LLDB_INVALID_ADDRESS);
|
2012-02-01 07:09:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
2012-09-01 09:02:41 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2013-06-22 08:27:45 +08:00
|
|
|
log->Printf ("Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64 ", pc = 0x%16.16" PRIx64,
|
|
|
|
__FUNCTION__,
|
|
|
|
this,
|
2013-05-02 05:54:04 +08:00
|
|
|
GetID (),
|
|
|
|
GetProtocolID (),
|
2013-04-03 04:32:37 +08:00
|
|
|
GetRegisterContext() ? GetRegisterContext()->GetPC() : LLDB_INVALID_ADDRESS);
|
2011-10-15 08:23:43 +08:00
|
|
|
log->Printf ("^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
|
2010-06-09 00:52:24 +08:00
|
|
|
StreamString s;
|
2011-10-15 08:23:43 +08:00
|
|
|
s.IndentMore();
|
2010-06-09 00:52:24 +08:00
|
|
|
DumpThreadPlans(&s);
|
2011-10-15 08:23:43 +08:00
|
|
|
log->Printf ("Plan stack initial state:\n%s", s.GetData());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-12 03:26:09 +08:00
|
|
|
|
|
|
|
// The top most plan always gets to do the trace log...
|
|
|
|
current_plan->DoTraceLog ();
|
2012-04-21 05:16:56 +08:00
|
|
|
|
|
|
|
// First query the stop info's ShouldStopSynchronous. This handles "synchronous" stop reasons, for example the breakpoint
|
|
|
|
// command on internal breakpoints. If a synchronous stop reason says we should not stop, then we don't have to
|
|
|
|
// do any more work on this stop.
|
2013-05-09 09:55:29 +08:00
|
|
|
StopInfoSP private_stop_info (GetPrivateStopInfo());
|
2012-04-21 05:16:56 +08:00
|
|
|
if (private_stop_info && private_stop_info->ShouldStopSynchronous(event_ptr) == false)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf ("StopInfo::ShouldStop async callback says we should not stop, returning ShouldStop of false.");
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-09-06 05:12:49 +08:00
|
|
|
// If we've already been restarted, don't query the plans since the state they would examine is not current.
|
|
|
|
if (Process::ProcessEventData::GetRestartedFromEvent(event_ptr))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Before the plans see the state of the world, calculate the current inlined depth.
|
|
|
|
GetStackFrameList()->CalculateCurrentInlinedDepth();
|
|
|
|
|
2011-12-03 09:52:59 +08:00
|
|
|
// If the base plan doesn't understand why we stopped, then we have to find a plan that does.
|
|
|
|
// If that plan is still working, then we don't need to do any more work. If the plan that explains
|
|
|
|
// the stop is done, then we should pop all the plans below it, and pop it, and then let the plans above it decide
|
|
|
|
// whether they still need to do more work.
|
|
|
|
|
|
|
|
bool done_processing_current_plan = false;
|
|
|
|
|
2013-02-09 09:29:05 +08:00
|
|
|
if (!current_plan->PlanExplainsStop(event_ptr))
|
2011-12-03 09:52:59 +08:00
|
|
|
{
|
|
|
|
if (current_plan->TracerExplainsStop())
|
|
|
|
{
|
|
|
|
done_processing_current_plan = true;
|
|
|
|
should_stop = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-10 06:37:39 +08:00
|
|
|
// If the current plan doesn't explain the stop, then find one that
|
2011-12-03 09:52:59 +08:00
|
|
|
// does and let it handle the situation.
|
|
|
|
ThreadPlan *plan_ptr = current_plan;
|
|
|
|
while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
|
|
|
|
{
|
2013-02-09 09:29:05 +08:00
|
|
|
if (plan_ptr->PlanExplainsStop(event_ptr))
|
2011-12-03 09:52:59 +08:00
|
|
|
{
|
|
|
|
should_stop = plan_ptr->ShouldStop (event_ptr);
|
|
|
|
|
|
|
|
// plan_ptr explains the stop, next check whether plan_ptr is done, if so, then we should take it
|
|
|
|
// and all the plans below it off the stack.
|
|
|
|
|
|
|
|
if (plan_ptr->MischiefManaged())
|
|
|
|
{
|
2012-05-12 07:49:49 +08:00
|
|
|
// We're going to pop the plans up to and including the plan that explains the stop.
|
2012-05-12 07:47:32 +08:00
|
|
|
ThreadPlan *prev_plan_ptr = GetPreviousPlan (plan_ptr);
|
2011-12-03 09:52:59 +08:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (should_stop)
|
|
|
|
current_plan->WillStop();
|
|
|
|
PopPlan();
|
|
|
|
}
|
2012-05-12 07:47:32 +08:00
|
|
|
while ((current_plan = GetCurrentPlan()) != prev_plan_ptr);
|
|
|
|
// Now, if the responsible plan was not "Okay to discard" then we're done,
|
|
|
|
// otherwise we forward this to the next plan in the stack below.
|
|
|
|
if (plan_ptr->IsMasterPlan() && !plan_ptr->OkayToDiscard())
|
|
|
|
done_processing_current_plan = true;
|
|
|
|
else
|
|
|
|
done_processing_current_plan = false;
|
2011-12-03 09:52:59 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
done_processing_current_plan = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!done_processing_current_plan)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-19 12:45:32 +08:00
|
|
|
bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
|
2011-02-08 13:20:59 +08:00
|
|
|
|
2011-10-15 08:23:43 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Plan %s explains stop, auto-continue %i.", current_plan->GetName(), over_ride_stop);
|
|
|
|
|
2011-02-08 13:20:59 +08:00
|
|
|
// We're starting from the base plan, so just let it decide;
|
|
|
|
if (PlanIsBasePlan(current_plan))
|
|
|
|
{
|
|
|
|
should_stop = current_plan->ShouldStop (event_ptr);
|
|
|
|
if (log)
|
2011-05-19 11:54:16 +08:00
|
|
|
log->Printf("Base plan says should stop: %i.", should_stop);
|
2011-02-08 13:20:59 +08:00
|
|
|
}
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-08 13:20:59 +08:00
|
|
|
// Otherwise, don't let the base plan override what the other plans say to do, since
|
|
|
|
// presumably if there were other plans they would know what to do...
|
|
|
|
while (1)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-08 13:20:59 +08:00
|
|
|
if (PlanIsBasePlan(current_plan))
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
2011-02-08 13:20:59 +08:00
|
|
|
|
|
|
|
should_stop = current_plan->ShouldStop(event_ptr);
|
|
|
|
if (log)
|
|
|
|
log->Printf("Plan %s should stop: %d.", current_plan->GetName(), should_stop);
|
|
|
|
if (current_plan->MischiefManaged())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-08 13:20:59 +08:00
|
|
|
if (should_stop)
|
|
|
|
current_plan->WillStop();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-02-08 13:20:59 +08:00
|
|
|
// If a Master Plan wants to stop, and wants to stick on the stack, we let it.
|
|
|
|
// Otherwise, see if the plan's parent wants to stop.
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-02-08 13:20:59 +08:00
|
|
|
if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-08 13:20:59 +08:00
|
|
|
PopPlan();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
}
|
2011-02-08 13:20:59 +08:00
|
|
|
else
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-02-08 13:20:59 +08:00
|
|
|
PopPlan();
|
|
|
|
|
|
|
|
current_plan = GetCurrentPlan();
|
|
|
|
if (current_plan == NULL)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2012-05-04 05:19:36 +08:00
|
|
|
|
2010-06-19 12:45:32 +08:00
|
|
|
if (over_ride_stop)
|
|
|
|
should_stop = false;
|
2012-05-04 05:19:36 +08:00
|
|
|
|
|
|
|
// One other potential problem is that we set up a master plan, then stop in before it is complete - for instance
|
|
|
|
// by hitting a breakpoint during a step-over - then do some step/finish/etc operations that wind up
|
|
|
|
// past the end point condition of the initial plan. We don't want to strand the original plan on the stack,
|
|
|
|
// This code clears stale plans off the stack.
|
|
|
|
|
|
|
|
if (should_stop)
|
|
|
|
{
|
|
|
|
ThreadPlan *plan_ptr = GetCurrentPlan();
|
|
|
|
while (!PlanIsBasePlan(plan_ptr))
|
|
|
|
{
|
|
|
|
bool stale = plan_ptr->IsPlanStale ();
|
|
|
|
ThreadPlan *examined_plan = plan_ptr;
|
|
|
|
plan_ptr = GetPreviousPlan (examined_plan);
|
|
|
|
|
|
|
|
if (stale)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Plan %s being discarded in cleanup, it says it is already done.", examined_plan->GetName());
|
|
|
|
DiscardThreadPlansUpToPlan(examined_plan);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-15 08:23:43 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString s;
|
|
|
|
s.IndentMore();
|
|
|
|
DumpThreadPlans(&s);
|
|
|
|
log->Printf ("Plan stack final state:\n%s", s.GetData());
|
|
|
|
log->Printf ("vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv", should_stop);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return should_stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vote
|
|
|
|
Thread::ShouldReportStop (Event* event_ptr)
|
|
|
|
{
|
|
|
|
StateType thread_state = GetResumeState ();
|
2012-02-01 07:09:20 +08:00
|
|
|
StateType temp_thread_state = GetTemporaryResumeState();
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-09-04 01:10:42 +08:00
|
|
|
|
|
|
|
if (thread_state == eStateSuspended || thread_state == eStateInvalid)
|
|
|
|
{
|
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i (state was suspended or invalid)", GetID(), eVoteNoOpinion);
|
2010-06-09 00:52:24 +08:00
|
|
|
return eVoteNoOpinion;
|
2010-09-04 01:10:42 +08:00
|
|
|
}
|
2012-02-01 07:09:20 +08:00
|
|
|
|
|
|
|
if (temp_thread_state == eStateSuspended || temp_thread_state == eStateInvalid)
|
|
|
|
{
|
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i (temporary state was suspended or invalid)", GetID(), eVoteNoOpinion);
|
2012-02-01 07:09:20 +08:00
|
|
|
return eVoteNoOpinion;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ThreadStoppedForAReason())
|
|
|
|
{
|
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i (thread didn't stop for a reason.)", GetID(), eVoteNoOpinion);
|
2012-02-01 07:09:20 +08:00
|
|
|
return eVoteNoOpinion;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (m_completed_plan_stack.size() > 0)
|
|
|
|
{
|
|
|
|
// Don't use GetCompletedPlan here, since that suppresses private plans.
|
2010-09-04 01:10:42 +08:00
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote for complete stack's back plan", GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_completed_plan_stack.back()->ShouldReportStop (event_ptr);
|
|
|
|
}
|
|
|
|
else
|
2010-09-04 01:10:42 +08:00
|
|
|
{
|
2013-02-09 09:29:05 +08:00
|
|
|
Vote thread_vote = eVoteNoOpinion;
|
|
|
|
ThreadPlan *plan_ptr = GetCurrentPlan();
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (plan_ptr->PlanExplainsStop(event_ptr))
|
|
|
|
{
|
|
|
|
thread_vote = plan_ptr->ShouldReportStop(event_ptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (PlanIsBasePlan(plan_ptr))
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
plan_ptr = GetPreviousPlan(plan_ptr);
|
|
|
|
}
|
2010-09-04 01:10:42 +08:00
|
|
|
if (log)
|
2013-05-02 05:54:04 +08:00
|
|
|
log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 ": returning vote %i for current plan", GetID(), thread_vote);
|
2013-02-09 09:29:05 +08:00
|
|
|
|
|
|
|
return thread_vote;
|
2010-09-04 01:10:42 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Vote
|
|
|
|
Thread::ShouldReportRun (Event* event_ptr)
|
|
|
|
{
|
|
|
|
StateType thread_state = GetResumeState ();
|
2011-01-24 14:34:17 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (thread_state == eStateSuspended
|
|
|
|
|| thread_state == eStateInvalid)
|
2011-01-24 14:34:17 +08:00
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
return eVoteNoOpinion;
|
2011-01-24 14:34:17 +08:00
|
|
|
}
|
|
|
|
|
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 (m_completed_plan_stack.size() > 0)
|
|
|
|
{
|
|
|
|
// Don't use GetCompletedPlan here, since that suppresses private plans.
|
2011-01-24 14:34:17 +08:00
|
|
|
if (log)
|
2013-06-22 08:27:45 +08:00
|
|
|
log->Printf ("Current Plan for thread %d(%p) (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
|
|
|
|
GetIndexID(),
|
|
|
|
this,
|
2011-01-24 14:34:17 +08:00
|
|
|
GetID(),
|
2013-05-02 05:54:04 +08:00
|
|
|
StateAsCString(GetTemporaryResumeState()),
|
2011-01-24 14:34:17 +08:00
|
|
|
m_completed_plan_stack.back()->GetName());
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_completed_plan_stack.back()->ShouldReportRun (event_ptr);
|
|
|
|
}
|
|
|
|
else
|
2011-01-24 14:34:17 +08:00
|
|
|
{
|
|
|
|
if (log)
|
2013-06-22 08:27:45 +08:00
|
|
|
log->Printf ("Current Plan for thread %d(%p) (0x%4.4" PRIx64 ", %s): %s being asked whether we should report run.",
|
|
|
|
GetIndexID(),
|
|
|
|
this,
|
2011-01-24 14:34:17 +08:00
|
|
|
GetID(),
|
2013-05-02 05:54:04 +08:00
|
|
|
StateAsCString(GetTemporaryResumeState()),
|
2011-01-24 14:34:17 +08:00
|
|
|
GetCurrentPlan()->GetName());
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return GetCurrentPlan()->ShouldReportRun (event_ptr);
|
2011-01-24 14:34:17 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-16 10:00:15 +08:00
|
|
|
bool
|
|
|
|
Thread::MatchesSpec (const ThreadSpec *spec)
|
|
|
|
{
|
|
|
|
if (spec == NULL)
|
|
|
|
return true;
|
|
|
|
|
2012-03-08 06:03:04 +08:00
|
|
|
return spec->ThreadPassesBasicTests(*this);
|
2010-06-16 10:00:15 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
Thread::PushPlan (ThreadPlanSP &thread_plan_sp)
|
|
|
|
{
|
|
|
|
if (thread_plan_sp)
|
|
|
|
{
|
2010-11-12 03:26:09 +08:00
|
|
|
// If the thread plan doesn't already have a tracer, give it its parent's tracer:
|
|
|
|
if (!thread_plan_sp->GetThreadPlanTracer())
|
|
|
|
thread_plan_sp->SetThreadPlanTracer(m_plan_stack.back()->GetThreadPlanTracer());
|
2010-10-20 08:39:53 +08:00
|
|
|
m_plan_stack.push_back (thread_plan_sp);
|
2010-11-12 03:26:09 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
thread_plan_sp->DidPush();
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
StreamString s;
|
|
|
|
thread_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull);
|
2013-06-22 08:27:45 +08:00
|
|
|
log->Printf("Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
|
|
|
|
this,
|
2010-06-09 00:52:24 +08:00
|
|
|
s.GetData(),
|
2010-10-20 08:39:53 +08:00
|
|
|
thread_plan_sp->GetThread().GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::PopPlan ()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-08-23 05:34:33 +08:00
|
|
|
if (m_plan_stack.size() <= 1)
|
2010-06-09 00:52:24 +08:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ThreadPlanSP &plan = m_plan_stack.back();
|
|
|
|
if (log)
|
|
|
|
{
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf("Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".", plan->GetName(), plan->GetThread().GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
m_completed_plan_stack.push_back (plan);
|
|
|
|
plan->WillPop();
|
|
|
|
m_plan_stack.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::DiscardPlan ()
|
|
|
|
{
|
2013-06-22 08:27:45 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_plan_stack.size() > 1)
|
|
|
|
{
|
|
|
|
ThreadPlanSP &plan = m_plan_stack.back();
|
2013-06-22 08:27:45 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".", plan->GetName(), plan->GetThread().GetID());
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
m_discarded_plan_stack.push_back (plan);
|
|
|
|
plan->WillPop();
|
|
|
|
m_plan_stack.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlan *
|
|
|
|
Thread::GetCurrentPlan ()
|
|
|
|
{
|
2012-04-19 08:17:05 +08:00
|
|
|
// There will always be at least the base plan. If somebody is mucking with a
|
|
|
|
// thread with an empty plan stack, we should assert right away.
|
2013-04-20 08:27:58 +08:00
|
|
|
if (m_plan_stack.empty())
|
|
|
|
return NULL;
|
2012-04-19 08:17:05 +08:00
|
|
|
return m_plan_stack.back().get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlanSP
|
|
|
|
Thread::GetCompletedPlan ()
|
|
|
|
{
|
|
|
|
ThreadPlanSP empty_plan_sp;
|
|
|
|
if (!m_completed_plan_stack.empty())
|
|
|
|
{
|
|
|
|
for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
ThreadPlanSP completed_plan_sp;
|
|
|
|
completed_plan_sp = m_completed_plan_stack[i];
|
|
|
|
if (!completed_plan_sp->GetPrivate ())
|
|
|
|
return completed_plan_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return empty_plan_sp;
|
|
|
|
}
|
|
|
|
|
2011-12-17 09:35:57 +08:00
|
|
|
ValueObjectSP
|
|
|
|
Thread::GetReturnValueObject ()
|
|
|
|
{
|
|
|
|
if (!m_completed_plan_stack.empty())
|
|
|
|
{
|
|
|
|
for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
ValueObjectSP return_valobj_sp;
|
|
|
|
return_valobj_sp = m_completed_plan_stack[i]->GetReturnValueObject();
|
|
|
|
if (return_valobj_sp)
|
|
|
|
return return_valobj_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ValueObjectSP();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
Thread::IsThreadPlanDone (ThreadPlan *plan)
|
|
|
|
{
|
|
|
|
if (!m_completed_plan_stack.empty())
|
|
|
|
{
|
|
|
|
for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (m_completed_plan_stack[i].get() == plan)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Thread::WasThreadPlanDiscarded (ThreadPlan *plan)
|
|
|
|
{
|
|
|
|
if (!m_discarded_plan_stack.empty())
|
|
|
|
{
|
|
|
|
for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (m_discarded_plan_stack[i].get() == plan)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlan *
|
|
|
|
Thread::GetPreviousPlan (ThreadPlan *current_plan)
|
|
|
|
{
|
|
|
|
if (current_plan == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int stack_size = m_completed_plan_stack.size();
|
|
|
|
for (int i = stack_size - 1; i > 0; i--)
|
|
|
|
{
|
|
|
|
if (current_plan == m_completed_plan_stack[i].get())
|
|
|
|
return m_completed_plan_stack[i-1].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan)
|
|
|
|
{
|
|
|
|
if (m_plan_stack.size() > 0)
|
|
|
|
return m_plan_stack.back().get();
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
stack_size = m_plan_stack.size();
|
|
|
|
for (int i = stack_size - 1; i > 0; i--)
|
|
|
|
{
|
|
|
|
if (current_plan == m_plan_stack[i].get())
|
|
|
|
return m_plan_stack[i-1].get();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::QueueThreadPlan (ThreadPlanSP &thread_plan_sp, bool abort_other_plans)
|
|
|
|
{
|
|
|
|
if (abort_other_plans)
|
|
|
|
DiscardThreadPlans(true);
|
|
|
|
|
|
|
|
PushPlan (thread_plan_sp);
|
|
|
|
}
|
|
|
|
|
2010-11-12 03:26:09 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
Thread::EnableTracer (bool value, bool single_stepping)
|
|
|
|
{
|
|
|
|
int stack_size = m_plan_stack.size();
|
|
|
|
for (int i = 0; i < stack_size; i++)
|
|
|
|
{
|
|
|
|
if (m_plan_stack[i]->GetThreadPlanTracer())
|
|
|
|
{
|
|
|
|
m_plan_stack[i]->GetThreadPlanTracer()->EnableTracing(value);
|
|
|
|
m_plan_stack[i]->GetThreadPlanTracer()->EnableSingleStep(single_stepping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::SetTracer (lldb::ThreadPlanTracerSP &tracer_sp)
|
|
|
|
{
|
|
|
|
int stack_size = m_plan_stack.size();
|
|
|
|
for (int i = 0; i < stack_size; i++)
|
|
|
|
m_plan_stack[i]->SetThreadPlanTracer(tracer_sp);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
2010-11-06 03:25:48 +08:00
|
|
|
Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp)
|
2012-05-04 05:19:36 +08:00
|
|
|
{
|
|
|
|
DiscardThreadPlansUpToPlan (up_to_plan_sp.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-11-06 03:25:48 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf("Discarding thread plans for thread tid = 0x%4.4" PRIx64 ", up to %p", GetID(), up_to_plan_ptr);
|
2010-11-06 03:25:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int stack_size = m_plan_stack.size();
|
|
|
|
|
|
|
|
// If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
|
|
|
|
// stack, and if so discard up to and including it.
|
|
|
|
|
2012-05-04 05:19:36 +08:00
|
|
|
if (up_to_plan_ptr == NULL)
|
2010-11-06 03:25:48 +08:00
|
|
|
{
|
|
|
|
for (int i = stack_size - 1; i > 0; i--)
|
|
|
|
DiscardPlan();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool found_it = false;
|
|
|
|
for (int i = stack_size - 1; i > 0; i--)
|
|
|
|
{
|
2012-05-04 05:19:36 +08:00
|
|
|
if (m_plan_stack[i].get() == up_to_plan_ptr)
|
2010-11-06 03:25:48 +08:00
|
|
|
found_it = true;
|
|
|
|
}
|
|
|
|
if (found_it)
|
|
|
|
{
|
|
|
|
bool last_one = false;
|
|
|
|
for (int i = stack_size - 1; i > 0 && !last_one ; i--)
|
|
|
|
{
|
2012-05-04 05:19:36 +08:00
|
|
|
if (GetCurrentPlan() == up_to_plan_ptr)
|
2010-11-06 03:25:48 +08:00
|
|
|
last_one = true;
|
|
|
|
DiscardPlan();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-11-06 03:25:48 +08:00
|
|
|
void
|
|
|
|
Thread::DiscardThreadPlans(bool force)
|
|
|
|
{
|
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)
|
|
|
|
{
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf("Discarding thread plans for thread (tid = 0x%4.4" PRIx64 ", force %d)", GetID(), force);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (force)
|
|
|
|
{
|
|
|
|
int stack_size = m_plan_stack.size();
|
|
|
|
for (int i = stack_size - 1; i > 0; i--)
|
|
|
|
{
|
|
|
|
DiscardPlan();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
|
|
|
|
int master_plan_idx;
|
2012-09-11 08:09:25 +08:00
|
|
|
bool discard = true;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Find the first master plan, see if it wants discarding, and if yes discard up to it.
|
|
|
|
for (master_plan_idx = m_plan_stack.size() - 1; master_plan_idx >= 0; master_plan_idx--)
|
|
|
|
{
|
|
|
|
if (m_plan_stack[master_plan_idx]->IsMasterPlan())
|
|
|
|
{
|
|
|
|
discard = m_plan_stack[master_plan_idx]->OkayToDiscard();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (discard)
|
|
|
|
{
|
|
|
|
// First pop all the dependent plans:
|
|
|
|
for (int i = m_plan_stack.size() - 1; i > master_plan_idx; i--)
|
|
|
|
{
|
|
|
|
|
|
|
|
// FIXME: Do we need a finalize here, or is the rule that "PrepareForStop"
|
|
|
|
// for the plan leaves it in a state that it is safe to pop the plan
|
|
|
|
// with no more notice?
|
|
|
|
DiscardPlan();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now discard the master plan itself.
|
|
|
|
// The bottom-most plan never gets discarded. "OkayToDiscard" for it means
|
|
|
|
// discard it's dependent plans, but not it...
|
|
|
|
if (master_plan_idx > 0)
|
|
|
|
{
|
|
|
|
DiscardPlan();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If the master plan doesn't want to get discarded, then we're done.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-10 06:37:39 +08:00
|
|
|
bool
|
|
|
|
Thread::PlanIsBasePlan (ThreadPlan *plan_ptr)
|
|
|
|
{
|
|
|
|
if (plan_ptr->IsBasePlan())
|
|
|
|
return true;
|
|
|
|
else if (m_plan_stack.size() == 0)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return m_plan_stack[0].get() == plan_ptr;
|
|
|
|
}
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
Error
|
|
|
|
Thread::UnwindInnermostExpression()
|
|
|
|
{
|
|
|
|
Error error;
|
|
|
|
int stack_size = m_plan_stack.size();
|
|
|
|
|
|
|
|
// If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
|
|
|
|
// stack, and if so discard up to and including it.
|
|
|
|
|
|
|
|
for (int i = stack_size - 1; i > 0; i--)
|
|
|
|
{
|
|
|
|
if (m_plan_stack[i]->GetKind() == ThreadPlan::eKindCallFunction)
|
|
|
|
{
|
|
|
|
DiscardThreadPlansUpToPlan(m_plan_stack[i].get());
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error.SetErrorString("No expressions currently active on this thread");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::QueueFundamentalPlan (bool abort_other_plans)
|
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanBase(*this));
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2011-01-21 14:11:58 +08:00
|
|
|
Thread::QueueThreadPlanForStepSingleInstruction
|
|
|
|
(
|
|
|
|
bool step_over,
|
|
|
|
bool abort_other_plans,
|
|
|
|
bool stop_other_threads
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanStepInstruction (*this, step_over, stop_other_threads, eVoteNoOpinion, eVoteNoOpinion));
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
|
|
|
Thread::QueueThreadPlanForStepOverRange
|
2010-06-13 02:59:55 +08:00
|
|
|
(
|
|
|
|
bool abort_other_plans,
|
|
|
|
const AddressRange &range,
|
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
|
|
|
const SymbolContext &addr_context,
|
|
|
|
lldb::RunMode stop_other_threads
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp;
|
|
|
|
thread_plan_sp.reset (new ThreadPlanStepOverRange (*this, range, addr_context, stop_other_threads));
|
|
|
|
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
|
|
|
Thread::QueueThreadPlanForStepInRange
|
|
|
|
(
|
|
|
|
bool abort_other_plans,
|
|
|
|
const AddressRange &range,
|
|
|
|
const SymbolContext &addr_context,
|
|
|
|
const char *step_in_target,
|
2010-06-13 02:59:55 +08:00
|
|
|
lldb::RunMode stop_other_threads,
|
|
|
|
bool avoid_code_without_debug_info
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp;
|
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
|
|
|
ThreadPlanStepInRange *plan = new ThreadPlanStepInRange (*this, range, addr_context, stop_other_threads);
|
|
|
|
if (avoid_code_without_debug_info)
|
|
|
|
plan->GetFlags().Set (ThreadPlanShouldStopHere::eAvoidNoDebug);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
|
|
|
plan->GetFlags().Clear (ThreadPlanShouldStopHere::eAvoidNoDebug);
|
|
|
|
if (step_in_target)
|
|
|
|
plan->SetStepInTarget(step_in_target);
|
|
|
|
thread_plan_sp.reset (plan);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::QueueThreadPlanForStepOverBreakpointPlan (bool abort_other_plans)
|
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanStepOverBreakpoint (*this));
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2011-01-21 14:11:58 +08:00
|
|
|
Thread::QueueThreadPlanForStepOut
|
|
|
|
(
|
|
|
|
bool abort_other_plans,
|
|
|
|
SymbolContext *addr_context,
|
|
|
|
bool first_insn,
|
|
|
|
bool stop_other_threads,
|
|
|
|
Vote stop_vote,
|
|
|
|
Vote run_vote,
|
|
|
|
uint32_t frame_idx
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-21 14:11:58 +08:00
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanStepOut (*this,
|
|
|
|
addr_context,
|
|
|
|
first_insn,
|
|
|
|
stop_other_threads,
|
|
|
|
stop_vote,
|
|
|
|
run_vote,
|
|
|
|
frame_idx));
|
2012-08-01 06:19:25 +08:00
|
|
|
|
|
|
|
if (thread_plan_sp->ValidatePlan(NULL))
|
|
|
|
{
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2012-08-01 06:19:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-19 05:48:26 +08:00
|
|
|
return ThreadPlanSP();
|
2012-08-01 06:19:25 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2012-05-10 09:35:39 +08:00
|
|
|
Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-05-10 09:35:39 +08:00
|
|
|
ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, return_stack_id, stop_other_threads));
|
2011-12-03 09:52:59 +08:00
|
|
|
if (!thread_plan_sp || !thread_plan_sp->ValidatePlan (NULL))
|
2013-07-19 05:48:26 +08:00
|
|
|
return ThreadPlanSP();
|
2011-12-03 09:52:59 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::QueueThreadPlanForCallFunction (bool abort_other_plans,
|
|
|
|
Address& function,
|
|
|
|
lldb::addr_t arg,
|
|
|
|
bool stop_other_threads,
|
2013-01-15 10:47:48 +08:00
|
|
|
bool unwind_on_error,
|
|
|
|
bool ignore_breakpoints)
|
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanCallFunction (*this,
|
|
|
|
function,
|
|
|
|
ClangASTType(),
|
|
|
|
arg,
|
|
|
|
stop_other_threads,
|
|
|
|
unwind_on_error,
|
|
|
|
ignore_breakpoints));
|
2010-06-09 00:52:24 +08:00
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::QueueThreadPlanForRunToAddress (bool abort_other_plans,
|
|
|
|
Address &target_addr,
|
|
|
|
bool stop_other_threads)
|
|
|
|
{
|
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanRunToAddress (*this, target_addr, stop_other_threads));
|
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::QueueThreadPlanForStepUntil (bool abort_other_plans,
|
2011-01-21 14:11:58 +08:00
|
|
|
lldb::addr_t *address_list,
|
|
|
|
size_t num_addresses,
|
|
|
|
bool stop_other_threads,
|
|
|
|
uint32_t frame_idx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-21 14:11:58 +08:00
|
|
|
ThreadPlanSP thread_plan_sp (new ThreadPlanStepUntil (*this, address_list, num_addresses, stop_other_threads, frame_idx));
|
2010-06-09 00:52:24 +08:00
|
|
|
QueueThreadPlan (thread_plan_sp, abort_other_plans);
|
2013-07-19 05:48:26 +08:00
|
|
|
return thread_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
Thread::GetIndexID () const
|
|
|
|
{
|
|
|
|
return m_index_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::DumpThreadPlans (lldb_private::Stream *s) const
|
|
|
|
{
|
|
|
|
uint32_t stack_size = m_plan_stack.size();
|
2010-09-04 06:45:01 +08:00
|
|
|
int i;
|
2011-10-15 08:23:43 +08:00
|
|
|
s->Indent();
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf ("Plan Stack for thread #%u: tid = 0x%4.4" PRIx64 ", stack_size = %d\n", GetIndexID(), GetID(), stack_size);
|
2010-09-04 06:45:01 +08:00
|
|
|
for (i = stack_size - 1; i >= 0; i--)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
s->IndentMore();
|
2011-10-15 08:23:43 +08:00
|
|
|
s->Indent();
|
|
|
|
s->Printf ("Element %d: ", i);
|
2010-06-09 00:52:24 +08:00
|
|
|
m_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
|
|
|
|
s->EOL();
|
2011-10-15 08:23:43 +08:00
|
|
|
s->IndentLess();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stack_size = m_completed_plan_stack.size();
|
2011-10-15 08:23:43 +08:00
|
|
|
if (stack_size > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-10-15 08:23:43 +08:00
|
|
|
s->Indent();
|
|
|
|
s->Printf ("Completed Plan Stack: %d elements.\n", stack_size);
|
|
|
|
for (i = stack_size - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
s->IndentMore();
|
|
|
|
s->Indent();
|
|
|
|
s->Printf ("Element %d: ", i);
|
|
|
|
m_completed_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
|
|
|
|
s->EOL();
|
|
|
|
s->IndentLess();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stack_size = m_discarded_plan_stack.size();
|
2011-10-15 08:23:43 +08:00
|
|
|
if (stack_size > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-10-15 08:23:43 +08:00
|
|
|
s->Indent();
|
|
|
|
s->Printf ("Discarded Plan Stack: %d elements.\n", stack_size);
|
|
|
|
for (i = stack_size - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
s->IndentMore();
|
|
|
|
s->Indent();
|
|
|
|
s->Printf ("Element %d: ", i);
|
|
|
|
m_discarded_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
|
|
|
|
s->EOL();
|
|
|
|
s->IndentLess();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
TargetSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::CalculateTarget ()
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
TargetSP target_sp;
|
|
|
|
ProcessSP process_sp(GetProcess());
|
|
|
|
if (process_sp)
|
|
|
|
target_sp = process_sp->CalculateTarget();
|
|
|
|
return target_sp;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
ProcessSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::CalculateProcess ()
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
return GetProcess();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
ThreadSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::CalculateThread ()
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
return shared_from_this();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:35:26 +08:00
|
|
|
StackFrameSP
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread::CalculateStackFrame ()
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
return StackFrameSP();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-04 09:05:56 +08:00
|
|
|
Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
exe_ctx.SetContext (shared_from_this());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 08:35:26 +08:00
|
|
|
|
2012-03-29 09:41:38 +08:00
|
|
|
StackFrameListSP
|
2010-08-25 08:35:26 +08:00
|
|
|
Thread::GetStackFrameList ()
|
|
|
|
{
|
2012-03-29 09:41:38 +08:00
|
|
|
StackFrameListSP frame_list_sp;
|
|
|
|
Mutex::Locker locker(m_frame_mutex);
|
|
|
|
if (m_curr_frames_sp)
|
|
|
|
{
|
|
|
|
frame_list_sp = m_curr_frames_sp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frame_list_sp.reset(new StackFrameList (*this, m_prev_frames_sp, true));
|
|
|
|
m_curr_frames_sp = frame_list_sp;
|
|
|
|
}
|
|
|
|
return frame_list_sp;
|
2010-08-25 08:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Thread::ClearStackFrames ()
|
|
|
|
{
|
2012-03-29 09:41:38 +08:00
|
|
|
Mutex::Locker locker(m_frame_mutex);
|
|
|
|
|
2013-05-02 05:54:04 +08:00
|
|
|
Unwind *unwinder = GetUnwinder ();
|
|
|
|
if (unwinder)
|
|
|
|
unwinder->Clear();
|
|
|
|
|
2012-02-29 11:40:22 +08:00
|
|
|
// Only store away the old "reference" StackFrameList if we got all its frames:
|
|
|
|
// FIXME: At some point we can try to splice in the frames we have fetched into
|
|
|
|
// the new frame as we make it, but let's not try that now.
|
|
|
|
if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
|
2011-08-13 05:40:01 +08:00
|
|
|
m_prev_frames_sp.swap (m_curr_frames_sp);
|
|
|
|
m_curr_frames_sp.reset();
|
2010-08-12 10:14:28 +08:00
|
|
|
}
|
|
|
|
|
2011-01-07 06:15:06 +08:00
|
|
|
lldb::StackFrameSP
|
|
|
|
Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
|
|
|
|
{
|
2012-03-29 09:41:38 +08:00
|
|
|
return GetStackFrameList()->GetFrameWithConcreteFrameIndex (unwind_idx);
|
2011-01-07 06:15:06 +08:00
|
|
|
}
|
|
|
|
|
2012-09-12 08:40:39 +08:00
|
|
|
|
|
|
|
Error
|
2012-10-11 02:32:14 +08:00
|
|
|
Thread::ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast)
|
2012-09-12 08:40:39 +08:00
|
|
|
{
|
|
|
|
StackFrameSP frame_sp = GetStackFrameAtIndex (frame_idx);
|
|
|
|
Error return_error;
|
|
|
|
|
|
|
|
if (!frame_sp)
|
|
|
|
{
|
2012-11-30 05:49:15 +08:00
|
|
|
return_error.SetErrorStringWithFormat("Could not find frame with index %d in thread 0x%" PRIx64 ".", frame_idx, GetID());
|
2012-09-12 08:40:39 +08:00
|
|
|
}
|
|
|
|
|
2012-10-11 02:32:14 +08:00
|
|
|
return ReturnFromFrame(frame_sp, return_value_sp, broadcast);
|
2012-09-12 08:40:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Error
|
2012-10-11 02:32:14 +08:00
|
|
|
Thread::ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast)
|
2012-09-12 08:40:39 +08:00
|
|
|
{
|
|
|
|
Error return_error;
|
|
|
|
|
|
|
|
if (!frame_sp)
|
|
|
|
{
|
|
|
|
return_error.SetErrorString("Can't return to a null frame.");
|
|
|
|
return return_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread *thread = frame_sp->GetThread().get();
|
2012-09-14 10:14:15 +08:00
|
|
|
uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
|
|
|
|
StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
|
2013-02-01 05:46:01 +08:00
|
|
|
if (!older_frame_sp)
|
|
|
|
{
|
|
|
|
return_error.SetErrorString("No older frame to return to.");
|
|
|
|
return return_error;
|
|
|
|
}
|
2012-09-12 08:40:39 +08:00
|
|
|
|
|
|
|
if (return_value_sp)
|
2012-09-27 09:15:29 +08:00
|
|
|
{
|
2012-09-12 08:40:39 +08:00
|
|
|
lldb::ABISP abi = thread->GetProcess()->GetABI();
|
|
|
|
if (!abi)
|
|
|
|
{
|
|
|
|
return_error.SetErrorString("Could not find ABI to set return value.");
|
2012-10-13 01:34:26 +08:00
|
|
|
return return_error;
|
2012-09-12 08:40:39 +08:00
|
|
|
}
|
2012-09-27 09:15:29 +08:00
|
|
|
SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
|
|
|
|
|
|
|
|
// FIXME: ValueObject::Cast doesn't currently work correctly, at least not for scalars.
|
|
|
|
// Turn that back on when that works.
|
|
|
|
if (0 && sc.function != NULL)
|
|
|
|
{
|
|
|
|
Type *function_type = sc.function->GetType();
|
|
|
|
if (function_type)
|
|
|
|
{
|
2013-07-12 06:46:58 +08:00
|
|
|
ClangASTType return_type = sc.function->GetClangType().GetFunctionReturnType();
|
2012-09-27 09:15:29 +08:00
|
|
|
if (return_type)
|
|
|
|
{
|
|
|
|
StreamString s;
|
2013-07-12 06:46:58 +08:00
|
|
|
return_type.DumpTypeDescription(&s);
|
|
|
|
ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
|
2012-09-27 09:15:29 +08:00
|
|
|
if (cast_value_sp)
|
|
|
|
{
|
|
|
|
cast_value_sp->SetFormat(eFormatHex);
|
|
|
|
return_value_sp = cast_value_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-14 10:14:15 +08:00
|
|
|
return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
|
2012-09-12 08:40:39 +08:00
|
|
|
if (!return_error.Success())
|
|
|
|
return return_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now write the return registers for the chosen frame:
|
2012-09-14 10:14:15 +08:00
|
|
|
// Note, we can't use ReadAllRegisterValues->WriteAllRegisterValues, since the read & write
|
2013-02-01 05:46:01 +08:00
|
|
|
// cook their data
|
|
|
|
|
|
|
|
StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
|
|
|
|
if (youngest_frame_sp)
|
2012-09-12 08:40:39 +08:00
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
lldb::RegisterContextSP reg_ctx_sp (youngest_frame_sp->GetRegisterContext());
|
|
|
|
if (reg_ctx_sp)
|
2013-02-01 05:46:01 +08:00
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
bool copy_success = reg_ctx_sp->CopyFromRegisterContext(older_frame_sp->GetRegisterContext());
|
|
|
|
if (copy_success)
|
|
|
|
{
|
|
|
|
thread->DiscardThreadPlans(true);
|
|
|
|
thread->ClearStackFrames();
|
|
|
|
if (broadcast && EventTypeHasListeners(eBroadcastBitStackChanged))
|
|
|
|
BroadcastEvent(eBroadcastBitStackChanged, new ThreadEventData (this->shared_from_this()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return_error.SetErrorString("Could not reset register values.");
|
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
return_error.SetErrorString("Frame has no register context.");
|
2013-02-01 05:46:01 +08:00
|
|
|
}
|
2012-09-12 08:40:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-01 05:46:01 +08:00
|
|
|
return_error.SetErrorString("Returned past top frame.");
|
2012-09-12 08:40:39 +08:00
|
|
|
}
|
2013-02-01 10:52:31 +08:00
|
|
|
return return_error;
|
2012-09-12 08:40:39 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
2010-10-04 09:05:56 +08:00
|
|
|
Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (process == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
StackFrameSP frame_sp;
|
2010-10-04 09:05:56 +08:00
|
|
|
SymbolContext frame_sc;
|
|
|
|
if (frame_idx != LLDB_INVALID_INDEX32)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
frame_sp = GetStackFrameAtIndex (frame_idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (frame_sp)
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
exe_ctx.SetFrameSP(frame_sp);
|
|
|
|
frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-21 08:09:25 +08:00
|
|
|
const char *thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();
|
2010-10-04 09:05:56 +08:00
|
|
|
assert (thread_format);
|
|
|
|
Debugger::FormatPrompt (thread_format,
|
2011-09-22 12:58:26 +08:00
|
|
|
frame_sp ? &frame_sc : NULL,
|
2010-10-04 09:05:56 +08:00
|
|
|
&exe_ctx,
|
|
|
|
NULL,
|
2013-05-24 04:47:45 +08:00
|
|
|
strm);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-19 07:32:35 +08:00
|
|
|
void
|
2011-03-11 06:14:10 +08:00
|
|
|
Thread::SettingsInitialize ()
|
2010-11-19 07:32:35 +08:00
|
|
|
{
|
|
|
|
}
|
2010-09-08 11:14:33 +08:00
|
|
|
|
2010-11-19 07:32:35 +08:00
|
|
|
void
|
2011-03-11 06:14:10 +08:00
|
|
|
Thread::SettingsTerminate ()
|
2010-11-19 07:32:35 +08:00
|
|
|
{
|
2012-08-23 02:39:03 +08:00
|
|
|
}
|
2010-09-27 08:30:10 +08:00
|
|
|
|
2010-11-12 03:26:09 +08:00
|
|
|
lldb::StackFrameSP
|
|
|
|
Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
|
|
|
|
{
|
2012-03-29 09:41:38 +08:00
|
|
|
return GetStackFrameList()->GetStackFrameSPForStackFramePtr (stack_frame_ptr);
|
2010-11-12 03:26:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
Thread::StopReasonAsCString (lldb::StopReason reason)
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
2012-12-21 07:08:03 +08:00
|
|
|
case eStopReasonInvalid: return "invalid";
|
|
|
|
case eStopReasonNone: return "none";
|
|
|
|
case eStopReasonTrace: return "trace";
|
|
|
|
case eStopReasonBreakpoint: return "breakpoint";
|
|
|
|
case eStopReasonWatchpoint: return "watchpoint";
|
|
|
|
case eStopReasonSignal: return "signal";
|
|
|
|
case eStopReasonException: return "exception";
|
|
|
|
case eStopReasonExec: return "exec";
|
|
|
|
case eStopReasonPlanComplete: return "plan complete";
|
|
|
|
case eStopReasonThreadExiting: return "thread exiting";
|
2010-11-12 03:26:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char unknown_state_string[64];
|
|
|
|
snprintf(unknown_state_string, sizeof (unknown_state_string), "StopReason = %i", reason);
|
|
|
|
return unknown_state_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
Thread::RunModeAsCString (lldb::RunMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case eOnlyThisThread: return "only this thread";
|
|
|
|
case eAllThreads: return "all threads";
|
|
|
|
case eOnlyDuringStepping: return "only during stepping";
|
|
|
|
}
|
|
|
|
|
|
|
|
static char unknown_state_string[64];
|
|
|
|
snprintf(unknown_state_string, sizeof (unknown_state_string), "RunMode = %i", mode);
|
|
|
|
return unknown_state_string;
|
|
|
|
}
|
|
|
|
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
size_t
|
|
|
|
Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
ExecutionContext exe_ctx (shared_from_this());
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
size_t num_frames_shown = 0;
|
|
|
|
strm.Indent();
|
2012-02-21 08:09:25 +08:00
|
|
|
bool is_selected = false;
|
|
|
|
if (process)
|
|
|
|
{
|
|
|
|
if (process->GetThreadList().GetSelectedThread().get() == this)
|
|
|
|
is_selected = true;
|
|
|
|
}
|
|
|
|
strm.Printf("%c ", is_selected ? '*' : ' ');
|
|
|
|
if (target && target->GetDebugger().GetUseExternalEditor())
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
{
|
2011-08-12 14:47:54 +08:00
|
|
|
StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
|
2011-08-16 08:07:28 +08:00
|
|
|
if (frame_sp)
|
2011-08-12 14:47:54 +08:00
|
|
|
{
|
2011-08-16 08:07:28 +08:00
|
|
|
SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry));
|
|
|
|
if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file)
|
|
|
|
{
|
|
|
|
Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
|
|
|
|
}
|
2011-08-12 14:47:54 +08:00
|
|
|
}
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DumpUsingSettingsFormat (strm, start_frame);
|
|
|
|
|
|
|
|
if (num_frames > 0)
|
|
|
|
{
|
|
|
|
strm.IndentMore();
|
|
|
|
|
|
|
|
const bool show_frame_info = true;
|
2011-07-26 10:39:59 +08:00
|
|
|
strm.IndentMore ();
|
2012-03-29 09:41:38 +08:00
|
|
|
num_frames_shown = GetStackFrameList ()->GetStatus (strm,
|
|
|
|
start_frame,
|
|
|
|
num_frames,
|
|
|
|
show_frame_info,
|
2012-07-12 04:33:48 +08:00
|
|
|
num_frames_with_source);
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
strm.IndentLess();
|
2011-07-26 10:39:59 +08:00
|
|
|
strm.IndentLess();
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
}
|
|
|
|
return num_frames_shown;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
Thread::GetStackFrameStatus (Stream& strm,
|
|
|
|
uint32_t first_frame,
|
|
|
|
uint32_t num_frames,
|
|
|
|
bool show_frame_info,
|
2012-07-12 04:33:48 +08:00
|
|
|
uint32_t num_frames_with_source)
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
{
|
2012-03-29 09:41:38 +08:00
|
|
|
return GetStackFrameList()->GetStatus (strm,
|
|
|
|
first_frame,
|
|
|
|
num_frames,
|
|
|
|
show_frame_info,
|
2012-07-12 04:33:48 +08:00
|
|
|
num_frames_with_source);
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
}
|
|
|
|
|
2011-06-04 04:40:54 +08:00
|
|
|
bool
|
|
|
|
Thread::SaveFrameZeroState (RegisterCheckpoint &checkpoint)
|
|
|
|
{
|
|
|
|
lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0));
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
checkpoint.SetStackID(frame_sp->GetStackID());
|
2013-04-03 04:32:37 +08:00
|
|
|
lldb::RegisterContextSP reg_ctx_sp (frame_sp->GetRegisterContext());
|
|
|
|
if (reg_ctx_sp)
|
|
|
|
return reg_ctx_sp->ReadAllRegisterValues (checkpoint.GetData());
|
2011-06-04 04:40:54 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Thread::RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint)
|
2012-09-12 08:40:39 +08:00
|
|
|
{
|
|
|
|
return ResetFrameZeroRegisters (checkpoint.GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Thread::ResetFrameZeroRegisters (lldb::DataBufferSP register_data_sp)
|
2011-06-04 04:40:54 +08:00
|
|
|
{
|
|
|
|
lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0));
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
2013-04-03 04:32:37 +08:00
|
|
|
lldb::RegisterContextSP reg_ctx_sp (frame_sp->GetRegisterContext());
|
|
|
|
if (reg_ctx_sp)
|
|
|
|
{
|
|
|
|
bool ret = reg_ctx_sp->WriteAllRegisterValues (register_data_sp);
|
|
|
|
|
|
|
|
// Clear out all stack frames as our world just changed.
|
|
|
|
ClearStackFrames();
|
|
|
|
reg_ctx_sp->InvalidateIfNeeded(true);
|
|
|
|
if (m_unwinder_ap.get())
|
|
|
|
m_unwinder_ap->Clear();
|
|
|
|
return ret;
|
|
|
|
}
|
2011-06-04 04:40:54 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
|
2011-08-22 10:49:39 +08:00
|
|
|
Unwind *
|
|
|
|
Thread::GetUnwinder ()
|
|
|
|
{
|
|
|
|
if (m_unwinder_ap.get() == NULL)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
const ArchSpec target_arch (CalculateTarget()->GetArchitecture ());
|
2011-08-22 10:49:39 +08:00
|
|
|
const llvm::Triple::ArchType machine = target_arch.GetMachine();
|
|
|
|
switch (machine)
|
|
|
|
{
|
|
|
|
case llvm::Triple::x86_64:
|
|
|
|
case llvm::Triple::x86:
|
|
|
|
case llvm::Triple::arm:
|
|
|
|
case llvm::Triple::thumb:
|
|
|
|
m_unwinder_ap.reset (new UnwindLLDB (*this));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple)
|
|
|
|
m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_unwinder_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-18 10:38:05 +08:00
|
|
|
void
|
|
|
|
Thread::Flush ()
|
|
|
|
{
|
|
|
|
ClearStackFrames ();
|
|
|
|
m_reg_context_sp.reset();
|
|
|
|
}
|
2012-10-16 08:09:33 +08:00
|
|
|
|
2012-11-20 08:11:13 +08:00
|
|
|
bool
|
2012-10-16 08:09:33 +08:00
|
|
|
Thread::IsStillAtLastBreakpointHit ()
|
|
|
|
{
|
|
|
|
// If we are currently stopped at a breakpoint, always return that stopinfo and don't reset it.
|
|
|
|
// This allows threads to maintain their breakpoint stopinfo, such as when thread-stepping in
|
|
|
|
// multithreaded programs.
|
2013-05-09 09:55:29 +08:00
|
|
|
if (m_stop_info_sp) {
|
|
|
|
StopReason stop_reason = m_stop_info_sp->GetStopReason();
|
2012-10-16 08:09:33 +08:00
|
|
|
if (stop_reason == lldb::eStopReasonBreakpoint) {
|
2013-05-09 09:55:29 +08:00
|
|
|
uint64_t value = m_stop_info_sp->GetValue();
|
2013-04-03 04:32:37 +08:00
|
|
|
lldb::RegisterContextSP reg_ctx_sp (GetRegisterContext());
|
|
|
|
if (reg_ctx_sp)
|
|
|
|
{
|
|
|
|
lldb::addr_t pc = reg_ctx_sp->GetPC();
|
|
|
|
BreakpointSiteSP bp_site_sp = GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
|
|
|
|
if (bp_site_sp && value == bp_site_sp->GetID())
|
|
|
|
return true;
|
|
|
|
}
|
2012-10-16 08:09:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|