Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add helper functions for creating return value variables.

  • Loading branch information...
commit c7ca91ffd364a32a50b3b563c6978b8a94417ded 1 parent dc693e9
@anevilyak anevilyak authored
View
76 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 @@ struct DwarfStackFrameDebugInfo::DwarfLocalVariableID : public LocalVariableID {
};
+// #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
@@ -235,6 +278,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
DwarfStackFrameDebugInfo::_CreateVariable(ObjectID* id, const BString& name,
DIEType* typeEntry, LocationDescription* locationDescription,
Variable*& _variable)
View
7 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 @@ class DwarfStackFrameDebugInfo : public StackFrameDebugInfo {
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,
Please sign in to comment.
Something went wrong with that request. Please try again.