From 2c6fab1de6779fecadc6777425b05dd1c263b591 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 29 Mar 2013 21:06:59 -0400 Subject: [PATCH] Handle return value CPU states. - DwarfStackFrameDebugInfo::CreateReturnValue() now takes a cpu state parameter. This is attached to the associated Variable object. - ResolveValueNodeJob() now checks if the value node child it's dealing with is that of a variable. If so it pulls that CpuState for the ValueLoader's purposes rather than the current state. This gets return values for multiple function calls in the same statement working. --- .../debugger/debug_info/DwarfImageDebugInfo.cpp | 2 +- .../debug_info/DwarfStackFrameDebugInfo.cpp | 6 ++++-- .../debugger/debug_info/DwarfStackFrameDebugInfo.h | 2 ++ src/apps/debugger/jobs/ResolveValueNodeJob.cpp | 13 +++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 026b98320a..b9dad3117d 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -1166,7 +1166,7 @@ DwarfImageDebugInfo::_CreateReturnValues(ReturnValueInfoList* returnValueInfos, BReference idReference( targetFunction->GetFunctionID(), true); result = factory.CreateReturnValue(idReference, returnType, - location, variable); + location, subroutineState, variable); if (result != B_OK) return result; diff --git a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp index 42cef634e4..b2fe7b30ec 100644 --- a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp @@ -11,6 +11,7 @@ #include "Architecture.h" #include "CompilationUnit.h" +#include "CpuState.h" #include "DebugInfoEntries.h" #include "Dwarf.h" #include "DwarfFile.h" @@ -279,7 +280,8 @@ DwarfStackFrameDebugInfo::CreateLocalVariable(FunctionID* functionID, status_t DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID, - DIEType* returnType, ValueLocation* location, Variable*& _variable) + DIEType* returnType, ValueLocation* location, CpuState* state, + Variable*& _variable) { if (returnType == NULL) return B_BAD_VALUE; @@ -300,7 +302,7 @@ DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID, name.SetToFormat("%s returned", functionID->FunctionName().String()); Variable* variable = new(std::nothrow) Variable(id, name, - type, location); + type, location, state); if (variable == NULL) return B_NO_MEMORY; diff --git a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h index 3e691308f3..86ef5b7bff 100644 --- a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h @@ -14,6 +14,7 @@ class CompilationUnit; +class CpuState; class DIEFormalParameter; class DIESubprogram; class DIEType; @@ -60,6 +61,7 @@ public: status_t CreateReturnValue(FunctionID* functionID, DIEType* returnType, ValueLocation* location, + CpuState* state, Variable*& _variable); // returns reference diff --git a/src/apps/debugger/jobs/ResolveValueNodeJob.cpp b/src/apps/debugger/jobs/ResolveValueNodeJob.cpp index c810ad5c3e..13712e3a6f 100644 --- a/src/apps/debugger/jobs/ResolveValueNodeJob.cpp +++ b/src/apps/debugger/jobs/ResolveValueNodeJob.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2013, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -18,6 +18,8 @@ #include "ValueLocation.h" #include "ValueNode.h" #include "ValueNodeContainer.h" +#include "Variable.h" +#include "VariableValueNodeChild.h" ResolveValueNodeValueJob::ResolveValueNodeValueJob( @@ -144,9 +146,16 @@ ResolveValueNodeValueJob::_ResolveNodeValue() } } + CpuState* variableCpuState = NULL; + VariableValueNodeChild* variableChild = dynamic_cast< + VariableValueNodeChild*>(nodeChild); + if (variableChild != NULL) + variableCpuState = variableChild->GetVariable()->GetCpuState(); + // resolve the node location and value ValueLoader valueLoader(fArchitecture, fDebuggerInterface, - fTypeInformation, fCpuState); + fTypeInformation, variableCpuState != NULL ? variableCpuState + : fCpuState); ValueLocation* location; Value* value; status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader,