When computing absolute addresses, take the image relocation

delta into account. Fixes retrieving the addresses and
consequently values of static variables.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39407 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-11-11 23:58:17 +00:00
parent 2f0376a62f
commit 3a1ce93bc7
9 changed files with 34 additions and 20 deletions

View File

@ -402,7 +402,8 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
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 @@ DwarfImageDebugInfo::CreateFrame(Image* image,
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(

View File

@ -124,13 +124,13 @@ DwarfStackFrameDebugInfo::DwarfStackFrameDebugInfo(Architecture* architecture,
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 @@ DwarfStackFrameDebugInfo::Init()
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);

View File

@ -41,6 +41,7 @@ public:
GlobalTypeCache* typeCache,
target_addr_t instructionPointer,
target_addr_t framePointer,
target_addr_t relocationDelta,
DwarfTargetInterface* targetInterface,
RegisterMap* fromDwarfRegisterMap);
~DwarfStackFrameDebugInfo();

View File

@ -56,8 +56,8 @@ struct HasByteStridePredicate {
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 @@ DwarfTypeContext::DwarfTypeContext(Architecture* architecture, image_id imageID,
fSubprogramEntry(subprogramEntry),
fInstructionPointer(instructionPointer),
fFramePointer(framePointer),
fRelocationDelta(relocationDelta),
fTargetInterface(targetInterface),
fFromDwarfRegisterMap(fromDwarfRegisterMap)
{
@ -218,7 +219,7 @@ DwarfType::ResolveLocation(DwarfTypeContext* typeContext,
typeContext->GetCompilationUnit(), typeContext->SubprogramEntry(),
description, typeContext->TargetInterface(),
typeContext->InstructionPointer(), objectAddress,
typeContext->FramePointer(), _location);
typeContext->FramePointer(), typeContext->RelocationDelta(), _location);
if (error != B_OK)
return error;

View File

@ -49,6 +49,7 @@ public:
DIESubprogram* subprogramEntry,
target_addr_t instructionPointer,
target_addr_t framePointer,
target_addr_t relocationDelta,
DwarfTargetInterface* targetInterface,
RegisterMap* fromDwarfRegisterMap);
~DwarfTypeContext();
@ -67,6 +68,8 @@ public:
{ 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 @@ private:
DIESubprogram* fSubprogramEntry;
target_addr_t fInstructionPointer;
target_addr_t fFramePointer;
target_addr_t fRelocationDelta;
DwarfTargetInterface* fTargetInterface;
RegisterMap* fFromDwarfRegisterMap;
};

View File

@ -159,8 +159,8 @@ DwarfExpressionEvaluator::Evaluate(const void* expression, size_t size,
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 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
_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 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
_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 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
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 @@ DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece)
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");

View File

@ -57,7 +57,8 @@ public:
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 @@ private:
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);

View File

@ -843,7 +843,8 @@ DwarfFile::ResolveLocation(CompilationUnit* unit,
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 @@ DwarfFile::ResolveLocation(CompilationUnit* unit,
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);
}

View File

@ -69,6 +69,7 @@ public:
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