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.
This commit is contained in:
Rene Gollent 2013-03-29 21:06:59 -04:00
parent 47ffc32bc0
commit 2c6fab1de6
4 changed files with 18 additions and 5 deletions

View File

@ -1166,7 +1166,7 @@ DwarfImageDebugInfo::_CreateReturnValues(ReturnValueInfoList* returnValueInfos,
BReference<FunctionID> idReference( BReference<FunctionID> idReference(
targetFunction->GetFunctionID(), true); targetFunction->GetFunctionID(), true);
result = factory.CreateReturnValue(idReference, returnType, result = factory.CreateReturnValue(idReference, returnType,
location, variable); location, subroutineState, variable);
if (result != B_OK) if (result != B_OK)
return result; return result;

View File

@ -11,6 +11,7 @@
#include "Architecture.h" #include "Architecture.h"
#include "CompilationUnit.h" #include "CompilationUnit.h"
#include "CpuState.h"
#include "DebugInfoEntries.h" #include "DebugInfoEntries.h"
#include "Dwarf.h" #include "Dwarf.h"
#include "DwarfFile.h" #include "DwarfFile.h"
@ -279,7 +280,8 @@ DwarfStackFrameDebugInfo::CreateLocalVariable(FunctionID* functionID,
status_t status_t
DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID, DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID,
DIEType* returnType, ValueLocation* location, Variable*& _variable) DIEType* returnType, ValueLocation* location, CpuState* state,
Variable*& _variable)
{ {
if (returnType == NULL) if (returnType == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
@ -300,7 +302,7 @@ DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID,
name.SetToFormat("%s returned", functionID->FunctionName().String()); name.SetToFormat("%s returned", functionID->FunctionName().String());
Variable* variable = new(std::nothrow) Variable(id, name, Variable* variable = new(std::nothrow) Variable(id, name,
type, location); type, location, state);
if (variable == NULL) if (variable == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;

View File

@ -14,6 +14,7 @@
class CompilationUnit; class CompilationUnit;
class CpuState;
class DIEFormalParameter; class DIEFormalParameter;
class DIESubprogram; class DIESubprogram;
class DIEType; class DIEType;
@ -60,6 +61,7 @@ public:
status_t CreateReturnValue(FunctionID* functionID, status_t CreateReturnValue(FunctionID* functionID,
DIEType* returnType, DIEType* returnType,
ValueLocation* location, ValueLocation* location,
CpuState* state,
Variable*& _variable); Variable*& _variable);
// returns reference // returns reference

View File

@ -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. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -18,6 +18,8 @@
#include "ValueLocation.h" #include "ValueLocation.h"
#include "ValueNode.h" #include "ValueNode.h"
#include "ValueNodeContainer.h" #include "ValueNodeContainer.h"
#include "Variable.h"
#include "VariableValueNodeChild.h"
ResolveValueNodeValueJob::ResolveValueNodeValueJob( 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 // resolve the node location and value
ValueLoader valueLoader(fArchitecture, fDebuggerInterface, ValueLoader valueLoader(fArchitecture, fDebuggerInterface,
fTypeInformation, fCpuState); fTypeInformation, variableCpuState != NULL ? variableCpuState
: fCpuState);
ValueLocation* location; ValueLocation* location;
Value* value; Value* value;
status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader, status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader,