diff options
author | Jim Ingham <jingham@apple.com> | 2011-12-17 01:35:57 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2011-12-17 01:35:57 +0000 |
commit | 73ca05a2a0c6ce957f9679e76b35ee06dc1559d4 (patch) | |
tree | 20b0f08ba2a6812f994fdea521bf436ea25453ce /lldb/source/Core | |
parent | 903231bc58b27bbd1b74622b013fa277ceaeb16f (diff) | |
download | bcm5719-llvm-73ca05a2a0c6ce957f9679e76b35ee06dc1559d4.tar.gz bcm5719-llvm-73ca05a2a0c6ce957f9679e76b35ee06dc1559d4.zip |
Add the ability to capture the return value in a thread's stop info, and print it
as part of the thread format output.
Currently this is only done for the ThreadPlanStepOut.
Add a convenience API ABI::GetReturnValueObject.
Change the ValueObject::EvaluationPoint to BE an ExecutionContextScope, rather than
trying to hand out one of its subsidiary object's pointers. That way this will always
be good.
llvm-svn: 146806
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 18 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 70 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectConstResult.cpp | 24 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectConstResultImpl.cpp | 2 |
4 files changed, 97 insertions, 17 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index cd86698661a..e33e9412c91 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1701,6 +1701,23 @@ Debugger::FormatPrompt } } } + else if (::strncmp (var_name_begin, "return-value}", strlen("return-value}")) == 0) + { + StopInfoSP stop_info_sp = thread->GetStopInfo (); + if (stop_info_sp) + { + ValueObjectSP return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp); + if (return_valobj_sp) + { + cstr = return_valobj_sp->GetValueAsCString (); + if (cstr && cstr[0]) + { + s.PutCString(cstr); + var_success = true; + } + } + } + } } } } @@ -2562,6 +2579,7 @@ Debugger::SettingsController::global_settings_table[] = MODULE_WITH_FUNC\ FILE_AND_LINE\ "{, stop reason = ${thread.stop-reason}}"\ + "{, return value = ${thread.return-value}}"\ "\\n" //#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 657faf36f85..e1c25becbc7 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -707,7 +707,7 @@ ValueObject::GetPointeeData (DataExtractor& data, AddressType addr_type; lldb::addr_t addr = IsPointerType() ? GetPointerValue(&addr_type) : GetAddressOf(true, &addr_type); - ExecutionContextScope *exe_scope = m_update_point.GetExecutionContextScope(); + ExecutionContextScope *exe_scope = GetExecutionContextScope(); switch (addr_type) @@ -3428,12 +3428,14 @@ ValueObject::CastPointerType (const char *name, TypeSP &type_sp) } ValueObject::EvaluationPoint::EvaluationPoint () : + ExecutionContextScope(), m_thread_id (LLDB_INVALID_UID), m_mod_id () { } ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected): + ExecutionContextScope (), m_needs_update (true), m_first_update (true), m_thread_id (LLDB_INVALID_THREAD_ID), @@ -3500,14 +3502,47 @@ ValueObject::EvaluationPoint::~EvaluationPoint () { } -ExecutionContextScope * -ValueObject::EvaluationPoint::GetExecutionContextScope () +Target * +ValueObject::EvaluationPoint::CalculateTarget () { - // We have to update before giving out the scope, or we could be handing out stale pointers. - ExecutionContextScope *exe_scope; + return m_target_sp.get(); +} + +Process * +ValueObject::EvaluationPoint::CalculateProcess () +{ + return m_process_sp.get(); +} + +Thread * +ValueObject::EvaluationPoint::CalculateThread () +{ + ExecutionContextScope *exe_scope; SyncWithProcessState(exe_scope); - - return exe_scope; + if (exe_scope) + return exe_scope->CalculateThread(); + else + return NULL; +} + +StackFrame * +ValueObject::EvaluationPoint::CalculateStackFrame () +{ + ExecutionContextScope *exe_scope; + SyncWithProcessState(exe_scope); + if (exe_scope) + return exe_scope->CalculateStackFrame(); + else + return NULL; +} + +void +ValueObject::EvaluationPoint::CalculateExecutionContext (ExecutionContext &exe_ctx) +{ + ExecutionContextScope *exe_scope; + SyncWithProcessState(exe_scope); + if (exe_scope) + return exe_scope->CalculateExecutionContext (exe_ctx); } // This function checks the EvaluationPoint against the current process state. If the current @@ -3520,12 +3555,18 @@ ValueObject::EvaluationPoint::GetExecutionContextScope () bool ValueObject::EvaluationPoint::SyncWithProcessState(ExecutionContextScope *&exe_scope) { + + // Start with the target, if it is NULL, then we're obviously not going to get any further: + exe_scope = m_target_sp.get(); + + if (exe_scope == NULL) + return false; + // If we don't have a process nothing can change. if (!m_process_sp) - { - exe_scope = m_target_sp.get(); return false; - } + + exe_scope = m_process_sp.get(); // If our stop id is the current stop ID, nothing has changed: ProcessModID current_mod_id = m_process_sp->GetModID(); @@ -3533,10 +3574,7 @@ ValueObject::EvaluationPoint::SyncWithProcessState(ExecutionContextScope *&exe_s // If the current stop id is 0, either we haven't run yet, or the process state has been cleared. // In either case, we aren't going to be able to sync with the process state. if (current_mod_id.GetStopID() == 0) - { - exe_scope = m_target_sp.get(); return false; - } bool changed; @@ -3555,10 +3593,10 @@ ValueObject::EvaluationPoint::SyncWithProcessState(ExecutionContextScope *&exe_s changed = true; } } - exe_scope = m_process_sp.get(); - // Something has changed, so we will return true. Now make sure the thread & frame still exist, and if either - // doesn't, mark ourselves as invalid. + // Now re-look up the thread and frame in case the underlying objects have gone away & been recreated. + // That way we'll be sure to return a valid exe_scope. + // If we used to have a thread or a frame but can't find it anymore, then mark ourselves as invalid. if (m_thread_id != LLDB_INVALID_THREAD_ID) { diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index fa1503f3217..950d33405af 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -130,6 +130,15 @@ ValueObjectConstResult::Create address))->GetSP(); } +ValueObjectSP +ValueObjectConstResult::Create (ExecutionContextScope *exe_scope, + clang::ASTContext *clang_ast, + Value &value, + const ConstString &name) +{ + return (new ValueObjectConstResult (exe_scope, clang_ast, value, name))->GetSP(); +} + ValueObjectConstResult::ValueObjectConstResult ( ExecutionContextScope *exe_scope, @@ -239,6 +248,21 @@ ValueObjectConstResult::ValueObjectConstResult ( SetIsConstant (); } +ValueObjectConstResult::ValueObjectConstResult ( + ExecutionContextScope *exe_scope, + clang::ASTContext *clang_ast, + const Value &value, + const ConstString &name) : + ValueObject (exe_scope), + m_type_name (), + m_byte_size (0), + m_clang_ast (clang_ast), + m_impl(this) +{ + m_value = value; + m_value.GetData(m_data); +} + ValueObjectConstResult::~ValueObjectConstResult() { } diff --git a/lldb/source/Core/ValueObjectConstResultImpl.cpp b/lldb/source/Core/ValueObjectConstResultImpl.cpp index afe050291b0..31646b4ca0b 100644 --- a/lldb/source/Core/ValueObjectConstResultImpl.cpp +++ b/lldb/source/Core/ValueObjectConstResultImpl.cpp @@ -185,7 +185,7 @@ ValueObjectConstResultImpl::AddressOf (Error &error) std::string new_name("&"); new_name.append(m_impl_backend->GetName().AsCString("")); - m_address_of_backend = ValueObjectConstResult::Create(m_impl_backend->GetUpdatePoint().GetExecutionContextScope(), + m_address_of_backend = ValueObjectConstResult::Create(m_impl_backend->GetExecutionContextScope(), type.GetASTContext(), type.GetPointerType(), ConstString(new_name.c_str()), |