Class DWARFExpressionEvaluator
java.lang.Object
ghidra.app.util.bin.format.dwarf.expression.DWARFExpressionEvaluator
Evaluates a
DWARFExpression.
If an instruction needs a value in a register or memory location, the current DWARFExpressionEvaluator.ValueReader
callback will be called to fetch the value. The default implementation is to throw an exception,
but future work may plug in a constant propagation callback.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidevaluate(byte[] exprBytes) Executes the instructions found in the expression.voidevaluate(byte[] exprBytes, long... stackArgs) Executes the instructions found in the expression.voidevaluate(DWARFExpression expr) voidevaluate(DWARFExpression expr, long... stackArgs) Executes the instructions found in the expression.getExpr()intintbooleanhasNext()Returns true if there are instructions that can be evaluated.booleanisEmpty()peek()Peek at the top value of the stack.pop()Pop the top value off the stack.longpopLong()Pop the top value off the stack, and coerce it into a scalar long.Pop the top value off the stack, and coerce it into a scalar.Pop the top value off the stack, and coerce it into a varnode.voidpush(boolean b) voidpush(long l) voidvoidvoidvoidsetExpression(DWARFExpression expr) Sets the current expression.voidsetFrameBaseStackLocation(int offset) voidsetFrameBaseVal(Varnode frameBaseVal) voidsetMaxStepCount(int maxStepCount) voidsetValReader(DWARFExpressionEvaluator.ValueReader valReader) booleanstep()Evaluates the next instruction in the expression.toString()withStaticStackRegisterValues(Integer stackOffset, Integer stackFrameOffset)
-
Constructor Details
-
DWARFExpressionEvaluator
-
-
Method Details
-
getDWARFCompilationUnit
-
getExpr
-
isEmpty
public boolean isEmpty() -
getPtrSize
public int getPtrSize() -
setFrameBaseStackLocation
public void setFrameBaseStackLocation(int offset) -
setFrameBaseVal
-
setValReader
-
withStaticStackRegisterValues
public DWARFExpressionEvaluator.ValueReader withStaticStackRegisterValues(Integer stackOffset, Integer stackFrameOffset) -
getMaxStepCount
public int getMaxStepCount() -
setMaxStepCount
public void setMaxStepCount(int maxStepCount) -
push
-
push
-
push
public void push(boolean b) -
push
public void push(long l) -
push
-
peek
Peek at the top value of the stack.- Returns:
- top value of the stack
- Throws:
DWARFExpressionException- if stack is empty
-
pop
Pop the top value off the stack.- Returns:
- top value of the stack
- Throws:
DWARFExpressionException- if stack is empty
-
popScalar
Pop the top value off the stack, and coerce it into a scalar.- Returns:
- top value of the stack, as a scalar
- Throws:
DWARFExpressionException- if stack is empty or value can not be used as a scalar
-
popVarnode
Pop the top value off the stack, and coerce it into a varnode.- Returns:
- top value of the stack, as a varnode
- Throws:
DWARFExpressionException- if stack is empty or value can not be used as a varnode
-
popLong
Pop the top value off the stack, and coerce it into a scalar long.- Returns:
- top value of the stack, as a scalar long
- Throws:
DWARFExpressionException- if stack is empty or value can not be used as a long
-
evaluate
Executes the instructions found in the expression.- Parameters:
exprBytes- raw bytes of the expression- Throws:
DWARFExpressionException- if error
-
evaluate
Executes the instructions found in the expression.- Parameters:
exprBytes- raw bytes of the expressionstackArgs- any values to push onto the stack before execution- Throws:
DWARFExpressionException- if error
-
setExpression
Sets the current expression.- Parameters:
expr-DWARFExpression
-
hasNext
public boolean hasNext()Returns true if there are instructions that can be evaluated.- Returns:
- true if there are instructions that can be evaluated
-
step
Evaluates the next instruction in the expression.- Returns:
- true if there are more instructions
- Throws:
DWARFExpressionException- if error
-
evaluate
Executes the instructions found in the expression.- Parameters:
expr-DWARFExceptionto evaluatestackArgs- - pushed 0..N, so stackArgs[0] will be deepest, stackArgs[N] will be topmost.- Throws:
DWARFExpressionException- if error
-
evaluate
- Throws:
DWARFExpressionException
-
toString
-