[Lldb-commits] [lldb] r194111 - Add a new GetThreadOriginExtendedBacktrace method to the
Jason Molenda
jmolenda at apple.com
Tue Nov 5 16:04:44 PST 2013
Author: jmolenda
Date: Tue Nov 5 18:04:44 2013
New Revision: 194111
URL: http://llvm.org/viewvc/llvm-project?rev=194111&view=rev
Log:
Add a new GetThreadOriginExtendedBacktrace method to the
SystemRuntime and SBThread classes.
<rdar://problem/15314369>
Modified:
lldb/trunk/include/lldb/API/SBThread.h
lldb/trunk/include/lldb/Target/SystemRuntime.h
lldb/trunk/scripts/Python/interface/SBThread.i
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/Target/SystemRuntime.cpp
Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=194111&r1=194110&r2=194111&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Tue Nov 5 18:04:44 2013
@@ -201,6 +201,9 @@ public:
bool
GetStatus (lldb::SBStream &status) const;
+ SBThread
+ GetThreadOriginExtendedBacktrace (const char *type);
+
protected:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
Modified: lldb/trunk/include/lldb/Target/SystemRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/SystemRuntime.h?rev=194111&r1=194110&r2=194111&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/SystemRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/SystemRuntime.h Tue Nov 5 18:04:44 2013
@@ -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.
Modified: lldb/trunk/scripts/Python/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=194111&r1=194110&r2=194111&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBThread.i (original)
+++ lldb/trunk/scripts/Python/interface/SBThread.i Tue Nov 5 18:04:44 2013
@@ -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.'''
Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=194111&r1=194110&r2=194111&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Tue Nov 5 18:04:44 2013
@@ -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 &desc
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;
+}
Modified: lldb/trunk/source/Target/SystemRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SystemRuntime.cpp?rev=194111&r1=194110&r2=194111&view=diff
==============================================================================
--- lldb/trunk/source/Target/SystemRuntime.cpp (original)
+++ lldb/trunk/source/Target/SystemRuntime.cpp Tue Nov 5 18:04:44 2013
@@ -65,3 +65,9 @@ SystemRuntime::GetThreadOriginExtendedBa
std::vector<ConstString> types;
return types;
}
+
+ThreadSP
+SystemRuntime::GetThreadOriginExtendedBacktrace (ThreadSP thread, ConstString type)
+{
+ return ThreadSP();
+}
More information about the lldb-commits
mailing list