[Lldb-commits] [lldb] r163670 - in /lldb/trunk: include/lldb/API/ include/lldb/Target/ lldb.xcodeproj/xcshareddata/xcschemes/ scripts/Python/interface/ source/API/ source/Plugins/ABI/MacOSX-arm/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Target/
Jim Ingham
jingham at apple.com
Tue Sep 11 17:40:39 PDT 2012
Author: jingham
Date: Tue Sep 11 19:40:39 2012
New Revision: 163670
URL: http://llvm.org/viewvc/llvm-project?rev=163670&view=rev
Log:
Start at getting "thread return" working. Doesn't work yet.
Modified:
lldb/trunk/include/lldb/API/SBThread.h
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Target/ABI.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
lldb/trunk/scripts/Python/interface/SBThread.i
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
lldb/trunk/source/Target/Thread.cpp
Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Tue Sep 11 19:40:39 2012
@@ -101,6 +101,9 @@
void
RunToAddress (lldb::addr_t addr);
+
+ SBError
+ ReturnToFrame (SBFrame &frame, SBValue &return_value);
//--------------------------------------------------------------------------
/// LLDB currently supports process centric debugging which means when any
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Tue Sep 11 19:40:39 2012
@@ -383,6 +383,7 @@
protected:
friend class SBValueList;
friend class SBFrame;
+ friend class SBThread;
lldb::ValueObjectSP
GetSP () const;
Modified: lldb/trunk/include/lldb/Target/ABI.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ABI.h (original)
+++ lldb/trunk/include/lldb/Target/ABI.h Tue Sep 11 19:40:39 2012
@@ -14,6 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/lldb-private.h"
@@ -50,6 +51,10 @@
GetReturnValueObject (Thread &thread,
ClangASTType &type,
bool persistent = true) const;
+
+ // Set the Return value object in the current frame as though a function with
+ virtual Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) = 0;
protected:
// This is the method the ABI will call to actually calculate the return value.
Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Sep 11 19:40:39 2012
@@ -285,6 +285,12 @@
return GetStackFrameList()->GetCurrentInlinedDepth();
}
+ Error
+ ReturnToFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp);
+
+ Error
+ ReturnToFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp);
+
virtual lldb::StackFrameSP
GetFrameWithStackID (const StackID &stack_id)
{
@@ -747,6 +753,10 @@
virtual bool
RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
+
+ // register_data_sp must be a DataSP passed to ReadAllRegisterValues.
+ bool
+ ResetFrameZeroRegisters (lldb::DataBufferSP register_data_sp);
virtual lldb_private::Unwind *
GetUnwinder ();
Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Sep 11 19:40:39 2012
@@ -90,7 +90,6 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "YES"
debugDocumentVersioning = "YES"
- enableOpenGLFrameCaptureMode = "0"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
Modified: lldb/trunk/scripts/Python/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBThread.i (original)
+++ lldb/trunk/scripts/Python/interface/SBThread.i Tue Sep 11 19:40:39 2012
@@ -130,6 +130,9 @@
void
RunToAddress (lldb::addr_t addr);
+ SBError
+ ReturnToFrame (SBFrame &frame, SBValue &return_value);
+
%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=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Tue Sep 11 19:40:39 2012
@@ -877,6 +877,29 @@
return sb_error;
}
+SBError
+SBThread::ReturnToFrame (SBFrame &frame, SBValue &return_value)
+{
+ SBError sb_error;
+
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ Mutex::Locker api_locker;
+ ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
+
+ if (log)
+ log->Printf ("SBThread(%p)::ReturnToFrame (frame=%d)", exe_ctx.GetThreadPtr(), frame.GetFrameID());
+
+ if (exe_ctx.HasThreadScope())
+ {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ sb_error.SetError (thread->ReturnToFrame(frame.GetFrameSP(), return_value.GetSP()));
+ }
+
+ return sb_error;
+}
+
bool
SBThread::Suspend()
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Tue Sep 11 19:40:39 2012
@@ -507,6 +507,13 @@
return return_valobj_sp;
}
+Error
+ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value)
+{
+ Error return_error("I can't do that yet Jim.");
+ return return_error;
+}
+
bool
ABIMacOSX_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
{
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Tue Sep 11 19:40:39 2012
@@ -41,6 +41,9 @@
GetArgumentValues (lldb_private::Thread &thread,
lldb_private::ValueList &values) const;
+ virtual lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+
protected:
virtual lldb::ValueObjectSP
GetReturnValueObjectImpl (lldb_private::Thread &thread,
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Sep 11 19:40:39 2012
@@ -774,6 +774,13 @@
return return_valobj_sp;
}
+Error
+ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value)
+{
+ Error return_error("I can't do that yet Jim.");
+ return return_error;
+}
+
bool
ABIMacOSX_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
{
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Tue Sep 11 19:40:39 2012
@@ -51,6 +51,9 @@
GetArgumentValues (lldb_private::Thread &thread,
lldb_private::ValueList &values) const;
+ virtual lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+
protected:
virtual lldb::ValueObjectSP
GetReturnValueObjectImpl (lldb_private::Thread &thread,
Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Tue Sep 11 19:40:39 2012
@@ -959,6 +959,13 @@
return return_valobj_sp;
}
+Error
+ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value)
+{
+ Error return_error("I can't do that yet Jim.");
+ return return_error;
+}
+
bool
ABISysV_x86_64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Tue Sep 11 19:40:39 2012
@@ -45,6 +45,9 @@
GetArgumentValues (lldb_private::Thread &thread,
lldb_private::ValueList &values) const;
+ virtual lldb_private::Error
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
+
protected:
lldb::ValueObjectSP
GetReturnValueObjectSimple (lldb_private::Thread &thread,
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=163670&r1=163669&r2=163670&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Sep 11 19:40:39 2012
@@ -1271,6 +1271,62 @@
return GetStackFrameList()->GetFrameWithConcreteFrameIndex (unwind_idx);
}
+
+Error
+Thread::ReturnToFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp)
+{
+ StackFrameSP frame_sp = GetStackFrameAtIndex (frame_idx);
+ Error return_error;
+
+ if (!frame_sp)
+ {
+ return_error.SetErrorStringWithFormat("Could not find frame with index %d in thread 0x%llx.", frame_idx, GetID());
+ }
+
+ return ReturnToFrame(frame_sp, return_value_sp);
+}
+
+Error
+Thread::ReturnToFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp)
+{
+ Error return_error;
+
+ if (!frame_sp)
+ {
+ return_error.SetErrorString("Can't return to a null frame.");
+ return return_error;
+ }
+
+ Thread *thread = frame_sp->GetThread().get();
+
+ if (return_value_sp)
+ {
+ lldb::ABISP abi = thread->GetProcess()->GetABI();
+ if (!abi)
+ {
+ return_error.SetErrorString("Could not find ABI to set return value.");
+ }
+ return_error = abi->SetReturnValueObject(frame_sp, return_value_sp);
+ if (!return_error.Success())
+ return return_error;
+ }
+
+ // Now write the return registers for the chosen frame:
+ lldb::DataBufferSP register_values_sp;
+ frame_sp->GetRegisterContext()->ReadAllRegisterValues (register_values_sp);
+ if (thread->ResetFrameZeroRegisters(register_values_sp))
+ {
+ thread->DiscardThreadPlans(true);
+ return return_error;
+ }
+ else
+ {
+ return_error.SetErrorString("Could not reset register values.");
+ return return_error;
+
+ }
+}
+
void
Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
{
@@ -1430,10 +1486,16 @@
bool
Thread::RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint)
{
+ return ResetFrameZeroRegisters (checkpoint.GetData());
+}
+
+bool
+Thread::ResetFrameZeroRegisters (lldb::DataBufferSP register_data_sp)
+{
lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0));
if (frame_sp)
{
- bool ret = frame_sp->GetRegisterContext()->WriteAllRegisterValues (checkpoint.GetData());
+ bool ret = frame_sp->GetRegisterContext()->WriteAllRegisterValues (register_data_sp);
// Clear out all stack frames as our world just changed.
ClearStackFrames();
More information about the lldb-commits
mailing list