summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBThread.h3
-rw-r--r--lldb/include/lldb/Target/SystemRuntime.h30
-rw-r--r--lldb/scripts/Python/interface/SBThread.i13
-rw-r--r--lldb/source/API/SBThread.cpp36
-rw-r--r--lldb/source/Target/SystemRuntime.cpp6
5 files changed, 88 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 3d8770c8671..d2d7346e283 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -201,6 +201,9 @@ public:
bool
GetStatus (lldb::SBStream &status) const;
+ SBThread
+ GetThreadOriginExtendedBacktrace (const char *type);
+
protected:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
diff --git a/lldb/include/lldb/Target/SystemRuntime.h b/lldb/include/lldb/Target/SystemRuntime.h
index bd012df59ae..ffa97c6af08 100644
--- a/lldb/include/lldb/Target/SystemRuntime.h
+++ b/lldb/include/lldb/Target/SystemRuntime.h
@@ -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.
diff --git a/lldb/scripts/Python/interface/SBThread.i b/lldb/scripts/Python/interface/SBThread.i
index 4f678b6353c..3337c8d7848 100644
--- a/lldb/scripts/Python/interface/SBThread.i
+++ b/lldb/scripts/Python/interface/SBThread.i
@@ -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.'''
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 0c3a17e0df8..8a7877d39c9 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -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;
+}
diff --git a/lldb/source/Target/SystemRuntime.cpp b/lldb/source/Target/SystemRuntime.cpp
index bac512ebd25..06021665b5d 100644
--- a/lldb/source/Target/SystemRuntime.cpp
+++ b/lldb/source/Target/SystemRuntime.cpp
@@ -65,3 +65,9 @@ SystemRuntime::GetThreadOriginExtendedBacktraceTypes ()
std::vector<ConstString> types;
return types;
}
+
+ThreadSP
+SystemRuntime::GetThreadOriginExtendedBacktrace (ThreadSP thread, ConstString type)
+{
+ return ThreadSP();
+}
OpenPOWER on IntegriCloud