Cleanup: store and retrieve the relocation delta from

the evaluation context instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39416 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2010-11-13 01:31:40 +00:00
parent de2e54ace0
commit 1a5bb78d9e
3 changed files with 27 additions and 20 deletions
@@ -36,10 +36,12 @@ static const uint32 kMaxOperationCount = 10000;
DwarfExpressionEvaluationContext::DwarfExpressionEvaluationContext( DwarfExpressionEvaluationContext::DwarfExpressionEvaluationContext(
const DwarfTargetInterface* targetInterface, uint8 addressSize) const DwarfTargetInterface* targetInterface, uint8 addressSize,
target_addr_t relocationDelta)
: :
fTargetInterface(targetInterface), fTargetInterface(targetInterface),
fAddressSize(addressSize) fAddressSize(addressSize),
fRelocationDelta(relocationDelta)
{ {
} }
@@ -159,8 +161,8 @@ 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,
target_addr_t relocationDelta, ValueLocation& _location) ValueLocation& _location)
{ {
_location.Clear(); _location.Clear();
// the empty expression is a valid one // the empty expression is a valid one
@@ -181,7 +183,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
_Push(objectAddress); _Push(objectAddress);
ValuePieceLocation piece; ValuePieceLocation piece;
status_t error = _Evaluate(&piece, relocationDelta); status_t error = _Evaluate(&piece);
if (error != B_OK) if (error != B_OK)
return error; return error;
@@ -229,7 +231,7 @@ DwarfExpressionEvaluator::EvaluateLocation(const void* expression, size_t size,
_Push(objectAddress); _Push(objectAddress);
ValuePieceLocation piece; ValuePieceLocation piece;
status_t error = _Evaluate(&piece, relocationDelta); status_t error = _Evaluate(&piece);
if (error != B_OK) if (error != B_OK)
return error; return error;
@@ -262,8 +264,7 @@ 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",
@@ -283,7 +284,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) + relocationDelta); _Push(fDataReader.ReadAddress(0) + fContext->RelocationDelta());
break; break;
case DW_OP_const1u: case DW_OP_const1u:
TRACE_EXPR(" DW_OP_const1u\n"); TRACE_EXPR(" DW_OP_const1u\n");
@@ -19,13 +19,17 @@ class DwarfExpressionEvaluationContext {
public: public:
DwarfExpressionEvaluationContext( DwarfExpressionEvaluationContext(
const DwarfTargetInterface* targetInterface, const DwarfTargetInterface* targetInterface,
uint8 addressSize); uint8 addressSize,
target_addr_t relocationDelta);
virtual ~DwarfExpressionEvaluationContext(); virtual ~DwarfExpressionEvaluationContext();
const DwarfTargetInterface* TargetInterface() const const DwarfTargetInterface* TargetInterface() const
{ return fTargetInterface; } { return fTargetInterface; }
uint8 AddressSize() const { return fAddressSize; } uint8 AddressSize() const { return fAddressSize; }
target_addr_t RelocationDelta() const
{ return fRelocationDelta; }
virtual bool GetObjectAddress(target_addr_t& _address) = 0; virtual bool GetObjectAddress(target_addr_t& _address) = 0;
virtual bool GetFrameAddress(target_addr_t& _address) = 0; virtual bool GetFrameAddress(target_addr_t& _address) = 0;
virtual bool GetFrameBaseAddress(target_addr_t& _address) virtual bool GetFrameBaseAddress(target_addr_t& _address)
@@ -43,6 +47,7 @@ public:
protected: protected:
const DwarfTargetInterface* fTargetInterface; const DwarfTargetInterface* fTargetInterface;
uint8 fAddressSize; uint8 fAddressSize;
target_addr_t fRelocationDelta;
}; };
@@ -57,8 +62,7 @@ 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, target_addr_t relocationDelta, size_t size, ValueLocation& _location);
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).
@@ -72,8 +76,7 @@ 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);
+9 -6
View File
@@ -36,9 +36,11 @@ public:
DIESubprogram* subprogramEntry, DIESubprogram* subprogramEntry,
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) target_addr_t framePointer,
target_addr_t relocationDelta)
: :
DwarfExpressionEvaluationContext(targetInterface, unit->AddressSize()), DwarfExpressionEvaluationContext(targetInterface, unit->AddressSize(),
relocationDelta),
fFile(file), fFile(file),
fUnit(unit), fUnit(unit),
fSubprogramEntry(subprogramEntry), fSubprogramEntry(subprogramEntry),
@@ -828,7 +830,7 @@ DwarfFile::EvaluateExpression(CompilationUnit* unit,
target_addr_t valueToPush, bool pushValue, target_addr_t& _result) target_addr_t valueToPush, bool pushValue, target_addr_t& _result)
{ {
ExpressionEvaluationContext context(this, unit, subprogramEntry, ExpressionEvaluationContext context(this, unit, subprogramEntry,
targetInterface, instructionPointer, 0, framePointer); targetInterface, instructionPointer, 0, framePointer, 0);
DwarfExpressionEvaluator evaluator(&context); DwarfExpressionEvaluator evaluator(&context);
if (pushValue && evaluator.Push(valueToPush) != B_OK) if (pushValue && evaluator.Push(valueToPush) != B_OK)
@@ -856,10 +858,11 @@ DwarfFile::ResolveLocation(CompilationUnit* unit,
// evaluate it // evaluate it
ExpressionEvaluationContext context(this, unit, subprogramEntry, ExpressionEvaluationContext context(this, unit, subprogramEntry,
targetInterface, instructionPointer, objectPointer, framePointer); targetInterface, instructionPointer, objectPointer, framePointer,
relocationDelta);
DwarfExpressionEvaluator evaluator(&context); DwarfExpressionEvaluator evaluator(&context);
return evaluator.EvaluateLocation(expression, expressionLength, return evaluator.EvaluateLocation(expression, expressionLength,
relocationDelta, _result); _result);
} }