diff options
-rw-r--r-- | include/lldb/API/SBThread.h | 3 | ||||
-rw-r--r-- | include/lldb/API/SBValue.h | 1 | ||||
-rw-r--r-- | include/lldb/Target/ABI.h | 5 | ||||
-rw-r--r-- | include/lldb/Target/Thread.h | 10 | ||||
-rw-r--r-- | lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme | 1 | ||||
-rw-r--r-- | scripts/Python/interface/SBThread.i | 3 | ||||
-rw-r--r-- | source/API/SBThread.cpp | 23 | ||||
-rw-r--r-- | source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 7 | ||||
-rw-r--r-- | source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h | 3 | ||||
-rw-r--r-- | source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 7 | ||||
-rw-r--r-- | source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h | 3 | ||||
-rw-r--r-- | source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 7 | ||||
-rw-r--r-- | source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h | 3 | ||||
-rw-r--r-- | source/Target/Thread.cpp | 64 |
14 files changed, 138 insertions, 2 deletions
diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h index 343b32f9f..082b99e92 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -101,6 +101,9 @@ public: void RunToAddress (lldb::addr_t addr); + + SBError + ReturnToFrame (SBFrame &frame, SBValue &return_value); //-------------------------------------------------------------------------- /// LLDB currently supports process centric debugging which means when any diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h index b53cbb029..0cff1a0d3 100644 --- a/include/lldb/API/SBValue.h +++ b/include/lldb/API/SBValue.h @@ -383,6 +383,7 @@ public: protected: friend class SBValueList; friend class SBFrame; + friend class SBThread; lldb::ValueObjectSP GetSP () const; diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 1a0989f62..eb0ae2883 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -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 @@ public: 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. diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index 0dcced76e..d252001c6 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -285,6 +285,12 @@ public: 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 @@ protected: 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 (); diff --git a/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme b/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme index 7424b64d6..101410da8 100644 --- a/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme +++ b/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme @@ -90,7 +90,6 @@ buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "YES" debugDocumentVersioning = "YES" - enableOpenGLFrameCaptureMode = "0" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference diff --git a/scripts/Python/interface/SBThread.i b/scripts/Python/interface/SBThread.i index 2f012ecf7..e53d255e9 100644 --- a/scripts/Python/interface/SBThread.i +++ b/scripts/Python/interface/SBThread.i @@ -130,6 +130,9 @@ public: 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 diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index fd692641f..74df380e3 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -877,6 +877,29 @@ SBThread::StepOverUntil (lldb::SBFrame &sb_frame, 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() diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 384c7eea7..565819c6c 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -507,6 +507,13 @@ ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread, 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) { diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h index be9a1838f..5e781be9a 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -41,6 +41,9 @@ public: 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, diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index 7f16ae3b2..36e599501 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -774,6 +774,13 @@ ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread, 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) { diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h index ec18678f1..6dcfff52a 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -51,6 +51,9 @@ public: 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, diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 677a4afed..0baf6ba39 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -959,6 +959,13 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &ast_type 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) { diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h index 04801e04e..31c1f8437 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -45,6 +45,9 @@ public: 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, diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp index 05ab15068..72c526148 100644 --- a/source/Target/Thread.cpp +++ b/source/Target/Thread.cpp @@ -1271,6 +1271,62 @@ Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx) 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 @@ Thread::SaveFrameZeroState (RegisterCheckpoint &checkpoint) 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(); |