This checkin is the first step in making the lldb thread stepping mechanism more accessible from

the user level.  It adds the ability to invent new stepping modes implemented by python classes,
and to view the current thread plan stack and to some extent alter it.

I haven't gotten to documentation or tests yet.  But this should not cause any behavior changes
if you don't use it, so its safe to check it in now and work on it incrementally.

llvm-svn: 218642
This commit is contained in:
Jim Ingham
2014-09-29 23:17:18 +00:00
parent 8b6fefb3a3
commit 2bdbfd50d2
38 changed files with 1896 additions and 322 deletions

View File

@@ -41,6 +41,7 @@
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBThreadPlan.h"
#include "lldb/API/SBValue.h"
using namespace lldb;
@@ -918,7 +919,9 @@ SBThread::RunToAddress (lldb::addr_t addr)
Thread *thread = exe_ctx.GetThreadPtr();
ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads));
ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress (abort_other_plans,
target_addr,
stop_other_threads));
// This returns an error, we should use it!
ResumeNewPlan (exe_ctx, new_plan_sp.get());
@@ -1072,6 +1075,46 @@ SBThread::StepOverUntil (lldb::SBFrame &sb_frame,
return sb_error;
}
SBError
SBThread::StepUsingScriptedThreadPlan (const char *script_class_name)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBError sb_error;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
if (log)
{
log->Printf ("SBThread(%p)::StepUsingScriptedThreadPlan: class name: %s",
static_cast<void*>(exe_ctx.GetThreadPtr()),
script_class_name);
}
if (!exe_ctx.HasThreadScope())
{
sb_error.SetErrorString("this SBThread object is invalid");
return sb_error;
}
Thread *thread = exe_ctx.GetThreadPtr();
ThreadPlanSP thread_plan_sp = thread->QueueThreadPlanForStepScripted(false, script_class_name, false);
if (thread_plan_sp)
sb_error = ResumeNewPlan(exe_ctx, thread_plan_sp.get());
else
{
sb_error.SetErrorStringWithFormat("Error queuing thread plan for class: %s.", script_class_name);
if (log)
log->Printf ("SBThread(%p)::StepUsingScriptedThreadPlan: Error queuing thread plan for class: %s",
static_cast<void*>(exe_ctx.GetThreadPtr()),
script_class_name);
}
return sb_error;
}
SBError
SBThread::JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line)
{
@@ -1473,7 +1516,8 @@ SBThread::GetExtendedBacktraceThread (const char *type)
const char *queue_name = new_thread_sp->GetQueueName();
if (queue_name == NULL)
queue_name = "";
log->Printf ("SBThread(%p)::GetExtendedBacktraceThread() => new extended Thread created (%p) with queue_id 0x%" PRIx64 " queue name '%s'",
log->Printf ("SBThread(%p)::GetExtendedBacktraceThread() => new extended Thread "
"created (%p) with queue_id 0x%" PRIx64 " queue name '%s'",
static_cast<void*>(exe_ctx.GetThreadPtr()),
static_cast<void*>(new_thread_sp.get()),
new_thread_sp->GetQueueID(),
@@ -1515,3 +1559,24 @@ SBThread::SafeToCallFunctions ()
return thread_sp->SafeToCallFunctions();
return true;
}
lldb_private::Thread *
SBThread::operator->()
{
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)
return thread_sp.get();
else
return NULL;
}
lldb_private::Thread *
SBThread::get()
{
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)
return thread_sp.get();
else
return NULL;
}