Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add helper functions for creating return value variables.

  • Loading branch information...
commit c7ca91ffd364a32a50b3b563c6978b8a94417ded 1 parent dc693e9
Rene Gollent anevilyak authored
76 src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp
... ... @@ -1,4 +1,5 @@
1 1 /*
  2 + * Copyright 2012, Rene Gollent, rene@gollent.com.
2 3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 4 * Distributed under the terms of the MIT License.
4 5 */
@@ -23,6 +24,7 @@
23 24 #include "LocalVariableID.h"
24 25 #include "Register.h"
25 26 #include "RegisterMap.h"
  27 +#include "ReturnValueID.h"
26 28 #include "StringUtils.h"
27 29 #include "Tracing.h"
28 30 #include "ValueLocation.h"
@@ -117,6 +119,47 @@ struct DwarfStackFrameDebugInfo::DwarfLocalVariableID : public LocalVariableID {
117 119 };
118 120
119 121
  122 +// #pragma mark - DwarfReturnValueID
  123 +
  124 +
  125 +struct DwarfStackFrameDebugInfo::DwarfReturnValueID
  126 + : public ReturnValueID {
  127 +
  128 + DwarfReturnValueID(FunctionID* functionID)
  129 + :
  130 + fFunctionID(functionID),
  131 + fName("(returned)")
  132 + {
  133 + fFunctionID->AcquireReference();
  134 + }
  135 +
  136 + virtual ~DwarfReturnValueID()
  137 + {
  138 + fFunctionID->ReleaseReference();
  139 + }
  140 +
  141 + virtual bool operator==(const ObjectID& other) const
  142 + {
  143 + const DwarfReturnValueID* returnValueID
  144 + = dynamic_cast<const DwarfReturnValueID*>(&other);
  145 + return returnValueID != NULL
  146 + && *fFunctionID == *returnValueID->fFunctionID
  147 + && fName == returnValueID->fName;
  148 + }
  149 +
  150 +protected:
  151 + virtual uint32 ComputeHashValue() const
  152 + {
  153 + uint32 hash = fFunctionID->HashValue();
  154 + return hash * 25 + StringUtils::HashValue(fName);
  155 + }
  156 +
  157 +private:
  158 + FunctionID* fFunctionID;
  159 + const BString fName;
  160 +};
  161 +
  162 +
120 163 // #pragma mark - DwarfStackFrameDebugInfo
121 164
122 165
@@ -235,6 +278,39 @@ DwarfStackFrameDebugInfo::CreateLocalVariable(FunctionID* functionID,
235 278
236 279
237 280 status_t
  281 +DwarfStackFrameDebugInfo::CreateReturnValue(FunctionID* functionID,
  282 + DIEType* returnType, ValueLocation* location, Variable*& _variable)
  283 +{
  284 + if (returnType == NULL)
  285 + return B_BAD_VALUE;
  286 +
  287 + // create the type
  288 + DwarfType* type;
  289 + status_t error = fTypeFactory->CreateType(returnType, type);
  290 + if (error != B_OK)
  291 + return error;
  292 + BReference<DwarfType> typeReference(type, true);
  293 +
  294 + DwarfReturnValueID* id = new(std::nothrow) DwarfReturnValueID(
  295 + functionID);
  296 + if (id == NULL)
  297 + return B_NO_MEMORY;
  298 +
  299 + BString name;
  300 + name.SetToFormat("%s returned", functionID->FunctionName().String());
  301 +
  302 + Variable* variable = new(std::nothrow) Variable(id, name,
  303 + type, location);
  304 + if (variable == NULL)
  305 + return B_NO_MEMORY;
  306 +
  307 + _variable = variable;
  308 +
  309 + return B_OK;
  310 +}
  311 +
  312 +
  313 +status_t
238 314 DwarfStackFrameDebugInfo::_CreateVariable(ObjectID* id, const BString& name,
239 315 DIEType* typeEntry, LocationDescription* locationDescription,
240 316 Variable*& _variable)
7 src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h
... ... @@ -1,4 +1,5 @@
1 1 /*
  2 + * Copyright 2012, Rene Gollent, rene@gollent.com.
2 3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 4 * Distributed under the terms of the MIT License.
4 5 */
@@ -56,10 +57,16 @@ class DwarfStackFrameDebugInfo : public StackFrameDebugInfo {
56 57 DIEVariable* variableEntry,
57 58 Variable*& _variable);
58 59 // returns reference
  60 + status_t CreateReturnValue(FunctionID* functionID,
  61 + DIEType* returnType,
  62 + ValueLocation* location,
  63 + Variable*& _variable);
  64 + // returns reference
59 65
60 66 private:
61 67 struct DwarfFunctionParameterID;
62 68 struct DwarfLocalVariableID;
  69 + struct DwarfReturnValueID;
63 70
64 71 private:
65 72 status_t _CreateVariable(ObjectID* id,

0 comments on commit c7ca91f

Please sign in to comment.
Something went wrong with that request. Please try again.