Author: jingham Date: Thu Jul 7 21:12:05 2016 New Revision: 274822 URL: http://llvm.org/viewvc/llvm-project?rev=274822&view=rev Log: Add an API to unwind from a hand-called expression.
This is just an SB API way of doing "thread return -x". <rdar://problem/27110360> Modified: lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/scripts/interface/SBThread.i lldb/trunk/source/API/SBThread.cpp Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=274822&r1=274821&r2=274822&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Thu Jul 7 21:12:05 2016 @@ -150,6 +150,9 @@ public: SBError ReturnFromFrame (SBFrame &frame, SBValue &return_value); + SBError + UnwindInnermostExpression(); + //-------------------------------------------------------------------------- /// LLDB currently supports process centric debugging which means when any /// thread in a process stops, all other threads are stopped. The Suspend() Modified: lldb/trunk/scripts/interface/SBThread.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBThread.i?rev=274822&r1=274821&r2=274822&view=diff ============================================================================== --- lldb/trunk/scripts/interface/SBThread.i (original) +++ lldb/trunk/scripts/interface/SBThread.i Thu Jul 7 21:12:05 2016 @@ -259,6 +259,14 @@ public: SBError ReturnFromFrame (SBFrame &frame, SBValue &return_value); + %feature("autodoc", " + Unwind the stack frames from the innermost expression evaluation. + This API is equivalent to 'thread return -x'. + ") UnwindInnermostExpression; + + SBError + UnwindInnermostExpression(); + %feature("docstring", " //-------------------------------------------------------------------------- /// LLDB currently supports process centric debugging which means when any Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=274822&r1=274821&r2=274822&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Thu Jul 7 21:12:05 2016 @@ -1249,6 +1249,31 @@ SBThread::ReturnFromFrame (SBFrame &fram return sb_error; } +SBError +SBThread::UnwindInnermostExpression() +{ + SBError sb_error; + + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); + + if (log) + log->Printf ("SBThread(%p)::UnwindExpressionEvaluation", + static_cast<void*>(exe_ctx.GetThreadPtr())); + + if (exe_ctx.HasThreadScope()) + { + Thread *thread = exe_ctx.GetThreadPtr(); + sb_error.SetError (thread->UnwindInnermostExpression()); + if (sb_error.Success()) + thread->SetSelectedFrameByIndex(0, false); + } + + return sb_error; + +} bool SBThread::Suspend() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits