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:
@@ -402,7 +402,8 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
|||||||
if (typeContext == NULL) {
|
if (typeContext == NULL) {
|
||||||
typeContext = new(std::nothrow)
|
typeContext = new(std::nothrow)
|
||||||
DwarfTypeContext(fArchitecture, fImageInfo.ImageID(), fFile,
|
DwarfTypeContext(fArchitecture, fImageInfo.ImageID(), fFile,
|
||||||
unit, NULL, 0, 0, &inputInterface, fromDwarfMap);
|
unit, NULL, 0, 0, fRelocationDelta, &inputInterface,
|
||||||
|
fromDwarfMap);
|
||||||
if (typeContext == NULL)
|
if (typeContext == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
typeContextReference.SetTo(typeContext, true);
|
typeContextReference.SetTo(typeContext, true);
|
||||||
@@ -504,8 +505,8 @@ DwarfImageDebugInfo::CreateFrame(Image* image,
|
|||||||
DwarfStackFrameDebugInfo* stackFrameDebugInfo
|
DwarfStackFrameDebugInfo* stackFrameDebugInfo
|
||||||
= new(std::nothrow) DwarfStackFrameDebugInfo(fArchitecture,
|
= new(std::nothrow) DwarfStackFrameDebugInfo(fArchitecture,
|
||||||
fImageInfo.ImageID(), fFile, unit, subprogramEntry, fTypeLookup,
|
fImageInfo.ImageID(), fFile, unit, subprogramEntry, fTypeLookup,
|
||||||
fTypeCache, instructionPointer, framePointer, inputInterface,
|
fTypeCache, instructionPointer, framePointer, fRelocationDelta,
|
||||||
fromDwarfMap);
|
inputInterface, fromDwarfMap);
|
||||||
if (stackFrameDebugInfo == NULL)
|
if (stackFrameDebugInfo == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
Reference<DwarfStackFrameDebugInfo> stackFrameDebugInfoReference(
|
Reference<DwarfStackFrameDebugInfo> stackFrameDebugInfoReference(
|
||||||
|
|||||||
@@ -124,13 +124,13 @@ DwarfStackFrameDebugInfo::DwarfStackFrameDebugInfo(Architecture* architecture,
|
|||||||
image_id imageID, DwarfFile* file, CompilationUnit* compilationUnit,
|
image_id imageID, DwarfFile* file, CompilationUnit* compilationUnit,
|
||||||
DIESubprogram* subprogramEntry, GlobalTypeLookup* typeLookup,
|
DIESubprogram* subprogramEntry, GlobalTypeLookup* typeLookup,
|
||||||
GlobalTypeCache* typeCache, target_addr_t instructionPointer,
|
GlobalTypeCache* typeCache, target_addr_t instructionPointer,
|
||||||
target_addr_t framePointer, DwarfTargetInterface* targetInterface,
|
target_addr_t framePointer, target_addr_t relocationDelta,
|
||||||
RegisterMap* fromDwarfRegisterMap)
|
DwarfTargetInterface* targetInterface, RegisterMap* fromDwarfRegisterMap)
|
||||||
:
|
:
|
||||||
StackFrameDebugInfo(),
|
StackFrameDebugInfo(),
|
||||||
fTypeContext(new(std::nothrow) DwarfTypeContext(architecture, imageID, file,
|
fTypeContext(new(std::nothrow) DwarfTypeContext(architecture, imageID, file,
|
||||||
compilationUnit, subprogramEntry, instructionPointer, framePointer,
|
compilationUnit, subprogramEntry, instructionPointer, framePointer,
|
||||||
targetInterface, fromDwarfRegisterMap)),
|
relocationDelta, targetInterface, fromDwarfRegisterMap)),
|
||||||
fTypeLookup(typeLookup),
|
fTypeLookup(typeLookup),
|
||||||
fTypeCache(typeCache)
|
fTypeCache(typeCache)
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,8 @@ DwarfStackFrameDebugInfo::Init()
|
|||||||
DwarfTypeContext* typeContext = new(std::nothrow) DwarfTypeContext(
|
DwarfTypeContext* typeContext = new(std::nothrow) DwarfTypeContext(
|
||||||
fTypeContext->GetArchitecture(), fTypeContext->ImageID(),
|
fTypeContext->GetArchitecture(), fTypeContext->ImageID(),
|
||||||
fTypeContext->File(), fTypeContext->GetCompilationUnit(), NULL, 0, 0,
|
fTypeContext->File(), fTypeContext->GetCompilationUnit(), NULL, 0, 0,
|
||||||
fTypeContext->TargetInterface(), fTypeContext->FromDwarfRegisterMap());
|
fTypeContext->RelocationDelta(), fTypeContext->TargetInterface(),
|
||||||
|
fTypeContext->FromDwarfRegisterMap());
|
||||||
if (typeContext == NULL)
|
if (typeContext == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
Reference<DwarfTypeContext> typeContextReference(typeContext, true);
|
Reference<DwarfTypeContext> typeContextReference(typeContext, true);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
GlobalTypeCache* typeCache,
|
GlobalTypeCache* typeCache,
|
||||||
target_addr_t instructionPointer,
|
target_addr_t instructionPointer,
|
||||||
target_addr_t framePointer,
|
target_addr_t framePointer,
|
||||||
|
target_addr_t relocationDelta,
|
||||||
DwarfTargetInterface* targetInterface,
|
DwarfTargetInterface* targetInterface,
|
||||||
RegisterMap* fromDwarfRegisterMap);
|
RegisterMap* fromDwarfRegisterMap);
|
||||||
~DwarfStackFrameDebugInfo();
|
~DwarfStackFrameDebugInfo();
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ struct HasByteStridePredicate {
|
|||||||
DwarfTypeContext::DwarfTypeContext(Architecture* architecture, image_id imageID,
|
DwarfTypeContext::DwarfTypeContext(Architecture* architecture, image_id imageID,
|
||||||
DwarfFile* file, CompilationUnit* compilationUnit,
|
DwarfFile* file, CompilationUnit* compilationUnit,
|
||||||
DIESubprogram* subprogramEntry, target_addr_t instructionPointer,
|
DIESubprogram* subprogramEntry, target_addr_t instructionPointer,
|
||||||
target_addr_t framePointer, DwarfTargetInterface* targetInterface,
|
target_addr_t framePointer, target_addr_t relocationDelta,
|
||||||
RegisterMap* fromDwarfRegisterMap)
|
DwarfTargetInterface* targetInterface, RegisterMap* fromDwarfRegisterMap)
|
||||||
:
|
:
|
||||||
fArchitecture(architecture),
|
fArchitecture(architecture),
|
||||||
fImageID(imageID),
|
fImageID(imageID),
|
||||||
@@ -66,6 +66,7 @@ DwarfTypeContext::DwarfTypeContext(Architecture* architecture, image_id imageID,
|
|||||||
fSubprogramEntry(subprogramEntry),
|
fSubprogramEntry(subprogramEntry),
|
||||||
fInstructionPointer(instructionPointer),
|
fInstructionPointer(instructionPointer),
|
||||||
fFramePointer(framePointer),
|
fFramePointer(framePointer),
|
||||||
|
fRelocationDelta(relocationDelta),
|
||||||
fTargetInterface(targetInterface),
|
fTargetInterface(targetInterface),
|
||||||
fFromDwarfRegisterMap(fromDwarfRegisterMap)
|
fFromDwarfRegisterMap(fromDwarfRegisterMap)
|
||||||
{
|
{
|
||||||
@@ -218,7 +219,7 @@ DwarfType::ResolveLocation(DwarfTypeContext* typeContext,
|
|||||||
typeContext->GetCompilationUnit(), typeContext->SubprogramEntry(),
|
typeContext->GetCompilationUnit(), typeContext->SubprogramEntry(),
|
||||||
description, typeContext->TargetInterface(),
|
description, typeContext->TargetInterface(),
|
||||||
typeContext->InstructionPointer(), objectAddress,
|
typeContext->InstructionPointer(), objectAddress,
|
||||||
typeContext->FramePointer(), _location);
|
typeContext->FramePointer(), typeContext->RelocationDelta(), _location);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
DIESubprogram* subprogramEntry,
|
DIESubprogram* subprogramEntry,
|
||||||
target_addr_t instructionPointer,
|
target_addr_t instructionPointer,
|
||||||
target_addr_t framePointer,
|
target_addr_t framePointer,
|
||||||
|
target_addr_t relocationDelta,
|
||||||
DwarfTargetInterface* targetInterface,
|
DwarfTargetInterface* targetInterface,
|
||||||
RegisterMap* fromDwarfRegisterMap);
|
RegisterMap* fromDwarfRegisterMap);
|
||||||
~DwarfTypeContext();
|
~DwarfTypeContext();
|
||||||
@@ -67,6 +68,8 @@ public:
|
|||||||
{ return fInstructionPointer; }
|
{ return fInstructionPointer; }
|
||||||
target_addr_t FramePointer() const
|
target_addr_t FramePointer() const
|
||||||
{ return fFramePointer; }
|
{ return fFramePointer; }
|
||||||
|
target_addr_t RelocationDelta() const
|
||||||
|
{ return fRelocationDelta; }
|
||||||
DwarfTargetInterface* TargetInterface() const
|
DwarfTargetInterface* TargetInterface() const
|
||||||
{ return fTargetInterface; }
|
{ return fTargetInterface; }
|
||||||
RegisterMap* FromDwarfRegisterMap() const
|
RegisterMap* FromDwarfRegisterMap() const
|
||||||
@@ -80,6 +83,7 @@ private:
|
|||||||
DIESubprogram* fSubprogramEntry;
|
DIESubprogram* fSubprogramEntry;
|
||||||
target_addr_t fInstructionPointer;
|
target_addr_t fInstructionPointer;
|
||||||
target_addr_t fFramePointer;
|
target_addr_t fFramePointer;
|
||||||
|
target_addr_t fRelocationDelta;
|
||||||
DwarfTargetInterface* fTargetInterface;
|
DwarfTargetInterface* fTargetInterface;
|
||||||
RegisterMap* fFromDwarfRegisterMap;
|
RegisterMap* fFromDwarfRegisterMap;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ DwarfExpressionEvaluator::Evaluate(const void* expression, size_t size,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
|
DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
|
||||||
ValueLocation& _location)
|
target_addr_t relocationDelta, ValueLocation& _location)
|
||||||
{
|
{
|
||||||
_location.Clear();
|
_location.Clear();
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
|
|||||||
_Push(objectAddress);
|
_Push(objectAddress);
|
||||||
|
|
||||||
ValuePieceLocation piece;
|
ValuePieceLocation piece;
|
||||||
status_t error = _Evaluate(&piece);
|
status_t error = _Evaluate(&piece, relocationDelta);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
|
|||||||
_Push(objectAddress);
|
_Push(objectAddress);
|
||||||
|
|
||||||
ValuePieceLocation piece;
|
ValuePieceLocation piece;
|
||||||
status_t error = _Evaluate(&piece);
|
status_t error = _Evaluate(&piece, relocationDelta);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -262,7 +262,8 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece)
|
DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece,
|
||||||
|
target_addr_t relocationDelta)
|
||||||
{
|
{
|
||||||
TRACE_EXPR_ONLY({
|
TRACE_EXPR_ONLY({
|
||||||
TRACE_EXPR("DwarfExpressionEvaluator::_Evaluate(%p, %lld)\n",
|
TRACE_EXPR("DwarfExpressionEvaluator::_Evaluate(%p, %lld)\n",
|
||||||
@@ -282,7 +283,7 @@ DwarfExpressionEvaluator::_Evaluate(ValuePieceLocation* _piece)
|
|||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case DW_OP_addr:
|
case DW_OP_addr:
|
||||||
TRACE_EXPR(" DW_OP_addr\n");
|
TRACE_EXPR(" DW_OP_addr\n");
|
||||||
_Push(fDataReader.ReadAddress(0));
|
_Push(fDataReader.ReadAddress(0) + relocationDelta);
|
||||||
break;
|
break;
|
||||||
case DW_OP_const1u:
|
case DW_OP_const1u:
|
||||||
TRACE_EXPR(" DW_OP_const1u\n");
|
TRACE_EXPR(" DW_OP_const1u\n");
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ public:
|
|||||||
status_t Evaluate(const void* expression, size_t size,
|
status_t Evaluate(const void* expression, size_t size,
|
||||||
target_addr_t& _result);
|
target_addr_t& _result);
|
||||||
status_t EvaluateLocation(const void* expression,
|
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
|
// The returned location will have DWARF
|
||||||
// semantics regarding register numbers and
|
// semantics regarding register numbers and
|
||||||
// bit offsets/sizes (cf. bit pieces).
|
// bit offsets/sizes (cf. bit pieces).
|
||||||
@@ -71,7 +72,8 @@ private:
|
|||||||
inline void _Push(target_addr_t value);
|
inline void _Push(target_addr_t value);
|
||||||
inline target_addr_t _Pop();
|
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 _DereferenceAddress(uint8 addressSize);
|
||||||
void _DereferenceAddressSpaceAddress(
|
void _DereferenceAddressSpaceAddress(
|
||||||
uint8 addressSize);
|
uint8 addressSize);
|
||||||
|
|||||||
@@ -843,7 +843,8 @@ DwarfFile::ResolveLocation(CompilationUnit* unit,
|
|||||||
DIESubprogram* subprogramEntry, const LocationDescription* location,
|
DIESubprogram* subprogramEntry, const LocationDescription* location,
|
||||||
const DwarfTargetInterface* targetInterface,
|
const DwarfTargetInterface* targetInterface,
|
||||||
target_addr_t instructionPointer, target_addr_t objectPointer,
|
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
|
// get the expression
|
||||||
const void* expression;
|
const void* expression;
|
||||||
@@ -857,7 +858,8 @@ DwarfFile::ResolveLocation(CompilationUnit* unit,
|
|||||||
ExpressionEvaluationContext context(this, unit, subprogramEntry,
|
ExpressionEvaluationContext context(this, unit, subprogramEntry,
|
||||||
targetInterface, instructionPointer, objectPointer, framePointer);
|
targetInterface, instructionPointer, objectPointer, framePointer);
|
||||||
DwarfExpressionEvaluator evaluator(&context);
|
DwarfExpressionEvaluator evaluator(&context);
|
||||||
return evaluator.EvaluateLocation(expression, expressionLength, _result);
|
return evaluator.EvaluateLocation(expression, expressionLength,
|
||||||
|
relocationDelta, _result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
target_addr_t instructionPointer,
|
target_addr_t instructionPointer,
|
||||||
target_addr_t objectPointer,
|
target_addr_t objectPointer,
|
||||||
target_addr_t framePointer,
|
target_addr_t framePointer,
|
||||||
|
target_addr_t relocationDelta,
|
||||||
ValueLocation& _result);
|
ValueLocation& _result);
|
||||||
// The returned location will have DWARF
|
// The returned location will have DWARF
|
||||||
// semantics regarding register numbers and
|
// semantics regarding register numbers and
|
||||||
|
|||||||
Reference in New Issue
Block a user