diff --git a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp index 99853ae8f3..42cef634e4 100644 --- a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2012, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -23,6 +24,7 @@ #include "LocalVariableID.h" #include "Register.h" #include "RegisterMap.h" +#include "ReturnValueID.h" #include "StringUtils.h" #include "Tracing.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(&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 @@ -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 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 DwarfStackFrameDebugInfo::_CreateVariable(ObjectID* id, const BString& name, DIEType* typeEntry, LocationDescription* locationDescription, diff --git a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h index e55d0d2ed1..3e691308f3 100644 --- a/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h @@ -1,4 +1,5 @@ /* + * Copyright 2012, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -56,10 +57,16 @@ public: DIEVariable* variableEntry, Variable*& _variable); // returns reference + status_t CreateReturnValue(FunctionID* functionID, + DIEType* returnType, + ValueLocation* location, + Variable*& _variable); + // returns reference private: struct DwarfFunctionParameterID; struct DwarfLocalVariableID; + struct DwarfReturnValueID; private: status_t _CreateVariable(ObjectID* id,