Author: anevilyak Date: 2010-11-12 00:58:17 +0100 (Fri, 12 Nov 2010) New Revision: 39407 Changeset: http://dev.haiku-os.org/changeset/39407 Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.cpp haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.h haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h Log: When computing absolute addresses, take the image relocation delta into account. Fixes retrieving the addresses and consequently values of static variables. Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp 2010-11-11 23:58:17 UTC (rev 39407) @@ -402,7 +402,8 @@ if (typeContext == NULL) { typeContext = new(std::nothrow) DwarfTypeContext(fArchitecture, fImageInfo.ImageID(), fFile, - unit, NULL, 0, 0, &inputInterface, fromDwarfMap); + unit, NULL, 0, 0, fRelocationDelta, &inputInterface, + fromDwarfMap); if (typeContext == NULL) return B_NO_MEMORY; typeContextReference.SetTo(typeContext, true); @@ -504,8 +505,8 @@ DwarfStackFrameDebugInfo* stackFrameDebugInfo = new(std::nothrow) DwarfStackFrameDebugInfo(fArchitecture, fImageInfo.ImageID(), fFile, unit, subprogramEntry, fTypeLookup, - fTypeCache, instructionPointer, framePointer, inputInterface, - fromDwarfMap); + fTypeCache, instructionPointer, framePointer, fRelocationDelta, + inputInterface, fromDwarfMap); if (stackFrameDebugInfo == NULL) return B_NO_MEMORY; Reference<DwarfStackFrameDebugInfo> stackFrameDebugInfoReference( Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.cpp 2010-11-11 23:58:17 UTC (rev 39407) @@ -124,13 +124,13 @@ image_id imageID, DwarfFile* file, CompilationUnit* compilationUnit, DIESubprogram* subprogramEntry, GlobalTypeLookup* typeLookup, GlobalTypeCache* typeCache, target_addr_t instructionPointer, - target_addr_t framePointer, DwarfTargetInterface* targetInterface, - RegisterMap* fromDwarfRegisterMap) + target_addr_t framePointer, target_addr_t relocationDelta, + DwarfTargetInterface* targetInterface, RegisterMap* fromDwarfRegisterMap) : StackFrameDebugInfo(), fTypeContext(new(std::nothrow) DwarfTypeContext(architecture, imageID, file, compilationUnit, subprogramEntry, instructionPointer, framePointer, - targetInterface, fromDwarfRegisterMap)), + relocationDelta, targetInterface, fromDwarfRegisterMap)), fTypeLookup(typeLookup), fTypeCache(typeCache) { @@ -159,7 +159,8 @@ DwarfTypeContext* typeContext = new(std::nothrow) DwarfTypeContext( fTypeContext->GetArchitecture(), fTypeContext->ImageID(), fTypeContext->File(), fTypeContext->GetCompilationUnit(), NULL, 0, 0, - fTypeContext->TargetInterface(), fTypeContext->FromDwarfRegisterMap()); + fTypeContext->RelocationDelta(), fTypeContext->TargetInterface(), + fTypeContext->FromDwarfRegisterMap()); if (typeContext == NULL) return B_NO_MEMORY; Reference<DwarfTypeContext> typeContextReference(typeContext, true); Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/debug_info/DwarfStackFrameDebugInfo.h 2010-11-11 23:58:17 UTC (rev 39407) @@ -41,6 +41,7 @@ GlobalTypeCache* typeCache, target_addr_t instructionPointer, target_addr_t framePointer, + target_addr_t relocationDelta, DwarfTargetInterface* targetInterface, RegisterMap* fromDwarfRegisterMap); ~DwarfStackFrameDebugInfo(); Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.cpp 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.cpp 2010-11-11 23:58:17 UTC (rev 39407) @@ -56,8 +56,8 @@ DwarfTypeContext::DwarfTypeContext(Architecture* architecture, image_id imageID, DwarfFile* file, CompilationUnit* compilationUnit, DIESubprogram* subprogramEntry, target_addr_t instructionPointer, - target_addr_t framePointer, DwarfTargetInterface* targetInterface, - RegisterMap* fromDwarfRegisterMap) + target_addr_t framePointer, target_addr_t relocationDelta, + DwarfTargetInterface* targetInterface, RegisterMap* fromDwarfRegisterMap) : fArchitecture(architecture), fImageID(imageID), @@ -66,6 +66,7 @@ fSubprogramEntry(subprogramEntry), fInstructionPointer(instructionPointer), fFramePointer(framePointer), + fRelocationDelta(relocationDelta), fTargetInterface(targetInterface), fFromDwarfRegisterMap(fromDwarfRegisterMap) { @@ -218,7 +219,7 @@ typeContext->GetCompilationUnit(), typeContext->SubprogramEntry(), description, typeContext->TargetInterface(), typeContext->InstructionPointer(), objectAddress, - typeContext->FramePointer(), _location); + typeContext->FramePointer(), typeContext->RelocationDelta(), _location); if (error != B_OK) return error; Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.h =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.h 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/debug_info/DwarfTypes.h 2010-11-11 23:58:17 UTC (rev 39407) @@ -49,6 +49,7 @@ DIESubprogram* subprogramEntry, target_addr_t instructionPointer, target_addr_t framePointer, + target_addr_t relocationDelta, DwarfTargetInterface* targetInterface, RegisterMap* fromDwarfRegisterMap); ~DwarfTypeContext(); @@ -67,6 +68,8 @@ { return fInstructionPointer; } target_addr_t FramePointer() const { return fFramePointer; } + target_addr_t RelocationDelta() const + { return fRelocationDelta; } DwarfTargetInterface* TargetInterface() const { return fTargetInterface; } RegisterMap* FromDwarfRegisterMap() const @@ -80,6 +83,7 @@ DIESubprogram* fSubprogramEntry; target_addr_t fInstructionPointer; target_addr_t fFramePointer; + target_addr_t fRelocationDelta; DwarfTargetInterface* fTargetInterface; RegisterMap* fFromDwarfRegisterMap; }; Modified: haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp =================================================================== --- haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.cpp 2010-11-11 23:58:17 UTC (rev 39407) @@ -159,8 +159,8 @@ status_t DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size, - ValueLocation& _location) -{ + target_addr_t relocationDelta, ValueLocation& _location) +{ _location.Clear(); // the empty expression is a valid one @@ -181,7 +181,7 @@ _Push(objectAddress); ValuePieceLocation piece; - status_t error = _Evaluate(&piece); + status_t error = _Evaluate(&piece, relocationDelta); if (error != B_OK) return error; @@ -229,7 +229,7 @@ _Push(objectAddress); ValuePieceLocation piece; - status_t error = _Evaluate(&piece); + status_t error = _Evaluate(&piece, relocationDelta); if (error != B_OK) return error; @@ -262,7 +262,8 @@ status_t -DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece) +DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece, + target_addr_t relocationDelta) { TRACE_EXPR_ONLY({ TRACE_EXPR("DwarfExpressionEvaluator::_Evaluate(%p, %lld)\n", @@ -282,7 +283,7 @@ switch (opcode) { case DW_OP_addr: TRACE_EXPR(" DW_OP_addr\n"); - _Push(fDataReader.ReadAddress(0)); + _Push(fDataReader.ReadAddress(0) + relocationDelta); break; case DW_OP_const1u: TRACE_EXPR(" DW_OP_const1u\n"); Modified: haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h =================================================================== --- haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/dwarf/DwarfExpressionEvaluator.h 2010-11-11 23:58:17 UTC (rev 39407) @@ -57,7 +57,8 @@ status_t Evaluate(const void* expression, size_t size, target_addr_t& _result); status_t EvaluateLocation(const void* expression, - size_t size, ValueLocation& _location); + size_t size, target_addr_t relocationDelta, + ValueLocation& _location); // The returned location will have DWARF // semantics regarding register numbers and // bit offsets/sizes (cf. bit pieces). @@ -71,7 +72,8 @@ inline void _Push(target_addr_t value); inline target_addr_t _Pop(); - status_t _Evaluate(ValuePieceLocation* _piece); + status_t _Evaluate(ValuePieceLocation* _piece, + target_addr_t relocationDelta = 0); void _DereferenceAddress(uint8 addressSize); void _DereferenceAddressSpaceAddress( uint8 addressSize); Modified: haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp =================================================================== --- haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp 2010-11-11 23:58:17 UTC (rev 39407) @@ -843,7 +843,8 @@ DIESubprogram* subprogramEntry, const LocationDescription* location, const DwarfTargetInterface* targetInterface, target_addr_t instructionPointer, target_addr_t objectPointer, - target_addr_t framePointer, ValueLocation& _result) + target_addr_t framePointer, target_addr_t relocationDelta, + ValueLocation& _result) { // get the expression const void* expression; @@ -857,7 +858,8 @@ ExpressionEvaluationContext context(this, unit, subprogramEntry, targetInterface, instructionPointer, objectPointer, framePointer); DwarfExpressionEvaluator evaluator(&context); - return evaluator.EvaluateLocation(expression, expressionLength, _result); + return evaluator.EvaluateLocation(expression, expressionLength, + relocationDelta, _result); } Modified: haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h =================================================================== --- haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h 2010-11-11 22:47:18 UTC (rev 39406) +++ haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h 2010-11-11 23:58:17 UTC (rev 39407) @@ -69,6 +69,7 @@ target_addr_t instructionPointer, target_addr_t objectPointer, target_addr_t framePointer, + target_addr_t relocationDelta, ValueLocation& _result); // The returned location will have DWARF // semantics regarding register numbers and