Class DWARFExpression
java.lang.Object
ghidra.app.util.bin.format.dwarf.expression.DWARFExpression
A
DWARFExpression is an immutable list of operations
and some factory methods to read an expression from its binary representation.
Use a DWARFExpressionEvaluator to execute a DWARFExpression.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanintfindInstructionByOffset(long offset) Finds the index of anoperationby its offset from the beginning of the expression.getInstruction(int i) Returns the requested instruction.intReturns number of instructions in this expression.inthashCode()booleanisEmpty()Returns true if there are no instructions.static DWARFExpressionread(byte[] exprBytes, DWARFCompilationUnit cu) Deserializes aDWARFExpressionfrom its raw bytes.Converts thisDWARFExpressioninto a generic form, lacking any operand values.toString()toString(int caretPosition, boolean newlines, boolean offsets, DWARFRegisterMappings regMapping) Returns a formatted string representing this expression.
-
Field Details
-
MAX_SANE_EXPR
public static final int MAX_SANE_EXPR- See Also:
-
-
Method Details
-
read
public static DWARFExpression read(byte[] exprBytes, DWARFCompilationUnit cu) throws DWARFExpressionException Deserializes aDWARFExpressionfrom its raw bytes.- Parameters:
exprBytes- bytes containing the expressioncu- theDWARFCompilationUnitthat contained the expression- Returns:
- new
DWARFExpression, never null - Throws:
DWARFExpressionException- if error reading the expression, checkDWARFExpressionException.getExpression()for the partial results of the read
-
toGenericForm
Converts thisDWARFExpressioninto a generic form, lacking any operand values.Useful for aggregating statistics about unsupported/problematic expressions encountered in a binary.
- Returns:
- new
DWARFExpressioninstance where each instruction has been stripped of all operands
-
getInstruction
Returns the requested instruction.- Parameters:
i- instruction index- Returns:
- the requested instruction
-
getInstructionCount
public int getInstructionCount()Returns number of instructions in this expression.- Returns:
- number of instructions in this expression
-
isEmpty
public boolean isEmpty()Returns true if there are no instructions.- Returns:
- true if there are no instructions
-
findInstructionByOffset
public int findInstructionByOffset(long offset) Finds the index of anoperationby its offset from the beginning of the expression.- Parameters:
offset- byte offset of instruction to find- Returns:
- index of instruction at specified byte offset, or -1 if there is no instruction at the specified offset
-
toString
-
toString
-
toString
public String toString(int caretPosition, boolean newlines, boolean offsets, DWARFRegisterMappings regMapping) Returns a formatted string representing this expression.- Parameters:
caretPosition- index of which instruction to highlight as being the current instruction, or -1 to not highlight any instructionnewlines- boolean flag, if true each instruction will be on its own lineoffsets- boolean flag, if true the byte offset in the expression will be listed next to each instructionregMapping- mapping of dwarf to ghidra registers- Returns:
- formatted string
-
hashCode
public int hashCode() -
equals
-