diff --git a/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp b/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp index 4bcea53a33..00256826bd 100644 --- a/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp +++ b/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp @@ -36,10 +36,12 @@ static const uint32 kMaxOperationCount = 10000; DwarfExpressionEvaluationContext::DwarfExpressionEvaluationContext( - const DwarfTargetInterface* targetInterface, uint8 addressSize) + const DwarfTargetInterface* targetInterface, uint8 addressSize, + target_addr_t relocationDelta) : fTargetInterface(targetInterface), - fAddressSize(addressSize) + fAddressSize(addressSize), + fRelocationDelta(relocationDelta) { } @@ -159,8 +161,8 @@ DwarfExpressionEvaluator::Evaluate(const void* expression, size_t size, status_t DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size, - target_addr_t relocationDelta, ValueLocation& _location) -{ + ValueLocation& _location) +{ _location.Clear(); // the empty expression is a valid one @@ -181,7 +183,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size, _Push(objectAddress); ValuePieceLocation piece; - status_t error = _Evaluate(&piece, relocationDelta); + status_t error = _Evaluate(&piece); if (error != B_OK) return error; @@ -229,7 +231,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size, _Push(objectAddress); ValuePieceLocation piece; - status_t error = _Evaluate(&piece, relocationDelta); + status_t error = _Evaluate(&piece); if (error != B_OK) return error; @@ -262,8 +264,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size, status_t -DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece, - target_addr_t relocationDelta) +DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece) { TRACE_EXPR_ONLY({ TRACE_EXPR("DwarfExpressionEvaluator::_Evaluate(%p, %lld)\n", @@ -283,7 +284,7 @@ DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece, switch (opcode) { case DW_OP_addr: TRACE_EXPR(" DW_OP_addr\n"); - _Push(fDataReader.ReadAddress(0) + relocationDelta); + _Push(fDataReader.ReadAddress(0) + fContext->RelocationDelta()); break; case DW_OP_const1u: TRACE_EXPR(" DW_OP_const1u\n"); diff --git a/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h b/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h index 1a67d86a88..71faec2057 100644 --- a/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h +++ b/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h @@ -19,13 +19,17 @@ class DwarfExpressionEvaluationContext { public: DwarfExpressionEvaluationContext( const DwarfTargetInterface* targetInterface, - uint8 addressSize); + uint8 addressSize, + target_addr_t relocationDelta); virtual ~DwarfExpressionEvaluationContext(); const DwarfTargetInterface* TargetInterface() const { return fTargetInterface; } uint8 AddressSize() const { return fAddressSize; } + target_addr_t RelocationDelta() const + { return fRelocationDelta; } + virtual bool GetObjectAddress(target_addr_t& _address) = 0; virtual bool GetFrameAddress(target_addr_t& _address) = 0; virtual bool GetFrameBaseAddress(target_addr_t& _address) @@ -43,6 +47,7 @@ public: protected: const DwarfTargetInterface* fTargetInterface; uint8 fAddressSize; + target_addr_t fRelocationDelta; }; @@ -57,8 +62,7 @@ public: status_t Evaluate(const void* expression, size_t size, target_addr_t& _result); status_t EvaluateLocation(const void* expression, - size_t size, target_addr_t relocationDelta, - ValueLocation& _location); + size_t size, ValueLocation& _location); // The returned location will have DWARF // semantics regarding register numbers and // bit offsets/sizes (cf. bit pieces). @@ -72,8 +76,7 @@ private: inline void _Push(target_addr_t value); inline target_addr_t _Pop(); - status_t _Evaluate(ValuePieceLocation* _piece, - target_addr_t relocationDelta = 0); + status_t _Evaluate(ValuePieceLocation* _piece); void _DereferenceAddress(uint8 addressSize); void _DereferenceAddressSpaceAddress( uint8 addressSize); diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index b1f7c224db..1ab1208808 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -36,9 +36,11 @@ public: DIESubprogram* subprogramEntry, const DwarfTargetInterface* targetInterface, target_addr_t instructionPointer, target_addr_t objectPointer, - target_addr_t framePointer) + target_addr_t framePointer, + target_addr_t relocationDelta) : - DwarfExpressionEvaluationContext(targetInterface, unit->AddressSize()), + DwarfExpressionEvaluationContext(targetInterface, unit->AddressSize(), + relocationDelta), fFile(file), fUnit(unit), fSubprogramEntry(subprogramEntry), @@ -828,7 +830,7 @@ DwarfFile::EvaluateExpression(CompilationUnit* unit, target_addr_t valueToPush, bool pushValue, target_addr_t& _result) { ExpressionEvaluationContext context(this, unit, subprogramEntry, - targetInterface, instructionPointer, 0, framePointer); + targetInterface, instructionPointer, 0, framePointer, 0); DwarfExpressionEvaluator evaluator(&context); if (pushValue && evaluator.Push(valueToPush) != B_OK) @@ -856,10 +858,11 @@ DwarfFile::ResolveLocation(CompilationUnit* unit, // evaluate it ExpressionEvaluationContext context(this, unit, subprogramEntry, - targetInterface, instructionPointer, objectPointer, framePointer); + targetInterface, instructionPointer, objectPointer, framePointer, + relocationDelta); DwarfExpressionEvaluator evaluator(&context); - return evaluator.EvaluateLocation(expression, expressionLength, - relocationDelta, _result); + return evaluator.EvaluateLocation(expression, expressionLength, + _result); }