Package ghidra.program.database.code
Class InstructionDB
java.lang.Object
ghidra.program.database.DatabaseObject
ghidra.program.database.code.InstructionDB
- All Implemented Interfaces:
InstructionContext,ProcessorContext,ProcessorContextView,CodeUnit,Instruction,MemBuffer,PropertySet
Database implementation for an Instruction.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected Addressprotected byte[]protected CodeManagerprotected Addressprotected intprotected Lockprotected ProgramDBprotected ReferenceDBManagerFields inherited from class ghidra.program.database.DatabaseObject
keyFields inherited from interface ghidra.program.model.listing.CodeUnit
COMMENT_PROPERTY, DEFINED_DATA_PROPERTY, EOL_COMMENT, INSTRUCTION_PROPERTY, MNEMONIC, PLATE_COMMENT, POST_COMMENT, PRE_COMMENT, REPEATABLE_COMMENT, SPACE_PROPERTYFields inherited from interface ghidra.program.model.listing.Instruction
INVALID_DEPTH_CHANGE, MAX_LENGTH_OVERRIDE -
Constructor Summary
ConstructorsConstructorDescriptionInstructionDB(CodeManager codeMgr, DBObjectCache<? extends ghidra.program.database.code.CodeUnitDB> cache, Address address, long addr, InstructionPrototype proto, byte flags) Construct a new InstructionDB. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMnemonicReference(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 memory reference to the operand at the given index.static intcheckLengthOverride(int length, InstructionPrototype prototype) Check and revise a specifiedlengthto arrive at a suitable length-override value.voidRestores this instruction's fallthrough address back to the default fallthrough for this instruction.voidclearRegister(Register register) Clears the register within this context.intCompares the given address to the address range of this node.booleanReturns true if address is contained in the range of this codeUnit.booleanReturn true if obj is equal to this.Get the Address which corresponds to the offset 0.getAddress(int opIndex) Get the Address for the given operand index if one exists.getAddressString(boolean showBlockName, boolean pad) Get the string representation of the starting address for this code unit.getBigInteger(int offset, int size, boolean signed) returns the value at the given offset, taking into account the endianness.bytegetByte(int offset) Get one byte from memory at the current position plus offset.byte[]getBytes()Get the bytes that make up this code unit.intgetBytes(byte[] b, int offset) Readsb.lengthbytes 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.getComment(CommentType commentType) Get the comment for the given typeString[]getCommentAsArray(CommentType commentType) Get the comment for the given type and parse it into an array of strings such that each line is its own string.Get the default fallthrough for this instruction.intGet default fall-through offset in bytes from start of instruction to the fallthrough instruction.Address[]Get an array of Address objects for all default flows established by the underlying instruction prototype.getDefaultOperandRepresentation(int opIndex) Get the operand representation for the given operand index without markup.getDefaultOperandRepresentationList(int opIndex) Get the operand representation for the given operand index.intGet the number of delay slot instructions for this argument.getExternalReference(int opIndex) Gets the external reference (if any) at the opIndexGet the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.Address[]getFlows()Get an array of Address objects for all flows other than a fall-through.Object[]Get the Input objects used by this instruction.intgetInt(int offset) returns the int at the given offset, taking into account the endianness.intgetIntProperty(String name) Get the int property for name.getLabel()Returns the label for this code unit..intGet length of this code unit.longgetLong(int offset) returns the long at the given offset, taking into account the endianness.Returns the ending address for this code unit..Get the read-only memory buffer containing the instruction bytes.Get the Memory object actually used by the MemBuffer.Returns the starting address for this code unit..Get references for the mnemonic for this code unit.Returns the mnemonic for this code unit, e.g., MOV, JMP.getNext()intReturns the number of operands for this code unit..getObjectProperty(String name) Get the object property for name; returns null if there is no name property for this code unit.getOperandReferences(int opIndex) Returns the references for the operand index..getOperandRefType(int opIndex) Get the operand reference type for the given operand index.intgetOperandType(int opIndex) Get the type of a specific operand.Object[]getOpObjects(int opIndex) Get objects used by this operand (Address, Scalar, Register ...)getOriginalPrototypeContext(Register baseContextReg) Get the original context used to establish the shared prototypebyte[]Get the actual bytes parsed when forming this instruction.intGet the actual number of bytes parsed when forming this instruction.Get the instruction parser context for the instruction which corresponds to this context object.getParserContext(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.protected intgetPrimaryReference(int index) Returns the primary reference for the operand index..Returns the Primary Symbol for this code unit..Get the read-only processor context containing the context-register state state at the corresponding instruction.Returns the program that generated this CodeUnit..Returns an iterator over all references TO this code unit..Get ALL memory references FROM this code unit.getRegister(int opIndex) If operand is a pure Register, return the register.getRegister(String name) Get a Register given the name of a registerReturns all the Registers for the processor as an unmodifiable listgetRegisterValue(Register register) Get the RegisterValue for the given register.Object[]Get the Result objects produced/affected by this instruction These would probably only be Register or AddressgetScalar(int opIndex) Returns the scalar at the given operand index.getSeparator(int opIndex) Get the separator strings between an operand.shortgetShort(int offset) returns the short at the given offset, taking into account the endianness.getStringProperty(String name) Get the string property for name; returns null if there is no name property for this code unit.Symbol[]Returns the Symbols for this code unit..Get the contents of a processor register as a BigInteger objectbooleangetVoidProperty(String name) Returns whether this code unit is marked as having the name property.protected booleanhasBeenDeleted(DBRecord rec) Perform any refresh necessary and determine if this code unit has been deleted.booleaninthashCode()booleanhasProperty(String name) Returns true if the codeunit has the given property defined.booleanReturns true if a value is defined for the given register.booleanReturns true if the underlying bytes are in big-endian order, false if they are little endian.booleanbooleanbooleanbooleanDetermine if an instruction length override has been set.Get an iterator over the property names which have values applied.protected booleanrefresh()Tells the object to refresh its state from the database.protected booleanTells the object to refresh its state from the database using the specified record if not null.voidremoveExternalReference(int opIndex) Remove external reference (if any) at the given opIndexvoidremoveMnemonicReference(Address refAddr) Remove a reference to the mnemonic for this code unit.voidremoveOperandReference(int opIndex, Address refAddr) Remove a reference to the operand.voidremoveProperty(String name) Remove the property value associated with the given name .voidsetComment(CommentType commentType, String comment) Set the comment for the given comment type.voidsetCommentAsArray(CommentType commentType, String[] comment) Set the comment (with each line in its own string) for the given comment typevoidsetFallThrough(Address fallThroughAddr) Overrides the instruction's default fallthrough address to the given address.voidsetFlowOverride(FlowOverride flow) Set the flow override for this instruction.voidsetLengthOverride(int len) Set instruction length override.voidSets a memory reference to be the primary reference at its address/opIndex location.voidsetProperty(String name) Set the named property.voidsetProperty(String name, int value) Set the named integer property with the given value.voidsetProperty(String name, String value) Set the named string property with the given value.<T extends Saveable>
voidsetProperty(String name, T value) Set the named property with the givenSaveablevalue.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, BigInteger value) Sets the value for a Register.toString()Returns a string that represents this code unit with default markup.Methods inherited from class ghidra.program.database.DatabaseObject
checkDeleted, checkIsValid, checkIsValid, getKey, isDeleted, isInvalid, keyChanged, setDeleted, setInvalid, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.listing.CodeUnit
addMnemonicReference, addOperandReference, compareTo, contains, getAddressString, getBytes, getBytesInCodeUnit, getComment, getComment, getCommentAsArray, getCommentAsArray, getExternalReference, getLabel, getLength, getMaxAddress, getMinAddress, getMnemonicReferences, getOperandReferences, getPrimaryReference, getPrimarySymbol, getProgram, getReferenceIteratorTo, getReferencesFrom, getSymbols, removeExternalReference, removeMnemonicReference, removeOperandReference, setComment, setComment, setCommentAsArray, setCommentAsArray, setPrimaryMemoryReference, setRegisterReference, setStackReferenceMethods inherited from interface ghidra.program.model.lang.InstructionContext
getAddressMethods inherited from interface ghidra.program.model.mem.MemBuffer
getAddress, getBigInteger, getByte, getBytes, getInputStream, getInputStream, getInt, getLong, getMemory, getShort, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isBigEndian, isInitializedMemoryMethods inherited from interface ghidra.program.model.lang.ProcessorContext
clearRegister, setRegisterValue, setValueMethods inherited from interface ghidra.program.model.lang.ProcessorContextView
getBaseContextRegister, getRegister, getRegisters, getRegisterValue, getValue, hasValueMethods inherited from interface ghidra.program.model.util.PropertySet
getIntProperty, getObjectProperty, getStringProperty, getVoidProperty, hasProperty, propertyNames, removeProperty, setProperty, setProperty, setProperty, setProperty
-
Field Details
-
codeMgr
-
address
-
addr
protected long addr -
endAddr
-
length
protected int length -
refMgr
-
program
-
bytes
protected byte[] bytes -
lock
-
-
Constructor Details
-
InstructionDB
public InstructionDB(CodeManager codeMgr, DBObjectCache<? extends ghidra.program.database.code.CodeUnitDB> cache, Address address, long addr, InstructionPrototype proto, byte flags) Construct a new InstructionDB.- Parameters:
codeMgr- code managercache- code unit cacheaddress- min address of this instructionaddr- database keyproto- instruction prototypeflags- flow override flags
-
-
Method Details
-
refresh
Description copied from class:DatabaseObjectTells the object to refresh its state from the database using the specified record if not null. NOTE: The default implementation ignores the record and invokes refresh(). Implementations of this method must take care if multiple database tables are used since the record supplied could correspond to another object. In some cases it may be best not to override this method or ignore the record provided.- Parameters:
record- valid record associated with object's key (optional, may be null to force record lookup or other refresh technique)- Returns:
- true if the object was able to refresh itself. Return false if record is null and object was deleted. Objects that extend this class must implement a refresh method. If an object can never refresh itself, then it should always return false.
-
getPreferredCacheLength
protected int getPreferredCacheLength() -
hasBeenDeleted
Perform any refresh necessary and determine if this code unit has been deleted. If a record has been provided, it may be used to facilitate a refresh without performing a record query from the database- Parameters:
rec- optional record which corresponds to code unit. A null record does NOT indicate existence and a record query may be required.- Returns:
- true if removal of code unit has been confirmed
-
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- Returns:
- delay slot depth (number of instructions)
-
getOriginalPrototypeContext
Get the original context used to establish the shared prototype- Parameters:
baseContextReg- is a context register- Returns:
- prototype context value
-
getParsedLength
public int getParsedLength()Description copied from interface:InstructionGet the actual number of bytes parsed when forming this instruction. While this method will generally return the same value asCodeUnit.getLength(), its value will differ whenInstruction.setLengthOverride(int)has been used. In addition, it is important to note thatCodeUnit.getMaxAddress()will always reflect a non-overlapping address which reflectsCodeUnit.getLength(). This method is equivalent to the following code for a given instruction:
InstructionPrototypeproto = instruction.Instruction.getPrototype(); int length = proto.getLength();- Specified by:
getParsedLengthin interfaceInstruction- Returns:
- the actual number of bytes parsed when forming this instruction
-
getParsedBytes
Description copied from interface:InstructionGet the actual bytes parsed when forming this instruction. While this method will generally return the same value asCodeUnit.getBytes(), it will return more bytes whenInstruction.setLengthOverride(int)has been used. In this override situation, the bytes returned will generally duplicate some of the parsed bytes associated with the next instruction that this instruction overlaps. This method is equivalent to the following code for a given instruction:
InstructionPrototypeproto = instruction.Instruction.getPrototype();Memorymem = instruction.MemBuffer.getMemory(); byte[] bytes = mem.getBytes(instruction.MemBuffer.getAddress(), proto.getLength()); int length = proto.getLength();- Specified by:
getParsedBytesin interfaceInstruction- Returns:
- the actual number of bytes parsed when forming this instruction
- Throws:
MemoryAccessException- if the full number of bytes could not be read
-
getFallFrom
- Specified by:
getFallFromin interfaceInstruction- Returns:
- the Address for the instruction that fell through to
this instruction.
This is useful for handling instructions that are found
in a delay slot.
Note: if an instruction is in a delayslot, then it may have
a branch into the delayslot, which is handled as follows
JMPIF Y, X lab: _ADD getFallFrom() = JMPIF MOV getFallFrom() = _ADD JMP Y, X lab: _ADD getFallFrom() = null MOV getFallFrom() = _ADD JMPIF Y, X _ADD getFallFrom() = JMPIF MOV getFallFrom() = JMPIF JMP Y, X _ADD getFallFrom() = JMP MOV getFallFrom() = null
-
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
-
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
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
- Specified by:
getFlowTypein interfaceInstruction- Returns:
- the flow type of this instruction (how this instruction flows to the next instruction).
-
getNext
- Specified by:
getNextin interfaceInstruction- Returns:
- the instruction following this one in address order or null if none found.
-
getOperandRefType
Description copied from interface:InstructionGet the operand reference type for the given operand index.- Specified by:
getOperandRefTypein interfaceInstruction- Parameters:
opIndex- operand index- Returns:
- the operand reference type for the given operand index.
-
getSeparator
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
-
getDefaultOperandRepresentation
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
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.
- See Also:
-
getOpObjects
Description copied from interface:InstructionGet objects used by this operand (Address, Scalar, Register ...)- Specified by:
getOpObjectsin interfaceInstruction- Parameters:
opIndex- index of the operand.- Returns:
- objects used by this operand (Address, Scalar, Register ...)
-
getPrevious
- Specified by:
getPreviousin interfaceInstruction- Returns:
- the instruction before this one in address order or null if none found.
-
getPrototype
- Specified by:
getPrototypein interfaceInstruction- Returns:
- the prototype for this instruction.
-
getRegister
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.
-
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
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
-
isInDelaySlot
public boolean isInDelaySlot()- Specified by:
isInDelaySlotin interfaceInstruction- Returns:
- true if this instruction was disassembled in a delay slot
-
getAddress
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.
-
toString
Returns a string that represents this code unit with default markup. Only the mnemonic and operands are included. -
getMnemonicString
Description copied from interface:CodeUnitReturns the mnemonic for this code unit, e.g., MOV, JMP.- Specified by:
getMnemonicStringin interfaceCodeUnit- Returns:
- the mnemonic for this code unit, e.g., MOV, JMP
-
getNumOperands
public int getNumOperands()Description copied from interface:CodeUnitReturns the number of operands for this code unit..- Specified by:
getNumOperandsin interfaceCodeUnit- Returns:
- the number of operands for this code unit.
-
getScalar
Description copied from interface:CodeUnitReturns the scalar at the given operand index. Data objects have one operand (the value). -
equals
Return true if obj is equal to this. -
getFlowOverride
- Specified by:
getFlowOverridein interfaceInstruction- Returns:
- the flow override which may have been set on this instruction.
-
setFlowOverride
Description copied from interface:InstructionSet the flow override for this instruction.- Specified by:
setFlowOverridein interfaceInstruction- Parameters:
flow- flow override setting orFlowOverride.NONEto clear.
-
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
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.- 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
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
-
isFallThroughOverridden
public boolean isFallThroughOverridden()- Specified by:
isFallThroughOverriddenin interfaceInstruction- Returns:
- true if this instructions fallthrough has been overriden.
-
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
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:
fallThroughAddr- the address to be used as this instructions fallthrough address. May be null.
-
setLengthOverride
Description copied from interface:InstructionSet instruction length override. Specified length must be in the range 0..7 where 0 clears the setting and adopts the default length. The specified length must be less than the actual number of bytes consumed by the prototype and be a multiple of the language specified instruction alignment.NOTE: Use of the feature with a delay slot instruction is discouraged.
- Specified by:
setLengthOverridein interfaceInstruction- Parameters:
len- effective instruction code unit length.- Throws:
CodeUnitInsertionException- if expanding instruction length conflicts with another instruction or length is not a multiple of the language specified instruction alignment.
-
checkLengthOverride
public static int checkLengthOverride(int length, InstructionPrototype prototype) throws IllegalArgumentException, CodeUnitInsertionException Check and revise a specifiedlengthto arrive at a suitable length-override value.- Parameters:
length- instruction byte-length (must be in the range 0..prototype-length). If smaller than the prototype length it must have a value no greater than 7, otherwise an error will be thrown. A value of 0 or greater-than-or-equal the prototype length will be ignored and not impose and override length. The length value must be a multiple of theinstruction alignment.prototype- instruction prototype- Returns:
- length-override value (0 = disable length-override)
- Throws:
CodeUnitInsertionException- thrown if the new Instruction would overlap and existingCodeUnitor the specifiedlengthis unsupported.IllegalArgumentException- if a negativelengthis specified.
-
isLengthOverridden
public boolean isLengthOverridden()Description copied from interface:InstructionDetermine if an instruction length override has been set.- Specified by:
isLengthOverriddenin interfaceInstruction- Returns:
- true if length override has been set else false.
-
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
-
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
-
hasFallthrough
public boolean hasFallthrough()- Specified by:
hasFallthroughin interfaceInstruction- Returns:
- true if this instruction has a fall-through flow.
-
isFallthrough
public boolean isFallthrough()- Specified by:
isFallthroughin interfaceInstruction- Returns:
- true if this instruction has no execution flow other than fall-through.
-
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- Returns:
- the read-only processor context
-
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
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.
-
getInstructionContext
- Specified by:
getInstructionContextin interfaceInstruction- Returns:
- the instruction context for this instruction
-
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- Parameters:
instructionAddress- instruction address of requested context- 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.
-
refresh
protected boolean refresh()Description copied from class:DatabaseObjectTells the object to refresh its state from the database.- Specified by:
refreshin classDatabaseObject- Returns:
- true if the object was able to refresh itself. Return false if the object was deleted. Objects that extend this class must implement a refresh method. If an object can never refresh itself, then it should always return false.
-
addMnemonicReference
Description copied from interface:CodeUnitAdd a reference to the mnemonic for this code unit.- Specified by:
addMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- address to add as a reference.refType- the type of reference to add.sourceType- the source of this reference
-
addOperandReference
Description copied from interface:CodeUnitAdd a memory 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:
-
compareTo
Description copied from interface:CodeUnitCompares the given address to the address range of this node. -
contains
Description copied from interface:CodeUnitReturns true if address is contained in the range of this codeUnit. -
getAddressString
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
-
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
Description copied from interface:MemBufferreturns the short at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if a 2-byte short value cannot be read at the specified offset
-
getInt
Description copied from interface:MemBufferreturns the int at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if a 4-byte integer value cannot be read at the specified offset
-
getLong
Description copied from interface:MemBufferreturns the long at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if a 8-byte long value cannot be read at the specified offset
-
getBigInteger
Description copied from interface:MemBufferreturns the value at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if the request size value cannot be read at the specified offset
-
getComment
Description copied from interface:CodeUnitGet the comment for the given type- Specified by:
getCommentin interfaceCodeUnit- Parameters:
commentType-comment type- Returns:
- the comment string of the appropriate type or null if no comment of that type exists for this code unit
-
getCommentAsArray
Description copied from interface:CodeUnitGet the comment for the given type and parse it into an array of strings such that each line is its own string.- Specified by:
getCommentAsArrayin interfaceCodeUnit- Parameters:
commentType-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.
-
getExternalReference
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.
-
getIntProperty
Description copied from interface:PropertySetGet the int property for name.- Specified by:
getIntPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- integer property value property has been set
- Throws:
NoValueException- if there is not name property for this code unit
-
getLabel
Description copied from interface:CodeUnitReturns the label for this code unit.. -
getLength
public int getLength()Description copied from interface:CodeUnitGet length of this code unit. NOTE: If aninstruction length-overrideis set this method will return the reduced length. -
getMaxAddress
Description copied from interface:CodeUnitReturns the ending address for this code unit..- Specified by:
getMaxAddressin interfaceCodeUnit- Returns:
- the ending address for this code unit.
-
getMinAddress
Description copied from interface:CodeUnitReturns the starting address for this code unit..- Specified by:
getMinAddressin interfaceCodeUnit- Returns:
- the starting address for this code unit.
-
getAddress
Description copied from interface:MemBufferGet the Address which corresponds to the offset 0.- Specified by:
getAddressin interfaceMemBuffer- Returns:
- the current address of offset 0.
-
getMnemonicReferences
Description copied from interface:CodeUnitGet references for the mnemonic for this code unit.- 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.
-
getObjectProperty
Description copied from interface:PropertySetGet the object property for name; returns null if there is no name property for this code unit.- Specified by:
getObjectPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
Saveableproperty value, with map-specific implementation class, or null.
-
getOperandReferences
Description copied from interface:CodeUnitReturns the references for the operand index..- Specified by:
getOperandReferencesin interfaceCodeUnit- Parameters:
opIndex- operand index (0 is the first operand)- Returns:
- the references for the operand index.
-
getPrimaryReference
Description copied from interface:CodeUnitReturns the primary reference for the operand index..- Specified by:
getPrimaryReferencein interfaceCodeUnit- Parameters:
index- operand index (0 is the first operand)- Returns:
- the primary reference for the operand index.
-
getPrimarySymbol
Description copied from interface:CodeUnitReturns the Primary Symbol for this code unit..- Specified by:
getPrimarySymbolin interfaceCodeUnit- Returns:
- the Primary Symbol for this code unit.
-
getProgram
Description copied from interface:CodeUnitReturns the program that generated this CodeUnit..- Specified by:
getProgramin interfaceCodeUnit- Returns:
- the program that generated this CodeUnit.
-
getReferencesFrom
Description copied from interface:CodeUnitGet ALL memory references 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.
-
getReferenceIteratorTo
Description copied from interface:CodeUnitReturns an iterator over all references TO this code unit..- Specified by:
getReferenceIteratorToin interfaceCodeUnit- Returns:
- an iterator over all references TO this code unit.
-
getStringProperty
Description copied from interface:PropertySetGet the string property for name; returns null if there is no name property for this code unit.- Specified by:
getStringPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- string property value or null
-
getSymbols
Description copied from interface:CodeUnitReturns the Symbols for this code unit..- Specified by:
getSymbolsin interfaceCodeUnit- Returns:
- the Symbols for this code unit.
-
getVoidProperty
Description copied from interface:PropertySetReturns whether this code unit is marked as having the name property.- Specified by:
getVoidPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- true if property has been set, else false
-
hasProperty
Description copied from interface:PropertySetReturns true if the codeunit has the given property defined. This method works for all property map types.- Specified by:
hasPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- true if property has been set, else false
-
propertyNames
Description copied from interface:PropertySetGet an iterator over the property names which have values applied.- Specified by:
propertyNamesin interfacePropertySet- Returns:
- iterator of all property map names which have values applied
-
removeExternalReference
public void removeExternalReference(int opIndex) Description copied from interface:CodeUnitRemove external reference (if any) at the given opIndex- Specified by:
removeExternalReferencein interfaceCodeUnit- Parameters:
opIndex- the index of the operand from which to remove any external reference.
-
removeMnemonicReference
Description copied from interface:CodeUnitRemove a reference to the mnemonic for this code unit.- Specified by:
removeMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- the address to remove as a reference.
-
removeOperandReference
Description copied from interface:CodeUnitRemove a reference to the operand.- Specified by:
removeOperandReferencein interfaceCodeUnit- Parameters:
opIndex- operand indexrefAddr- address referencing the operand
-
removeProperty
Description copied from interface:PropertySetRemove the property value associated with the given name .- Specified by:
removePropertyin interfacePropertySet- Parameters:
name- the name of the property
-
setComment
Description copied from interface:CodeUnitSet the comment for the given comment type. Passingnullclears the comment- Specified by:
setCommentin interfaceCodeUnit- Parameters:
commentType-comment typecomment- comment for code unit; null clears the comment
-
setCommentAsArray
Description copied from interface:CodeUnitSet the comment (with each line in its own string) for the given comment type- Specified by:
setCommentAsArrayin interfaceCodeUnit- Parameters:
commentType-comment typecomment- an array of strings where each string is a single line of the comment.
-
setPrimaryMemoryReference
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.
-
setProperty
Description copied from interface:PropertySetSet the named integer property with the given value.- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.value- value to be stored.
-
setProperty
Description copied from interface:PropertySetSet the named property with the givenSaveablevalue.- Specified by:
setPropertyin interfacePropertySet- Type Parameters:
T-Saveableimplementation- Parameters:
name- the name of the property.value- value to be stored.
-
setProperty
Description copied from interface:PropertySetSet the named string property with the given value.- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.value- value to be stored.
-
setProperty
Description copied from interface:PropertySetSet the named property. This method is used for "void" properites. The property is either set or not set - there is no value- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.
-
setStackReference
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
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...
-
getBytes
public int getBytes(byte[] b, int offset) Description copied from interface:MemBufferReadsb.lengthbytes 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.
-
getBytes
Description copied from interface:CodeUnitGet the bytes that make up this code unit. NOTE: If aninstruction length-overrideis set this method will not return all bytes associated with theinstruction prototype.- 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.
-
getByte
Description copied from interface:MemBufferGet 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:
MemoryAccessException- if memory cannot be read at the specified offset
-
getMemory
Description copied from interface:MemBufferGet the Memory object actually used by the MemBuffer. -
getValue
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
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.
-
setValue
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
-
clearRegister
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
-
setRegisterValue
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
-
getRegister
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.
-
getBaseContextRegister
- Specified by:
getBaseContextRegisterin interfaceProcessorContextView- Returns:
- the base processor context register or null if one has not been defined
-
getRegisters
Description copied from interface:ProcessorContextViewReturns all the Registers for the processor as an unmodifiable list- Specified by:
getRegistersin interfaceProcessorContextView- Returns:
- all the Registers for the processor
-
hasValue
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.
-
hashCode
public int hashCode() -
getBytesInCodeUnit
Description 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.
-