Package ghidra.app.util
Class PseudoInstruction
- java.lang.Object
-
- ghidra.app.util.PseudoInstruction
-
- All Implemented Interfaces:
InstructionContext,ProcessorContext,ProcessorContextView,CodeUnit,Instruction,MemBuffer
public class PseudoInstruction extends java.lang.Object implements Instruction, InstructionContext
Pseudo (i.e., fake) instruction that is generated by the Disassembler. This form of has some limitation over an instruction which is obtained from a program listing. The instruction will completely cache all bytes corresponding to the prototype length at the specified address. Additional bytes will be cached for delay-slotted instructions to facilitate pcode generation and obtaining general pcode related attributes.
-
-
Field Summary
Fields Modifier and Type Field Description protected Addressaddressprotected byte[]bytesprotected java.util.Map<java.lang.Integer,java.lang.String>commentsprotected static Address[]emptyAddrArrayprotected static Reference[]emptyMemRefsprotected inthashprotected booleanisBigEndianprotected intlengthprotected AddressmaxAddressprotected Programprogramprotected ReferenceManagerrefMgr-
Fields inherited from interface ghidra.program.model.listing.CodeUnit
COMMENT_PROPERTY, DEFINED_DATA_PROPERTY, EOL_COMMENT, INSTRUCTION_PROPERTY, MNEMONIC, NO_COMMENT, PLATE_COMMENT, POST_COMMENT, PRE_COMMENT, REPEATABLE_COMMENT, SPACE_PROPERTY
-
Fields inherited from interface ghidra.program.model.listing.Instruction
INVALID_DEPTH_CHANGE
-
-
Constructor Summary
Constructors Constructor Description PseudoInstruction(AddressFactory addrFactory, Address addr, InstructionPrototype prototype, MemBuffer memBuffer, ProcessorContext procContext)Construct a new PseudoInstruction within a program.PseudoInstruction(Address addr, InstructionPrototype prototype, MemBuffer memBuffer, ProcessorContext procContext)Construct a new PseudoInstruction without a program (flow override not supported).PseudoInstruction(Program program, Address addr, InstructionPrototype prototype, MemBuffer memBuffer, ProcessorContext procContext)Construct a new PseudoInstruction within a program.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)Add a reference to the mnemonic for this code unit.voidaddOperandReference(int opIndex, Address refAddr, RefType type, SourceType sourceType)Add a user defined reference to the operand at the given index.voidclearFallThroughOverride()Restores this instruction's fallthrough address back to the default fallthrough for this instruction.voidclearRegister(Register register)Clears the register within this context.intcompareTo(Address a)Compares the given address to the address range of this node.booleancontains(Address testAddr)Determines if this code unit contains the indicated address.booleanequals(java.lang.Object obj)AddressgetAddress()Get the Address which corresponds to the offset 0.AddressgetAddress(int opIndex)Get the Address for the given operand index if one exists.java.lang.StringgetAddressString(boolean showBlockName, boolean pad)Get the string representation of the starting address for this code unit.RegistergetBaseContextRegister()java.math.BigIntegergetBigInteger(int offset, int size, boolean signed)returns the value at the given offset, taking into account the endianess.bytegetByte(int offset)Get one byte from memory at the current position plus offset.byte[]getBytes()Gets the bytes for this code unit.intgetBytes(byte[] b, int offset)Reads b.length bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position.voidgetBytesInCodeUnit(byte[] buffer, int bufferOffset)Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.java.lang.StringgetComment(int commentType)Get the comment for the given typejava.lang.String[]getCommentAsArray(int commentType)Get the comment as an array where each element is a single line for the given type.AddressgetDefaultFallThrough()Get the default fallthrough for this instruction.intgetDefaultFallThroughOffset()Get default fall-through offset in bytes from start of instruction to the fallthrough instruction.Address[]getDefaultFlows()Get an array of Address objects for all default flows established by the underlying instruction prototype.java.lang.StringgetDefaultOperandRepresentation(int opIndex)Get the operand representation for the given operand index without markup.java.util.List<java.lang.Object>getDefaultOperandRepresentationList(int opIndex)Get the operand representation for the given operand index.intgetDelaySlotDepth()Get the number of delay slot instructions for this argument.ExternalReferencegetExternalReference(int opIndex)Gets the external reference (if any) at the opIndexAddressgetFallFrom()Get the Address for the instruction that fell through to this instruction.AddressgetFallThrough()Get the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.FlowOverridegetFlowOverride()Returns the flow override which may have been set on this instruction.Address[]getFlows()Get an array of Address objects for all flows other than a fall-through.FlowTypegetFlowType()Get the flow type of this instruction (how this instruction flows to the next instruction).java.lang.Object[]getInputObjects()Get the Input objects used by this instruction.InstructionContextgetInstructionContext()intgetInt(int offset)returns the int at the given offset, taking into account the endianess.intgetIntProperty(java.lang.String name)Get the int property for name.java.lang.StringgetLabel()Deprecated.intgetLength()Get the length of the code unit.longgetLong(int offset)returns the long at the given offset, taking into account the endianess.AddressgetMaxAddress()Get the ending address for this code unit.MemBuffergetMemBuffer()Get the read-only memory buffer containing the instruction bytes.MemorygetMemory()Get the Memory object actually used by the MemBuffer.AddressgetMinAddress()Get the starting address for this code unit.Reference[]getMnemonicReferences()Get references for the mnemonic for this instruction.java.lang.StringgetMnemonicString()Get the mnemonic for this code unit, e.g., MOV, JMPInstructiongetNext()Get the instruction following this one in address order.CodeUnitgetNextCodeUnit()Get the code unit after this code unit.intgetNumOperands()Get the number of operands for this code unit.SaveablegetObjectProperty(java.lang.String name)Get the object property for name; returns null if there is no name property for this code unit.Reference[]getOperandReferences(int opIndex)Get the references for the operand index.RefTypegetOperandRefType(int opIndex)Get the operand reference type for the given operand index.intgetOperandType(int opIndex)Get the type of a specific operand.java.lang.Object[]getOpObjects(int opIndex)Get objects used by this operand (Address, Scalar, Register ...)ParserContextgetParserContext()Get the instruction parser context for the instruction which corresponds to this context object.ParserContextgetParserContext(Address instructionAddress)Get the instruction parser context which corresponds to the specified instruction address.PcodeOp[]getPcode()Get an array of PCode operations (micro code) that this instruction performs.PcodeOp[]getPcode(boolean includeOverrides)Get an array of PCode operations (micro code) that this instruction performs.PcodeOp[]getPcode(int opIndex)Get an array of PCode operations (micro code) that a particular operand performs to compute its value.InstructiongetPrevious()Get the instruction before this one in address order.CodeUnitgetPreviousCodeUnit()Get the code unit before this code unit.ReferencegetPrimaryReference(int index)Get the primary reference for the operand index.SymbolgetPrimarySymbol()Get the primary Symbol for this code unit.ProcessorContextViewgetProcessorContext()Get the read-only processor context containing the context-register state state at the corresponding instruction.ProgramgetProgram()Returns the program that generated this CodeUnit.InstructionPrototypegetPrototype()Get the prototype for this instruction.ReferenceIteratorgetReferenceIteratorTo()Get an iterator over all references TO this code unit.Reference[]getReferencesFrom()Get ALL reference FROM this code unit.RegistergetRegister(int opIndex)If operand is a pure Register, return the register.RegistergetRegister(java.lang.String name)Get a Register given the name of a registerRegister[]getRegisters()Returns all the Registers for the processorRegisterValuegetRegisterValue(Register register)Get the RegisterValue for the given register.java.lang.BytegetRepeatedByte()Return the byte value repeated for all bytes within this instruction or null if byte values vary.java.lang.Object[]getResultObjects()Get the Result objects produced/affected by this instruction These would probably only be Register or AddressScalargetScalar(int opIndex)Returns the scalar at the given operand index.java.lang.StringgetSeparator(int opIndex)Get the separator strings between an operand.shortgetShort(int offset)returns the short at the given offset, taking into account the endianess.StackReferencegetStackReference(int opIndex)java.lang.StringgetStringProperty(java.lang.String name)Get the string property for name; returns null if there is no name property for this code unit.Symbol[]getSymbols()Get the symbols for this code unit.java.math.BigIntegergetValue(Register register, boolean signed)Get the contents of a processor register as a BigInteger objectbooleangetVoidProperty(java.lang.String name)Returns whether this code unit is marked as having the name property.booleanhasFallthrough()Returns true if this instruction has a fall-through flow.inthashCode()booleanhasProperty(java.lang.String name)Returns true if the codeunit has the given property defined.booleanhasValue(Register register)Returns true if a value is defined for the given register.voidinvalidate()Invalidate memory bufferbooleanisBigEndian()Returns true if the underlying bytes are in big-endian order, false if they are little endian.booleanisFallthrough()Returns true if this instruction has no execution flow other than fall-through.booleanisFallThroughOverridden()Returns true if this instructions fallthrough has been overriden.booleanisInDelaySlot()Return true if this instruction was disassembled in a delay slotbooleanisSuccessor(CodeUnit codeUnit)Return true if the given CodeUnit follows directly after this code unit.booleanisValid()java.util.Iterator<java.lang.String>propertyNames()Get an iterator over the property names.protected voidrefreshIfNeeded()voidremoveExternalReference(int opIndex)Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.voidremoveMnemonicReference(Address refAddr)Remove a reference to the mnemonic for this instruction.voidremoveOperandReference(int opIndex, Address refAddr)Remove a user defined reference to the operand at opIndex.voidremoveProperty(java.lang.String name)Remove the property value with the given name for this code unit.voidremoveStackReference(int opIndex)voidsetComment(int commentType, java.lang.String comment)Set the comment for the given type.voidsetCommentAsArray(int commentType, java.lang.String[] comment)Set the comment for the given type.voidsetExternalReference(Reference ref)voidsetFallThrough(Address addr)Overrides the instruction's default fallthrough address to the given address.voidsetFlowOverride(FlowOverride flowOverride)Set the flow override for this instruction.voidsetInstructionBlock(InstructionBlock bl)voidsetMemoryReference(int opIndex, Address refAddr, RefType refType)voidsetPrimaryMemoryReference(Reference ref)Sets a memory reference to be the primary reference at its address/opIndex location.voidsetProperty(java.lang.String name)Mark the property name as having a value for this code unit.voidsetProperty(java.lang.String name, int value)Set the property name with the given value for this code unit.voidsetProperty(java.lang.String name, Saveable value)Set the property name with the given value for this code unit.voidsetProperty(java.lang.String name, java.lang.String value)Set the property name with the given value for this code unit.voidsetRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType)Sets a register reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this register referencevoidsetRegisterValue(RegisterValue value)Sets the specified register value within this context.voidsetStackReference(int opIndex, int offset, SourceType sourceType, RefType refType)Sets a stack reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this stack referencevoidsetValue(Register register, java.math.BigInteger value)Sets the value for a Register.java.lang.StringtoString()voidvisitProperty(PropertyVisitor visitor, java.lang.String propertyName)Invokes the visit() method of the specified PropertyVisitor if the named property exists for this code unit.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.listing.CodeUnit
addMnemonicReference, addOperandReference, compareTo, contains, getAddressString, getBytes, getBytesInCodeUnit, getComment, getCommentAsArray, getExternalReference, getIntProperty, getLabel, getLength, getMaxAddress, getMinAddress, getMnemonicReferences, getObjectProperty, getPrimaryReference, getPrimarySymbol, getProgram, getReferenceIteratorTo, getReferencesFrom, getStringProperty, getSymbols, getVoidProperty, hasProperty, isSuccessor, propertyNames, removeExternalReference, removeMnemonicReference, removeOperandReference, removeProperty, setComment, setCommentAsArray, setPrimaryMemoryReference, setProperty, setProperty, setProperty, setProperty, setRegisterReference, setStackReference, visitProperty
-
Methods inherited from interface ghidra.program.model.lang.InstructionContext
getAddress
-
Methods inherited from interface ghidra.program.model.mem.MemBuffer
getAddress, getBigInteger, getByte, getBytes, getInt, getLong, getMemory, getShort, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isBigEndian, isInitializedMemory
-
-
-
-
Field Detail
-
address
protected Address address
-
maxAddress
protected Address maxAddress
-
program
protected Program program
-
length
protected int length
-
emptyAddrArray
protected static final Address[] emptyAddrArray
-
hash
protected int hash
-
bytes
protected byte[] bytes
-
isBigEndian
protected boolean isBigEndian
-
emptyMemRefs
protected static final Reference[] emptyMemRefs
-
comments
protected java.util.Map<java.lang.Integer,java.lang.String> comments
-
refMgr
protected ReferenceManager refMgr
-
-
Constructor Detail
-
PseudoInstruction
public PseudoInstruction(Program program, Address addr, InstructionPrototype prototype, MemBuffer memBuffer, ProcessorContext procContext) throws AddressOverflowException
Construct a new PseudoInstruction within a program.- Parameters:
program-addr- address of the instructionprototype- prototype of the instructionmemBuffer- buffer containing the bytes for the instructionprocContext- processor state information during disassembly- Throws:
AddressOverflowException- if code unit length causes wrap within space
-
PseudoInstruction
public PseudoInstruction(AddressFactory addrFactory, Address addr, InstructionPrototype prototype, MemBuffer memBuffer, ProcessorContext procContext) throws AddressOverflowException
Construct a new PseudoInstruction within a program.- Parameters:
addrFactory- program/language address factoryaddr- address of the instructionprototype- prototype of the instructionmemBuffer- buffer containing the bytes for the instructionprocContext- processor state information during disassembly- Throws:
AddressOverflowException- if code unit length causes wrap within space
-
PseudoInstruction
public PseudoInstruction(Address addr, InstructionPrototype prototype, MemBuffer memBuffer, ProcessorContext procContext) throws AddressOverflowException
Construct a new PseudoInstruction without a program (flow override not supported).- Parameters:
addr- address of the instructionprototype- prototype of the instructionmemBuffer- buffer containing the bytes for the instructionprocContext- processor state information during disassembly- Throws:
AddressOverflowException- if code unit length causes wrap within space
-
-
Method Detail
-
getRepeatedByte
public java.lang.Byte getRepeatedByte()
Return the byte value repeated for all bytes within this instruction or null if byte values vary.- Returns:
- repeated byte value or null if bytes vary
-
getBaseContextRegister
public Register getBaseContextRegister()
- Specified by:
getBaseContextRegisterin interfaceProcessorContextView- Returns:
- the base processor context register or null if one has not been defined
-
getOperandReferences
public Reference[] getOperandReferences(int opIndex)
Get the references for the operand index. If the operand type is a register, then the user defined references are returned; otherwise an array with the address for the operand value is returned.- Specified by:
getOperandReferencesin interfaceCodeUnit- Parameters:
opIndex- operand index (0 is the first operand)
-
equals
public boolean equals(java.lang.Object obj)
-
getPrototype
public InstructionPrototype getPrototype()
Description copied from interface:InstructionGet the prototype for this instruction.- Specified by:
getPrototypein interfaceInstruction
-
getMnemonicString
public java.lang.String getMnemonicString()
Description copied from interface:CodeUnitGet the mnemonic for this code unit, e.g., MOV, JMP- Specified by:
getMnemonicStringin interfaceCodeUnit
-
getNumOperands
public int getNumOperands()
Description copied from interface:CodeUnitGet the number of operands for this code unit.- Specified by:
getNumOperandsin interfaceCodeUnit
-
getAddress
public Address getAddress(int opIndex)
Description copied from interface:CodeUnitGet the Address for the given operand index if one exists. Data objects have one operand (the value).- Specified by:
getAddressin interfaceCodeUnit- Parameters:
opIndex- index of the operand.- Returns:
- An addres if the operand represents a fully qualified address (given the context), or if the operand is a Scalar treated as an address. Null is returned if no address or scalar exists on that operand.
-
getScalar
public Scalar getScalar(int opIndex)
Description copied from interface:CodeUnitReturns the scalar at the given operand index. Data objects have one operand (the value).
-
getRegister
public Register getRegister(int opIndex)
Description copied from interface:InstructionIf operand is a pure Register, return the register.- Specified by:
getRegisterin interfaceInstruction- Parameters:
opIndex- index of the operand.- Returns:
- A register if the operand represents a register.
-
getOpObjects
public java.lang.Object[] getOpObjects(int opIndex)
Description copied from interface:InstructionGet objects used by this operand (Address, Scalar, Register ...)- Specified by:
getOpObjectsin interfaceInstruction- Parameters:
opIndex- index of the operand.
-
getInputObjects
public java.lang.Object[] getInputObjects()
Description copied from interface:InstructionGet the Input objects used by this instruction. These could be Scalars, Registers, Addresses- Specified by:
getInputObjectsin interfaceInstruction- Returns:
- an array of objects that are used by this instruction
-
getResultObjects
public java.lang.Object[] getResultObjects()
Description copied from interface:InstructionGet the Result objects produced/affected by this instruction These would probably only be Register or Address- Specified by:
getResultObjectsin interfaceInstruction- Returns:
- an array of objects that are affected by this instruction
-
getDefaultOperandRepresentation
public java.lang.String getDefaultOperandRepresentation(int opIndex)
Description copied from interface:InstructionGet the operand representation for the given operand index without markup.- Specified by:
getDefaultOperandRepresentationin interfaceInstruction- Parameters:
opIndex- operand index- Returns:
- operand represented as a string.
-
getDefaultOperandRepresentationList
public java.util.List<java.lang.Object> getDefaultOperandRepresentationList(int opIndex)
Description copied from interface:InstructionGet the operand representation for the given operand index. A list of Register, Address, Scalar, Character and String objects is returned - without markup!- Specified by:
getDefaultOperandRepresentationListin interfaceInstruction- Parameters:
opIndex- operand index- Returns:
- ArrayList of pieces of the operand representation. Unsupported languages may return null.
-
getOperandType
public int getOperandType(int opIndex)
Description copied from interface:InstructionGet the type of a specific operand.- Specified by:
getOperandTypein interfaceInstruction- Parameters:
opIndex- the index of the operand. (zero based)- Returns:
- the type of the operand.
-
getOperandRefType
public RefType getOperandRefType(int opIndex)
Description copied from interface:InstructionGet the operand reference type for the given operand index.- Specified by:
getOperandRefTypein interfaceInstruction- Parameters:
opIndex- operand index
-
getFallThrough
public Address getFallThrough()
Description copied from interface:InstructionGet the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.- Specified by:
getFallThroughin interfaceInstruction- Returns:
- fall-through address or null if instruction has no fallthrough
-
getDefaultFallThroughOffset
public int getDefaultFallThroughOffset()
Description copied from interface:InstructionGet default fall-through offset in bytes from start of instruction to the fallthrough instruction. This accounts for any instructions contained with delay slots.- Specified by:
getDefaultFallThroughOffsetin interfaceInstruction- Returns:
- default fall-through offset or zero (0) if instruction has no fallthrough
-
getDefaultFallThrough
public Address getDefaultFallThrough()
Description copied from interface:InstructionGet the default fallthrough for this instruction. This accounts for any instructions contained with delay slots.- Specified by:
getDefaultFallThroughin interfaceInstruction- Returns:
- fall-through address or null if instruction has no default fallthrough
-
getFallFrom
public Address getFallFrom()
Description copied from interface:InstructionGet the Address for the instruction that fell through to this instruction. This is useful for handling instructions that are found in a delay slot.- Specified by:
getFallFromin interfaceInstruction
-
getFlows
public Address[] getFlows()
Description copied from interface:InstructionGet an array of Address objects for all flows other than a fall-through. This will include any flow references which have been added to the instruction.- Specified by:
getFlowsin interfaceInstruction- Returns:
- flow addresses or null if there are no flows
-
getDefaultFlows
public Address[] getDefaultFlows()
Description copied from interface:InstructionGet an array of Address objects for all default flows established by the underlying instruction prototype. References are ignored.- Specified by:
getDefaultFlowsin interfaceInstruction- Returns:
- flow addresses or null if there are no flows
-
getFlowType
public FlowType getFlowType()
Description copied from interface:InstructionGet the flow type of this instruction (how this instruction flows to the next instruction).- Specified by:
getFlowTypein interfaceInstruction
-
getPcode
public PcodeOp[] getPcode()
Description copied from interface:InstructionGet an array of PCode operations (micro code) that this instruction performs. Flow overrides are not factored into pcode.- Specified by:
getPcodein interfaceInstruction- Returns:
- an array of Pcode operations, a zero length array if the language does not support PCode
-
getPcode
public PcodeOp[] getPcode(boolean includeOverrides)
Description copied from interface:InstructionGet an array of PCode operations (micro code) that this instruction performs. NOTE: If includeOverrides is true, unique temporary varnodes may be produced which vary in size to those produced for other instructions. If your analysis is sensitive to this you should consider usingInstructionPrototype#getPcode(ghidra.program.model.mem.MemBuffer, ProcessorContext, FlowOverride, ghidra.program.model.address.UniqueAddressFactory)instead with your ownUniqueAddressFactoryto prevent duplication within your scope of analysis. by this method may not be suitable for use with certain analysis- Specified by:
getPcodein interfaceInstruction- Parameters:
includeOverrides- if true any flow overrides will be factored into generated pcode.- Returns:
- an array of Pcode operations, a zero length array if the language does not support PCode
-
getPcode
public PcodeOp[] getPcode(int opIndex)
Description copied from interface:InstructionGet an array of PCode operations (micro code) that a particular operand performs to compute its value.- Specified by:
getPcodein interfaceInstruction- Parameters:
opIndex- index of the operand to retrieve PCode- Returns:
- an array of PCode operations, a zero length array if the language does not support PCode
-
getDelaySlotDepth
public int getDelaySlotDepth()
Description copied from interface:InstructionGet the number of delay slot instructions for this argument. This should be 0 for instructions which don't have a delay slot. This is used to support the delay slots found on some RISC processors such as SPARC and the PA-RISC. This returns an integer instead of a boolean in case some other processor executes more than one instruction from a delay slot.- Specified by:
getDelaySlotDepthin interfaceInstruction
-
isInDelaySlot
public boolean isInDelaySlot()
Description copied from interface:InstructionReturn true if this instruction was disassembled in a delay slot- Specified by:
isInDelaySlotin interfaceInstruction
-
getNext
public Instruction getNext()
Description copied from interface:InstructionGet the instruction following this one in address order.- Specified by:
getNextin interfaceInstruction
-
getPrevious
public Instruction getPrevious()
Description copied from interface:InstructionGet the instruction before this one in address order.- Specified by:
getPreviousin interfaceInstruction
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clearFallThroughOverride
public void clearFallThroughOverride()
Description copied from interface:InstructionRestores this instruction's fallthrough address back to the default fallthrough for this instruction.- Specified by:
clearFallThroughOverridein interfaceInstruction
-
setFallThrough
public void setFallThrough(Address addr)
Description copied from interface:InstructionOverrides the instruction's default fallthrough address to the given address. The given address may be null to indicate that the instruction has no fallthrough.- Specified by:
setFallThroughin interfaceInstruction- Parameters:
addr- the address to be used as this instructions fallthrough address. May be null.
-
getFlowOverride
public FlowOverride getFlowOverride()
Description copied from interface:InstructionReturns the flow override which may have been set on this instruction.- Specified by:
getFlowOverridein interfaceInstruction
-
setFlowOverride
public void setFlowOverride(FlowOverride flowOverride)
Description copied from interface:InstructionSet the flow override for this instruction.- Specified by:
setFlowOverridein interfaceInstruction
-
isFallThroughOverridden
public boolean isFallThroughOverridden()
Description copied from interface:InstructionReturns true if this instructions fallthrough has been overriden.- Specified by:
isFallThroughOverriddenin interfaceInstruction
-
hasFallthrough
public boolean hasFallthrough()
Description copied from interface:InstructionReturns true if this instruction has a fall-through flow.- Specified by:
hasFallthroughin interfaceInstruction
-
isFallthrough
public boolean isFallthrough()
Description copied from interface:InstructionReturns true if this instruction has no execution flow other than fall-through.- Specified by:
isFallthroughin interfaceInstruction
-
getSeparator
public java.lang.String getSeparator(int opIndex)
Description copied from interface:InstructionGet the separator strings between an operand. The separator string for 0 are the characters before the first operand. The separator string for numOperands+1 are the characters after the last operand.- Specified by:
getSeparatorin interfaceInstruction- Parameters:
opIndex- valid values are 0 thru numOperands+1- Returns:
- separator string, or null if there is no string
-
hasValue
public boolean hasValue(Register register)
Description copied from interface:ProcessorContextViewReturns true if a value is defined for the given register.- Specified by:
hasValuein interfaceProcessorContextView- Parameters:
register- the register to check for a value.- Returns:
- true if the given register has a value.
-
getValue
public java.math.BigInteger getValue(Register register, boolean signed)
Description copied from interface:ProcessorContextViewGet the contents of a processor register as a BigInteger object- Specified by:
getValuein interfaceProcessorContextView- Parameters:
register- register to get the value for- Returns:
- a BigInteger object containing the value of the register if a value exists, otherwise null.
-
getRegisterValue
public RegisterValue getRegisterValue(Register register)
Description copied from interface:ProcessorContextViewGet the RegisterValue for the given register.- Specified by:
getRegisterValuein interfaceProcessorContextView- Parameters:
register- register to get the value for- Returns:
- RegisterValue object containing the value of the register if a value exists, otherwise null.
-
getRegister
public Register getRegister(java.lang.String name)
Description copied from interface:ProcessorContextViewGet a Register given the name of a register- Specified by:
getRegisterin interfaceProcessorContextView- Parameters:
name- the name of the register.- Returns:
- The register with the given name.
-
getRegisters
public Register[] getRegisters()
Description copied from interface:ProcessorContextViewReturns all the Registers for the processor- Specified by:
getRegistersin interfaceProcessorContextView- Returns:
- all the Registers for the processor
-
setValue
public void setValue(Register register, java.math.BigInteger value) throws ContextChangeException
Description copied from interface:ProcessorContextSets the value for a Register.- Specified by:
setValuein interfaceProcessorContext- Parameters:
register- the register to have its value setvalue- the value for the register (null is not permitted).- Throws:
ContextChangeException- an illegal attempt to change context was made
-
setRegisterValue
public void setRegisterValue(RegisterValue value) throws ContextChangeException
Description copied from interface:ProcessorContextSets the specified register value within this context.- Specified by:
setRegisterValuein interfaceProcessorContext- Parameters:
value- register value- Throws:
ContextChangeException- an illegal attempt to change context was made
-
clearRegister
public void clearRegister(Register register) throws ContextChangeException
Description copied from interface:ProcessorContextClears the register within this context.- Specified by:
clearRegisterin interfaceProcessorContext- Parameters:
register- register to be cleared.- Throws:
ContextChangeException- an illegal attempt to change context was made
-
getProcessorContext
public ProcessorContextView getProcessorContext()
Description copied from interface:InstructionContextGet the read-only processor context containing the context-register state state at the corresponding instruction. This is primarily used during the parse phase to provide the initial context-register state.- Specified by:
getProcessorContextin interfaceInstructionContext
-
getMemBuffer
public MemBuffer getMemBuffer()
Description copied from interface:InstructionContextGet the read-only memory buffer containing the instruction bytes. Its position will correspond to the instruction address.- Specified by:
getMemBufferin interfaceInstructionContext- Returns:
- instruction memory buffer
-
getParserContext
public ParserContext getParserContext() throws MemoryAccessException
Description copied from interface:InstructionContextGet the instruction parser context for the instruction which corresponds to this context object.- Specified by:
getParserContextin interfaceInstructionContext- Returns:
- the instruction parser context for the instruction which corresponds to this context object.
- Throws:
MemoryAccessException- if memory error occurred while resolving instruction details.
-
getParserContext
public ParserContext getParserContext(Address instructionAddress) throws UnknownContextException, MemoryAccessException
Description copied from interface:InstructionContextGet the instruction parser context which corresponds to the specified instruction address. This may be obtained via either caching or by parsing the instruction at the specified address. The returned ParserContext may be cast to the prototype's implementation without checking. This method will throw an UnknownContextException if a compatible ParserContext is not found at the specified address.- Specified by:
getParserContextin interfaceInstructionContext- Returns:
- the instruction parser context at the specified instruction address
- Throws:
UnknownContextException- if the instruction at the specified address was not previously parsed or attempting to instantiate context resulted in an exception.MemoryAccessException- if memory error occurred while resolving instruction details.
-
getInstructionContext
public InstructionContext getInstructionContext()
- Specified by:
getInstructionContextin interfaceInstruction
-
setInstructionBlock
public void setInstructionBlock(InstructionBlock bl)
-
invalidate
public void invalidate()
Invalidate memory buffer
-
isValid
public boolean isValid()
-
getAddressString
public java.lang.String getAddressString(boolean showBlockName, boolean pad)Description copied from interface:CodeUnitGet the string representation of the starting address for this code unit.- Specified by:
getAddressStringin interfaceCodeUnit- Parameters:
showBlockName- true if the string should include the memory block namepad- if true, the address will be padded with leading zeros. Even if pad is false, the string will be padded to make the address string contain at least 4 digits.- Returns:
- string representation of address
- See Also:
CodeUnit.getAddressString(boolean, boolean)
-
getLength
public final int getLength()
Get the length of the code unit.
-
refreshIfNeeded
protected void refreshIfNeeded()
-
getBytes
public byte[] getBytes() throws MemoryAccessExceptionGets the bytes for this code unit.- Specified by:
getBytesin interfaceCodeUnit- Returns:
- an array of bytes that are in memory at the codeunits address. The array length is the same as the codeUnits length
- Throws:
MemoryAccessException- if the full number of bytes could not be read.
-
getBytes
public int getBytes(byte[] b, int offset)Description copied from interface:MemBufferReads b.length bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position. The actual number of bytes may be fewer if bytes can't be read.- Specified by:
getBytesin interfaceMemBuffer- Parameters:
b- the buffer into which bytes will be placedoffset- the offset in this memory buffer from which to start reading bytes.- Returns:
- the number of bytes read which may be fewer than b.length if available bytes are exhausted or no bytes are available at the specified offset.
-
getBytesInCodeUnit
public void getBytesInCodeUnit(byte[] buffer, int bufferOffset) throws MemoryAccessExceptionDescription copied from interface:CodeUnitCopies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.- Specified by:
getBytesInCodeUnitin interfaceCodeUnit- Parameters:
buffer- byte array to copy intobufferOffset- offset in byte array the copy will start- Throws:
MemoryAccessException- if the full number of bytes could not be read.
-
isBigEndian
public boolean isBigEndian()
Description copied from interface:MemBufferReturns true if the underlying bytes are in big-endian order, false if they are little endian.- Specified by:
isBigEndianin interfaceMemBuffer- Returns:
- true if the underlying bytes are in big-endian order, false if they are little endian.
-
getShort
public short getShort(int offset) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the short at the given offset, taking into account the endianess.- Specified by:
getShortin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)- Returns:
- the short at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if a 2-byte short value cannot be read at the specified offset
-
getInt
public int getInt(int offset) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the int at the given offset, taking into account the endianess.- Specified by:
getIntin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)- Returns:
- the int at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if a 4-byte integer value cannot be read at the specified offset
-
getLong
public long getLong(int offset) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the long at the given offset, taking into account the endianess.- Specified by:
getLongin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)- Returns:
- the long at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if a 8-byte long value cannot be read at the specified offset
-
getBigInteger
public java.math.BigInteger getBigInteger(int offset, int size, boolean signed) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the value at the given offset, taking into account the endianess.- Specified by:
getBigIntegerin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)size- the number of bytes to include in the valuesigned- true if value should be treated as a signed twos-compliment value.- Returns:
- the value at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if the request size value cannot be read at the specified offset
-
setProperty
public void setProperty(java.lang.String name, Saveable value)Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.value- the value of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support object typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.value- the value of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support string typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setProperty
public void setProperty(java.lang.String name, int value)Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.value- the value of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support int typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setProperty
public void setProperty(java.lang.String name)
Mark the property name as having a value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support void typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
getObjectProperty
public Saveable getObjectProperty(java.lang.String name)
Get the object property for name; returns null if there is no name property for this code unit.- Specified by:
getObjectPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
TypeMismatchException- if the property manager for name does not support object typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
getStringProperty
public java.lang.String getStringProperty(java.lang.String name)
Get the string property for name; returns null if there is no name property for this code unit.- Specified by:
getStringPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
TypeMismatchException- if the property manager for name does not support string typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
getIntProperty
public int getIntProperty(java.lang.String name) throws NoValueExceptionGet the int property for name.- Specified by:
getIntPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
NoValueException- if there is not name property for this code unitTypeMismatchException- if the property manager for name does not support int typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
hasProperty
public boolean hasProperty(java.lang.String name)
Description copied from interface:CodeUnitReturns true if the codeunit has the given property defined.- Specified by:
hasPropertyin interfaceCodeUnit- Parameters:
name- the name of the property
-
getVoidProperty
public boolean getVoidProperty(java.lang.String name)
Returns whether this code unit is marked as having the name property.- Specified by:
getVoidPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
TypeMismatchException- if the property manager for name does not support void typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
propertyNames
public java.util.Iterator<java.lang.String> propertyNames()
Description copied from interface:CodeUnitGet an iterator over the property names.- Specified by:
propertyNamesin interfaceCodeUnit- See Also:
CodeUnit.propertyNames()
-
removeProperty
public void removeProperty(java.lang.String name)
Remove the property value with the given name for this code unit.- Specified by:
removePropertyin interfaceCodeUnit- Parameters:
name- the name of the property.
-
visitProperty
public void visitProperty(PropertyVisitor visitor, java.lang.String propertyName)
Invokes the visit() method of the specified PropertyVisitor if the named property exists for this code unit.- Specified by:
visitPropertyin interfaceCodeUnit- Parameters:
visitor- the class implementing the PropertyVisitor interface.propertyName- the name of the property to be visited.
-
getLabel
@Deprecated public java.lang.String getLabel()
Deprecated.Get the label for this code unit.
-
getSymbols
public Symbol[] getSymbols()
Get the symbols for this code unit.- Specified by:
getSymbolsin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getPrimarySymbol
public Symbol getPrimarySymbol()
Get the primary Symbol for this code unit.- Specified by:
getPrimarySymbolin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getMinAddress
public Address getMinAddress()
Get the starting address for this code unit.- Specified by:
getMinAddressin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getMaxAddress
public Address getMaxAddress()
Get the ending address for this code unit.- Specified by:
getMaxAddressin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getNextCodeUnit
public CodeUnit getNextCodeUnit()
Get the code unit after this code unit.- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getPreviousCodeUnit
public CodeUnit getPreviousCodeUnit()
Get the code unit before this code unit.- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
isSuccessor
public boolean isSuccessor(CodeUnit codeUnit)
Return true if the given CodeUnit follows directly after this code unit.- Specified by:
isSuccessorin interfaceCodeUnit- Parameters:
codeUnit- the codeUnit being tested to see if it follows this codeUnit.- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getComment
public java.lang.String getComment(int commentType)
Description copied from interface:CodeUnitGet the comment for the given type- Specified by:
getCommentin interfaceCodeUnit- Parameters:
commentType- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENT- Returns:
- the comment string of the appropriate type or null if no comment of that type exists for this codeunit
- See Also:
CodeUnit.getComment(int)
-
getCommentAsArray
public java.lang.String[] getCommentAsArray(int commentType)
Get the comment as an array where each element is a single line for the given type.- Specified by:
getCommentAsArrayin interfaceCodeUnit- Parameters:
commentType- must be either EOL_COMMENT_TYPE, PRE_COMMENT_TYPE, POST_COMMENT_TYPE, or PLATE_COMMENT_TYPE- Returns:
- an array of strings where each item in the array is a line of text in the comment. If there is no comment of the requested type, an empty array is returned.
- Throws:
java.lang.IllegalArgumentException- if type is not one of the three types of comments supportedjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setCommentAsArray
public void setCommentAsArray(int commentType, java.lang.String[] comment)Set the comment for the given type.- Specified by:
setCommentAsArrayin interfaceCodeUnit- Parameters:
commentType- must be either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or PLATE_COMMENTcomment- the lines that make up the comment- Throws:
java.lang.IllegalArgumentException- if type is not one of the three types of comments supportedjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setComment
public void setComment(int commentType, java.lang.String comment)Set the comment for the given type.- Specified by:
setCommentin interfaceCodeUnit- Parameters:
commentType- must be either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or PLATE_COMMENTcomment- the comment- Throws:
java.lang.IllegalArgumentException- if type is not one of the three types of comments supportedjava.util.ConcurrentModificationException- if this object is no longer valid.
-
contains
public boolean contains(Address testAddr)
Determines if this code unit contains the indicated address.
-
compareTo
public int compareTo(Address a)
Compares the given address to the address range of this node.- Specified by:
compareToin interfaceCodeUnit- Parameters:
a- the address- Returns:
- a negative integer if addr is greater than the maximum range address zero if addr is in the range a positive integer if addr is less than minimum range address
- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getByte
public byte getByte(int offset) throws MemoryAccessExceptionGet one byte from memory at the current position plus offset.- Specified by:
getBytein interfaceMemBuffer- Parameters:
offset- the displacement from the current position.- Returns:
- the data at offset from the current position.
- Throws:
AddressOutOfBoundsException- if offset exceeds address spacejava.lang.IndexOutOfBoundsException- if offset is negativeMemoryAccessException- if memory cannot be read
-
getAddress
public Address getAddress()
Get the Address which corresponds to the offset 0.- Specified by:
getAddressin interfaceMemBuffer- Returns:
- the current address of offset 0.
-
getMemory
public Memory getMemory()
Get the Memory object actually used by the MemBuffer. return the Memory used by this MemBuffer.
-
addMnemonicReference
public void addMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)
Add a reference to the mnemonic for this code unit.- Specified by:
addMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- address of reference to addrefType- type of reference being addedsourceType- the source of this reference
-
getMnemonicReferences
public Reference[] getMnemonicReferences()
Get references for the mnemonic for this instruction.- Specified by:
getMnemonicReferencesin interfaceCodeUnit- Returns:
- an array of memory references. A zero length array will be returned if there are no references for the mnemonic.
-
removeMnemonicReference
public void removeMnemonicReference(Address refAddr)
Remove a reference to the mnemonic for this instruction.- Specified by:
removeMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- the address to remove as a reference.
-
addOperandReference
public void addOperandReference(int opIndex, Address refAddr, RefType type, SourceType sourceType)Add a user defined reference to the operand at the given index.- Specified by:
addOperandReferencein interfaceCodeUnit- Parameters:
opIndex- operand indexrefAddr- reference addresstype- the reference type to be added.sourceType- the source of this reference- See Also:
CodeUnit.addOperandReference(int, ghidra.program.model.address.Address, ghidra.program.model.symbol.RefType, SourceType)
-
removeOperandReference
public void removeOperandReference(int opIndex, Address refAddr)Remove a user defined reference to the operand at opIndex.- Specified by:
removeOperandReferencein interfaceCodeUnit- Parameters:
opIndex- operand indexrefAddr- address referencing the operand
-
getReferencesFrom
public Reference[] getReferencesFrom()
Get ALL reference FROM this code unit.- Specified by:
getReferencesFromin interfaceCodeUnit- Returns:
- an array of memory references from this codeUnit or an empty array if there are no references.
-
setExternalReference
public void setExternalReference(Reference ref)
-
setStackReference
public void setStackReference(int opIndex, int offset, SourceType sourceType, RefType refType)Description copied from interface:CodeUnitSets a stack reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this stack reference- Specified by:
setStackReferencein interfaceCodeUnit- Parameters:
opIndex- the index of the operand to set this stack referenceoffset- the (+/-) offset from stack base addresssourceType- the source of this referencerefType- type of reference, RefType.READ,WRITE,PTR...
-
setRegisterReference
public void setRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType)Description copied from interface:CodeUnitSets a register reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this register reference- Specified by:
setRegisterReferencein interfaceCodeUnit- Parameters:
opIndex- the index of the operand to set this register referencereg- a registersourceType- the source of this referencerefType- type of reference, RefType.READ,WRITE,PTR...
-
getPrimaryReference
public Reference getPrimaryReference(int index)
Description copied from interface:CodeUnitGet the primary reference for the operand index.- Specified by:
getPrimaryReferencein interfaceCodeUnit- Parameters:
index- operand index (0 is the first operand)
-
setPrimaryMemoryReference
public void setPrimaryMemoryReference(Reference ref)
Description copied from interface:CodeUnitSets a memory reference to be the primary reference at its address/opIndex location. The primary reference is the one that is used in the getOperandRepresentation() method.- Specified by:
setPrimaryMemoryReferencein interfaceCodeUnit- Parameters:
ref- the reference to be set as primary.
-
getStackReference
public StackReference getStackReference(int opIndex)
- See Also:
ghidra.program.model.listing.CodeUnit#getStackReference(int)
-
removeStackReference
public void removeStackReference(int opIndex)
- See Also:
ghidra.program.model.listing.CodeUnit#removeStackReference(int)
-
getExternalReference
public ExternalReference getExternalReference(int opIndex)
Description copied from interface:CodeUnitGets the external reference (if any) at the opIndex- Specified by:
getExternalReferencein interfaceCodeUnit- Parameters:
opIndex- the operand index to look for external references- Returns:
- the external reference at the operand or null if none exists.
- See Also:
CodeUnit.getExternalReference(int)
-
removeExternalReference
public void removeExternalReference(int opIndex)
Description copied from interface:CodeUnitRemove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.- Specified by:
removeExternalReferencein interfaceCodeUnit- See Also:
CodeUnit.removeExternalReference(int)
-
getReferenceIteratorTo
public ReferenceIterator getReferenceIteratorTo()
Description copied from interface:CodeUnitGet an iterator over all references TO this code unit.- Specified by:
getReferenceIteratorToin interfaceCodeUnit- See Also:
CodeUnit.getReferenceIteratorTo()
-
getProgram
public Program getProgram()
Description copied from interface:CodeUnitReturns the program that generated this CodeUnit.- Specified by:
getProgramin interfaceCodeUnit- See Also:
CodeUnit.getProgram()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-