Add helper functions for creating return value variables.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2012, Rene Gollent, [email protected].
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
#include "LocalVariableID.h"
|
#include "LocalVariableID.h"
|
||||||
#include "Register.h"
|
#include "Register.h"
|
||||||
#include "RegisterMap.h"
|
#include "RegisterMap.h"
|
||||||
|
#include "ReturnValueID.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
#include "Tracing.h"
|
#include "Tracing.h"
|
||||||
#include "ValueLocation.h"
|
#include "ValueLocation.h"
|
||||||
@@ -117,6 +119,47 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - DwarfReturnValueID
|
||||||
|
|
||||||
|
|
||||||
|
struct DwarfStackFrameDebugInfo::DwarfReturnValueID
|
||||||
|
: public ReturnValueID {
|
||||||
|
|
||||||
|
DwarfReturnValueID(FunctionID* functionID)
|
||||||
|
:
|
||||||
|
fFunctionID(functionID),
|
||||||
|
fName("(returned)")
|
||||||
|
{
|
||||||
|
fFunctionID->AcquireReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~DwarfReturnValueID()
|
||||||
|
{
|
||||||
|
fFunctionID->ReleaseReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool operator==(const ObjectID& other) const
|
||||||
|
{
|
||||||
|
const DwarfReturnValueID* returnValueID
|
||||||
|
= dynamic_cast<const DwarfReturnValueID*>(&other);
|
||||||
|
return returnValueID != NULL
|
||||||
|
&& *fFunctionID == *returnValueID->fFunctionID
|
||||||
|
&& fName == returnValueID->fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual uint32 ComputeHashValue() const
|
||||||
|
{
|
||||||
|
uint32 hash = fFunctionID->HashValue();
|
||||||
|
return hash * 25 + StringUtils::HashValue(fName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionID* fFunctionID;
|
||||||
|
const BString fName;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - DwarfStackFrameDebugInfo
|
// #pragma mark - DwarfStackFrameDebugInfo
|
||||||
|
|
||||||
|
|
||||||
@@ -234,6 +277,39 @@ DwarfStackFrameDebugInfo::CreateLocalVariable(FunctionID* functionID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID,
|
||||||
|
DIEType* returnType, ValueLocation* location, Variable*& _variable)
|
||||||
|
{
|
||||||
|
if (returnType == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
// create the type
|
||||||
|
DwarfType* type;
|
||||||
|
status_t error = fTypeFactory->CreateType(returnType, type);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
BReference<DwarfType> typeReference(type, true);
|
||||||
|
|
||||||
|
DwarfReturnValueID* id = new(std::nothrow) DwarfReturnValueID(
|
||||||
|
functionID);
|
||||||
|
if (id == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
BString name;
|
||||||
|
name.SetToFormat("%s returned", functionID->FunctionName().String());
|
||||||
|
|
||||||
|
Variable* variable = new(std::nothrow) Variable(id, name,
|
||||||
|
type, location);
|
||||||
|
if (variable == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
_variable = variable;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DwarfStackFrameDebugInfo::_CreateVariable(ObjectID* id, const BString& name,
|
DwarfStackFrameDebugInfo::_CreateVariable(ObjectID* id, const BString& name,
|
||||||
DIEType* typeEntry, LocationDescription* locationDescription,
|
DIEType* typeEntry, LocationDescription* locationDescription,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2012, Rene Gollent, [email protected].
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -56,10 +57,16 @@ public:
|
|||||||
DIEVariable* variableEntry,
|
DIEVariable* variableEntry,
|
||||||
Variable*& _variable);
|
Variable*& _variable);
|
||||||
// returns reference
|
// returns reference
|
||||||
|
status_t CreateReturnValue(FunctionID* functionID,
|
||||||
|
DIEType* returnType,
|
||||||
|
ValueLocation* location,
|
||||||
|
Variable*& _variable);
|
||||||
|
// returns reference
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DwarfFunctionParameterID;
|
struct DwarfFunctionParameterID;
|
||||||
struct DwarfLocalVariableID;
|
struct DwarfLocalVariableID;
|
||||||
|
struct DwarfReturnValueID;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _CreateVariable(ObjectID* id,
|
status_t _CreateVariable(ObjectID* id,
|
||||||
|
|||||||
Reference in New Issue
Block a user