Class SleighParserContext
java.lang.Object
ghidra.app.plugin.processors.sleigh.SleighParserContext
- All Implemented Interfaces:
ParserContext
All the recovered context for a single instruction
The main data structure is the tree of constructors and operands
-
Constructor Summary
ConstructorDescriptionSleighParserContext
(SleighParserContext origContext, int delayByteCount) Generate context specifically for an instruction that has a delayslot.SleighParserContext
(Address aAddr, Address nAddr, Address rAddr, Address dAddr) Constructor for building precompiled templates.SleighParserContext
(MemBuffer memBuf, SleighInstructionPrototype prototype, ProcessorContextView processorContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommit
(ConstructState point, TripleSymbol sym, int num, int mask) void
getAddr()
get address of current instructionGet constant address spaceint
getContextBits
(int startbit, int bitsize) Get bits from context into an intint[]
Get full set of context bytes.int
getContextBytes
(int bytestart, int bytesize) Get bytes from context into an intGet the processor context value as a RegisterValueGet address space containing current instructiongetFixedHandle
(ConstructState constructState) int
getInstructionBits
(int offset, int startbit, int size) Get bits from the instruction stream into an int (packed in big endian format).int
getInstructionBytes
(int offset, int bytestart, int size) Get bytes from the instruction stream into an int (packed in big endian format).Get memory buffer for current instruction which may also be used to parse next instruction or delay slot instructions.Get address of instruction after the next instruction.getNaddr()
Get address of instruction after current instruction.boolean
void
setContextWord
(int i, int val, int mask)
-
Constructor Details
-
SleighParserContext
public SleighParserContext(MemBuffer memBuf, SleighInstructionPrototype prototype, ProcessorContextView processorContext) -
SleighParserContext
Constructor for building precompiled templates. NOTE: This form does not support use ofinst_next2
.- Parameters:
aAddr
- = address to which 'inst_start' resolvesnAddr
- = address to which 'inst_next' resolvesrAddr
- = special address associated with original calldAddr
- = destination address of original call being replaced
-
SleighParserContext
Generate context specifically for an instruction that has a delayslot. When generating p-code SLEIGH has an alternate interpretation of the "inst_next" symbol that takes into account the instruction in the delay slot. This context is generated at the point when specific instruction(s) in the delay slot are known.- Parameters:
origContext
- is the original context (for the instruction in isolation)delayByteCount
- is the number of bytes in instruction stream occupied by the delay slot
-
-
Method Details
-
getPrototype
- Specified by:
getPrototype
in interfaceParserContext
-
addCommit
-
applyCommits
- Throws:
MemoryAccessException
-
getFixedHandle
-
getAddr
get address of current instruction- Returns:
- address of current instruction
-
getNaddr
Get address of instruction after current instruction. This may return null if this context instance does not support use ofinst_next
or next address falls beyond end of address space.- Returns:
- address of next instruction or null
-
getN2addr
Get address of instruction after the next instruction. This may returngetNaddr()
if this context instance does not support use ofinst_next2
or parse of next instruction fails.- Returns:
- address of instruction after the next instruction or null
-
getCurSpace
Get address space containing current instruction- Returns:
- address space containing current instruction
-
getConstSpace
Get constant address space- Returns:
- constant address space
-
getMemBuffer
Get memory buffer for current instruction which may also be used to parse next instruction or delay slot instructions.- Returns:
- memory buffer for current instruction
-
getInstructionBytes
Get bytes from the instruction stream into an int (packed in big endian format). Uninitialized or undefined memory will return zero byte values.- Parameters:
offset
- offset relative start of this contextbytestart
- pattern byte offset relative to specified context offsetsize
- is the number of bytes to fetch- Returns:
- requested byte-range value
- Throws:
MemoryAccessException
- if no bytes are available at first byte when (offset+bytestart==0).
-
getInstructionBits
Get bits from the instruction stream into an int (packed in big endian format). Uninitialized or undefined memory will return zero bit values.- Parameters:
offset
- offset relative start of this contextstartbit
- is the index of the first bit to fetchsize
- is the number of bits to fetch- Returns:
- requested bit-range value
- Throws:
MemoryAccessException
- if no bytes are available at first byte when (offset+bytestart/8==0).
-
getContextRegisterValue
Get the processor context value as a RegisterValue- Returns:
- processor context value
-
getContextBytes
public int getContextBytes(int bytestart, int bytesize) Get bytes from context into an int- Parameters:
bytestart
- is the index of the first byte to fetchbytesize
- number of bytes (range: 1 - 4)- Returns:
- the packed bytes from context
-
getContextBytes
public int[] getContextBytes()Get full set of context bytes. Sleigh only supports context which is a multiple of 4-bytes (i.e., size of int)- Returns:
- the array of context data
-
getContextBits
public int getContextBits(int startbit, int bitsize) Get bits from context into an int- Parameters:
startbit
- is the index of the first bit to fetchbitsize
- number of bits (range: 1 - 32)- Returns:
- the packed bits
-
setContextWord
public void setContextWord(int i, int val, int mask) -
isValid
-
getFlowRefAddr
-
getFlowDestAddr
-