forked from OSchip/llvm-project
Add a new GetThreadOriginExtendedBacktrace method to the
SystemRuntime and SBThread classes. <rdar://problem/15314369> llvm-svn: 194111
This commit is contained in:
parent
7e77a294dc
commit
5dd4916f63
|
@ -201,6 +201,9 @@ public:
|
|||
bool
|
||||
GetStatus (lldb::SBStream &status) const;
|
||||
|
||||
SBThread
|
||||
GetThreadOriginExtendedBacktrace (const char *type);
|
||||
|
||||
protected:
|
||||
friend class SBBreakpoint;
|
||||
friend class SBBreakpointLocation;
|
||||
|
|
|
@ -130,6 +130,36 @@ public:
|
|||
virtual std::vector<ConstString>
|
||||
GetThreadOriginExtendedBacktraceTypes ();
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Return a Thread which shows the origin of this thread's creation.
|
||||
///
|
||||
/// This likely returns a HistoryThread which shows how thread was
|
||||
/// originally created (e.g. "pthread" type), or how the work that
|
||||
/// is currently executing on it was originally enqueued (e.g.
|
||||
/// "libdispatch" type).
|
||||
///
|
||||
/// There may be a chain of thread-origins; it may be informative to
|
||||
/// the end user to query the returned ThreadSP for its origins as
|
||||
/// well.
|
||||
///
|
||||
/// @param [in] thread
|
||||
/// The thread to examine.
|
||||
///
|
||||
/// @param [in] type
|
||||
/// The type of thread origin being requested. The types supported
|
||||
/// are returned from SystemRuntime::GetThreadOriginExtendedBacktraceTypes.
|
||||
///
|
||||
/// @return
|
||||
/// A ThreadSP which will have a StackList of frames. This Thread will
|
||||
/// not appear in the Process' list of current threads. Normal thread
|
||||
/// operations like stepping will not be available. This is a historical
|
||||
/// view thread and may be only useful for showing a backtrace.
|
||||
///
|
||||
/// An empty ThreadSP will be returned if no thread origin is available.
|
||||
//------------------------------------------------------------------
|
||||
virtual lldb::ThreadSP
|
||||
GetThreadOriginExtendedBacktrace (lldb::ThreadSP thread, ConstString type);
|
||||
|
||||
protected:
|
||||
//------------------------------------------------------------------
|
||||
// Member variables.
|
||||
|
|
|
@ -240,6 +240,19 @@ public:
|
|||
bool
|
||||
operator != (const lldb::SBThread &rhs) const;
|
||||
|
||||
%feature("autodoc","
|
||||
Given an argument of str to specify the type of thread-origin extended
|
||||
backtrace to retrieve, query whether the origin of this thread is
|
||||
available. An SBThread is retured; SBThread.IsValid will return true
|
||||
if an extended backtrace was available. The returned SBThread is not
|
||||
a part of the SBProcess' thread list and it cannot be manipulated like
|
||||
normal threads -- you cannot step or resume it, for instance -- it is
|
||||
intended to used primarily for generating a backtrace. You may request
|
||||
the returned thread's own thread origin in turn.
|
||||
") GetThreadOriginExtendedBacktrace;
|
||||
lldb::SBThread
|
||||
GetThreadOriginExtendedBacktrace (const char *type);
|
||||
|
||||
%pythoncode %{
|
||||
class frames_access(object):
|
||||
'''A helper object that will lazily hand out frames for a thread when supplied an index.'''
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "lldb/Core/Stream.h"
|
||||
#include "lldb/Core/StreamFile.h"
|
||||
#include "lldb/Interpreter/CommandInterpreter.h"
|
||||
#include "lldb/Target/SystemRuntime.h"
|
||||
#include "lldb/Target/Thread.h"
|
||||
#include "lldb/Target/Process.h"
|
||||
#include "lldb/Symbol/SymbolContext.h"
|
||||
|
@ -1280,3 +1281,38 @@ SBThread::GetDescription (SBStream &description) const
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
SBThread
|
||||
SBThread::GetThreadOriginExtendedBacktrace (const char *type)
|
||||
{
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
Mutex::Locker api_locker;
|
||||
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
|
||||
SBThread sb_origin_thread;
|
||||
|
||||
if (exe_ctx.HasThreadScope())
|
||||
{
|
||||
Process::StopLocker stop_locker;
|
||||
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
|
||||
{
|
||||
ThreadSP real_thread(exe_ctx.GetThreadPtr());
|
||||
if (real_thread)
|
||||
{
|
||||
ConstString type_const (type);
|
||||
SystemRuntime *runtime = exe_ctx.GetProcessPtr()->GetSystemRuntime();
|
||||
if (runtime)
|
||||
{
|
||||
ThreadSP origin_thread = runtime->GetThreadOriginExtendedBacktrace (real_thread, type_const);
|
||||
sb_origin_thread.SetThread (origin_thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (log)
|
||||
log->Printf ("SBThread(%p)::GetThreadOriginExtendedBacktrace() => error: process is running", exe_ctx.GetThreadPtr());
|
||||
}
|
||||
}
|
||||
|
||||
return sb_origin_thread;
|
||||
}
|
||||
|
|
|
@ -65,3 +65,9 @@ SystemRuntime::GetThreadOriginExtendedBacktraceTypes ()
|
|||
std::vector<ConstString> types;
|
||||
return types;
|
||||
}
|
||||
|
||||
ThreadSP
|
||||
SystemRuntime::GetThreadOriginExtendedBacktrace (ThreadSP thread, ConstString type)
|
||||
{
|
||||
return ThreadSP();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue