Class DWARFExpressionEvaluator
- java.lang.Object
-
- ghidra.app.util.bin.format.dwarf4.expression.DWARFExpressionEvaluator
-
public class DWARFExpressionEvaluator extends java.lang.Object
Evaluates a subset of DWARF expression opcodes.Limitations:
Can not access memory during evaluation of expressions.
Some opcodes must be the last operation in the expression (deref, regX)
Can only specify offset from register for framebase and stack relative
Result can be a numeric value (ie. static address) or a register 'name' or a stack based offset.
-
-
Constructor Summary
Constructors Constructor Description DWARFExpressionEvaluator(byte pointerSize, boolean isLittleEndian, int dwarfFormat, DWARFRegisterMappings registerMappings)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DWARFExpressionEvaluator
create(DebugInfoEntry die)
DWARFExpressionResult
evaluate(byte[] exprBytes)
DWARFExpressionResult
evaluate(DWARFExpression _expr)
DWARFExpressionResult
evaluate(DWARFExpression _expr, long... stackArgs)
Register
getLastRegister()
int
getMaxStepCount()
int
getRawLastRegister()
java.lang.String
getStackAsString()
Register
getTerminalRegister()
Returns theregister
that holds the contents of the object that theexpression
points to.boolean
isDeref()
boolean
isDwarfStackValue()
boolean
isRegisterLocation()
boolean
isStackRelative()
long
peek()
long
pop()
void
push(long l)
DWARFExpression
readExpr(byte[] exprBytes)
void
setFrameBase(long fb)
void
setMaxStepCount(int maxStepCount)
java.lang.String
toString()
boolean
useUnknownRegister()
-
-
-
Constructor Detail
-
DWARFExpressionEvaluator
public DWARFExpressionEvaluator(byte pointerSize, boolean isLittleEndian, int dwarfFormat, DWARFRegisterMappings registerMappings)
-
-
Method Detail
-
create
public static DWARFExpressionEvaluator create(DebugInfoEntry die)
-
setFrameBase
public void setFrameBase(long fb)
-
push
public void push(long l)
-
peek
public long peek() throws DWARFExpressionException
- Throws:
DWARFExpressionException
-
pop
public long pop() throws DWARFExpressionException
- Throws:
DWARFExpressionException
-
getTerminalRegister
public Register getTerminalRegister()
Returns theregister
that holds the contents of the object that theexpression
points to.Note, you should check
isDeref()
to see if the register is just a pointer to the object instead of the object itself.- Returns:
-
isDeref
public boolean isDeref()
-
readExpr
public DWARFExpression readExpr(byte[] exprBytes) throws DWARFExpressionException
- Throws:
DWARFExpressionException
-
evaluate
public DWARFExpressionResult evaluate(byte[] exprBytes) throws DWARFExpressionException
- Throws:
DWARFExpressionException
-
evaluate
public DWARFExpressionResult evaluate(DWARFExpression _expr, long... stackArgs) throws DWARFExpressionException
- Parameters:
_expr
-stackArgs
- - pushed 0..N, so stackArgs[0] will be deepest, stackArgs[N] will be topmost.- Returns:
- Throws:
DWARFExpressionException
-
evaluate
public DWARFExpressionResult evaluate(DWARFExpression _expr) throws DWARFExpressionException
- Throws:
DWARFExpressionException
-
getStackAsString
public java.lang.String getStackAsString()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getMaxStepCount
public int getMaxStepCount()
-
setMaxStepCount
public void setMaxStepCount(int maxStepCount)
-
isDwarfStackValue
public boolean isDwarfStackValue()
-
useUnknownRegister
public boolean useUnknownRegister()
-
isRegisterLocation
public boolean isRegisterLocation()
-
getLastRegister
public Register getLastRegister()
-
getRawLastRegister
public int getRawLastRegister()
-
isStackRelative
public boolean isStackRelative()
-
-