Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
A low-level representation of a single pcode operation. More...
#include <pcoderaw.hh>
Public Member Functions | |
void | setBehavior (OpBehavior *be) |
Set the opcode for this op. | |
OpBehavior * | getBehavior (void) const |
Retrieve the behavior for this op. | |
OpCode | getOpcode (void) const |
Get the opcode for this op. | |
void | setSeqNum (const Address &a, uintm b) |
Set the sequence number. | |
const SeqNum & | getSeqNum (void) const |
Retrieve the sequence number. | |
const Address & | getAddr (void) const |
Get address of this operation. | |
void | setOutput (VarnodeData *o) |
Set the output varnode for this op. | |
VarnodeData * | getOutput (void) const |
Retrieve the output varnode for this op. | |
void | addInput (VarnodeData *i) |
Add an additional input varnode to this op. | |
void | clearInputs (void) |
Remove all input varnodes to this op. | |
int4 | numInput (void) const |
Get the number of input varnodes to this op. | |
VarnodeData * | getInput (int4 i) const |
Get the i-th input varnode for this op. | |
Static Public Member Functions | |
static OpCode | decode (Decoder &decoder, int4 isize, VarnodeData *invar, VarnodeData **outvar) |
Decode the raw OpCode and input/output Varnode data for a PcodeOp. | |
Private Attributes | |
OpBehavior * | behave |
The opcode for this operation. | |
SeqNum | seq |
Identifying address and index of this operation. | |
VarnodeData * | out |
Output varnode triple. | |
vector< VarnodeData * > | in |
Raw varnode inputs to this op. | |
A low-level representation of a single pcode operation.
This is just the minimum amount of data to represent a pcode operation An opcode, sequence number, optional output varnode and input varnodes
|
inline |
Add an additional input varnode to this op.
A PcodeOpRaw is initially created with no input varnodes. Inputs are added with this method. Varnodes are added in order, so the first addInput call creates input 0, for example.
i | is the varnode to be added as input |
References in.
Referenced by ghidra::PcodeEmitCache::dump().
|
inline |
Remove all input varnodes to this op.
If the inputs to a pcode operation need to be changed, this routine clears the existing inputs so new ones can be added.
References in.
|
static |
Decode the raw OpCode and input/output Varnode data for a PcodeOp.
This assumes the <op> element is already open. Decode info suitable for call to PcodeEmit::dump. The output pointer is changed to null if there is no output for this op, otherwise the existing pointer is used to store the output.
decoder | is the stream decoder |
isize | is the (preparsed) number of input parameters for the p-code op |
invar | is an array of storage for the input Varnodes |
outvar | is a (handle) to the storage for the output Varnode |
References ghidra::Decoder::closeElement(), ghidra::VarnodeData::decode(), ghidra::Decoder::getAddrSpaceManager(), ghidra::AddrSpaceManager::getConstantSpace(), ghidra::VarnodeData::offset, ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readSpace(), ghidra::VarnodeData::size, and ghidra::VarnodeData::space.
Referenced by ghidra::PcodeEmit::decodeOp().
|
inline |
Get address of this operation.
This is a convenience function to get the address of the machine instruction (of which this pcode op is a translation)
References ghidra::SeqNum::getAddr(), and seq.
Referenced by ghidra::EmulateMemory::executeBranchind(), ghidra::EmulateMemory::executeCallind(), and ghidra::EmulateSnippet::getExecuteAddress().
|
inline |
Retrieve the behavior for this op.
Get the underlying behavior object for this pcode operation. From this object you can determine how the object evaluates inputs to get the output
References behave.
Referenced by ghidra::EmulatePcodeCache::establishOp(), and ghidra::EmulateSnippet::setCurrentOp().
|
inline |
Get the i-th input varnode for this op.
Input varnodes are indexed starting at 0. This retrieves the input varnode by index. The index must be in range, or unpredicatable behavior will result. Use the numInput method to get the number of inputs.
i | is the index of the desired input |
References in.
Referenced by ghidra::EmulateSnippet::checkForLegalCode(), ghidra::BreakTableCallBack::doPcodeOpBreak(), ghidra::EmulateMemory::executeBinary(), ghidra::EmulateSnippet::executeBinary(), ghidra::EmulateMemory::executeBranch(), ghidra::EmulatePcodeCache::executeBranch(), ghidra::EmulateSnippet::executeBranch(), ghidra::EmulateMemory::executeBranchind(), ghidra::EmulateMemory::executeCall(), ghidra::EmulateMemory::executeCallind(), ghidra::EmulateMemory::executeCbranch(), ghidra::EmulateSnippet::executeCbranch(), ghidra::EmulateMemory::executeLoad(), ghidra::EmulateSnippet::executeLoad(), ghidra::EmulateMemory::executeStore(), ghidra::EmulateMemory::executeUnary(), and ghidra::EmulateSnippet::executeUnary().
|
inline |
Get the opcode for this op.
The possible types of pcode operations are enumerated by OpCode This routine retrieves the enumeration value for this particular op
References behave, and ghidra::OpBehavior::getOpcode().
Referenced by ghidra::EmulateSnippet::checkForLegalCode(), ghidra::EmulateSnippet::executeBranchind(), ghidra::EmulateSnippet::executeCall(), ghidra::EmulateSnippet::executeCallind(), ghidra::EmulateSnippet::executeCallother(), ghidra::EmulateSnippet::executeCpoolRef(), ghidra::EmulateSnippet::executeIndirect(), ghidra::EmulateSnippet::executeMultiequal(), ghidra::EmulateSnippet::executeNew(), ghidra::EmulateSnippet::executeSegmentOp(), and ghidra::EmulateSnippet::executeStore().
|
inline |
Retrieve the output varnode for this op.
Most pcode operations have an output varnode. This routine retrieves that varnode.
References out.
Referenced by ghidra::EmulateSnippet::checkForLegalCode(), ghidra::EmulateMemory::executeBinary(), ghidra::EmulateSnippet::executeBinary(), ghidra::EmulateMemory::executeLoad(), ghidra::EmulateSnippet::executeLoad(), ghidra::EmulateMemory::executeUnary(), and ghidra::EmulateSnippet::executeUnary().
|
inline |
Retrieve the sequence number.
Every pcode operation has a sequence number which associates the operation with the address of the machine instruction being translated and an index number for this operation within the translation.
References seq.
|
inline |
Get the number of input varnodes to this op.
References in, and ghidra::VarnodeData::size.
Referenced by ghidra::EmulateSnippet::checkForLegalCode().
|
inline |
Set the opcode for this op.
The core behavior for this operation is controlled by an OpBehavior object which knows how output is determined given inputs. This routine sets that object
be | is the behavior object |
References behave.
Referenced by ghidra::PcodeEmitCache::dump().
|
inline |
Set the output varnode for this op.
Most pcode operations output to a varnode. This routine sets what that varnode is.
o | is the varnode to set as output |
References out.
Referenced by ghidra::PcodeEmitCache::dump().
|
inline |
Set the sequence number.
Every pcode operation has a sequence number which associates the operation with the address of the machine instruction being translated and an order number which provides an index for this particular operation within the entire translation of the machine instruction
a | is the instruction address |
b | is the order number |
References seq.
Referenced by ghidra::PcodeEmitCache::dump().