Class DWARFExpressionInstruction
java.lang.Object
ghidra.app.util.bin.format.dwarf.expression.DWARFExpressionInstruction
An immutable representation of a single
DWARFExpression instruction and its operands.
An instruction can take 0, 1, or 2 operands, only the last can be a blob.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]protected final intprotected final DWARFExpressionOpCodeprotected final long[]protected final DWARFExpressionOperandType[] -
Constructor Summary
ConstructorsConstructorDescriptionDWARFExpressionInstruction(DWARFExpressionOpCode op, DWARFExpressionOperandType[] operandTypes, long[] operands, byte[] blob, int offset) Create a new DWARF expression instruction. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbyte[]getBlob()Returns the byte array that contains the bytes of the blob operand.intReturns offset of this opcode, relative to the start of theDWARFExpression.ReturnsDWARFExpressionOpCodeof this instruction.intReturns number of operands this instruction has.getOperandRepresentation(int opIndex) Returns formatted string representation of the specified operand, patterned after readelf's format.longgetOperandValue(int opindex) Returns the specified operand's value. Not valid for blob operands.inthashCode()static DWARFExpressionInstructionread(BinaryReader reader, byte addrSize, int intSize) Reads a single instruction from the stream.Returns a new instruction instance that is a copy of this instruction, but has had all it's operands removed.toString()
-
Field Details
-
opcode
-
offset
protected final int offset -
operandTypes
-
operands
protected final long[] operands -
blob
protected final byte[] blob
-
-
Constructor Details
-
DWARFExpressionInstruction
public DWARFExpressionInstruction(DWARFExpressionOpCode op, DWARFExpressionOperandType[] operandTypes, long[] operands, byte[] blob, int offset) Create a new DWARF expression instruction.- Parameters:
op- enum opcode, ie. DW_OP_not fromDWARFExpressionOpCodeoperandTypes- 'datatype' of each operandsoperands- value of the operands, pre-converted into longs.blob- if an operand is a byte array (ie. for DW_OP_implicit_value), this is the bytesoffset- byte offset of this operation from the start of the DWARF expression.
-
-
Method Details
-
read
public static DWARFExpressionInstruction read(BinaryReader reader, byte addrSize, int intSize) throws IOException Reads a single instruction from the stream.- Parameters:
reader-BinaryReaderstreamaddrSize- size of pointersintSize- size of ints- Returns:
- new
DWARFExpressionInstruction, never null. Problematic instructions will have an opcode ofDW_OP_unknown_opcodeand will contain the remainder of the stream as its blob operand - Throws:
IOException- if error reading a primitive value from the stream
-
toGenericForm
Returns a new instruction instance that is a copy of this instruction, but has had all it's operands removed.- Returns:
- a new instruction instance that is a copy of this instruction, but has had all it's operands removed
-
getOpCode
ReturnsDWARFExpressionOpCodeof this instruction.- Returns:
DWARFExpressionOpCodeof this instruction
-
getOperandValue
public long getOperandValue(int opindex) Returns the specified operand's value. Not valid for blob operands.- Parameters:
opindex- which operand to fetch.- Returns:
- the specified operand's value. Not valid for blob operands
-
getOperandCount
public int getOperandCount()Returns number of operands this instruction has.- Returns:
- number of operands this instruction has
-
getBlob
public byte[] getBlob()Returns the byte array that contains the bytes of the blob operand.- Returns:
- the byte array that contains the bytes of the blob operand
-
getOffset
public int getOffset()Returns offset of this opcode, relative to the start of theDWARFExpression.- Returns:
- offset of this opcode, relative to the start of the
DWARFExpression
-
toString
-
getOperandRepresentation
Returns formatted string representation of the specified operand, patterned after readelf's format.- Parameters:
opIndex- operand index- Returns:
- formatted string representation of the specified operand, patterned after readelf's format
-
hashCode
public int hashCode() -
equals
-