decompiler  1.0.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ghidra::UserOpManage Class Reference

Manager/container for description objects (UserPcodeOp) of user defined p-code ops. More...

#include <userop.hh>

Public Member Functions

 UserOpManage (void)
 Construct an empty manager.
 
 ~UserOpManage (void)
 Destructor.
 
void initialize (Architecture *glb)
 Initialize description objects for all user defined ops. More...
 
void setDefaults (Architecture *glb)
 Create any required operations if they weren't explicitly defined. More...
 
int4 numSegmentOps (void) const
 Number of segment operations supported.
 
UserPcodeOpgetOp (int4 i) const
 
UserPcodeOpgetOp (const string &nm) const
 Retrieve description by name. More...
 
SegmentOpgetSegmentOp (int4 i) const
 
VolatileReadOpgetVolatileRead (void) const
 Get (the) volatile read description.
 
VolatileWriteOpgetVolatileWrite (void) const
 Get (the) volatile write description.
 
void decodeSegmentOp (Decoder &decoder, Architecture *glb)
 Parse a <segmentop> element. More...
 
void decodeVolatile (Decoder &decoder, Architecture *glb)
 Parse a <volatile> element. More...
 
void decodeCallOtherFixup (Decoder &decoder, Architecture *glb)
 Parse a <callotherfixup> element. More...
 
void decodeJumpAssist (Decoder &decoder, Architecture *glb)
 Parse a <jumpassist> element. More...
 
void manualCallOtherFixup (const string &useropname, const string &outname, const vector< string > &inname, const string &snippet, Architecture *glb)
 Manually install an InjectedUserOp given just names of the user defined op and the p-code snippet. More...
 

Private Member Functions

void registerOp (UserPcodeOp *op)
 Insert a new UserPcodeOp description object in the map(s) More...
 

Private Attributes

vector< UserPcodeOp * > useroplist
 Description objects indexed by CALLOTHER constant id.
 
map< string, UserPcodeOp * > useropmap
 A map from the name of the user defined operation to a description object.
 
vector< SegmentOp * > segmentop
 Segment operations supported by this Architecture.
 
VolatileReadOpvol_read
 (Single) volatile read operation
 
VolatileWriteOpvol_write
 (Single) volatile write operation
 

Detailed Description

Manager/container for description objects (UserPcodeOp) of user defined p-code ops.

The description objects are referenced by the CALLOTHER constant id, (or by name during initialization). During initialize(), every user defined p-code op presented by the Architecture is assigned a default UnspecializedPcodeOp description. Further processing of the .cspec or .pspec may reassign a more specialized description object by parsing specific tags using on of this class's parse* methods.

Member Function Documentation

◆ decodeCallOtherFixup()

void ghidra::UserOpManage::decodeCallOtherFixup ( Decoder decoder,
Architecture glb 
)

Parse a <callotherfixup> element.

Create an InjectedUserOp description object based on the element and register it with this manager.

Parameters
decoderis the stream decoder
glbis the owning Architecture

References ghidra::InjectedUserOp::decode().

◆ decodeJumpAssist()

void ghidra::UserOpManage::decodeJumpAssist ( Decoder decoder,
Architecture glb 
)

Parse a <jumpassist> element.

Create a JumpAssistOp description object based on the element and register it with this manager.

Parameters
decoderis the stream decoder
glbis the owning Architecture

References ghidra::JumpAssistOp::decode(), and ghidra::JumpAssistOp::JumpAssistOp().

◆ decodeSegmentOp()

void ghidra::UserOpManage::decodeSegmentOp ( Decoder decoder,
Architecture glb 
)

Parse a <segmentop> element.

Create a SegmentOp description object based on the element and register it with this manager.

Parameters
decoderis the stream decoder
glbis the owning Architecture

References ghidra::SegmentOp::decode().

◆ decodeVolatile()

void ghidra::UserOpManage::decodeVolatile ( Decoder decoder,
Architecture glb 
)

Parse a <volatile> element.

Create either a VolatileReadOp or VolatileWriteOp description object based on the element and register it with this manager.

Parameters
decoderis the stream decoder
glbis the owning Architecture

References ghidra::Decoder::getNextAttributeId(), and ghidra::Decoder::readString().

◆ getOp() [1/2]

UserPcodeOp* ghidra::UserOpManage::getOp ( int4  i) const
inline

◆ getOp() [2/2]

UserPcodeOp * ghidra::UserOpManage::getOp ( const string &  nm) const

Retrieve description by name.

Parameters
nmis the low-level operation name
Returns
the matching description object or NULL

◆ getSegmentOp()

SegmentOp* ghidra::UserOpManage::getSegmentOp ( int4  i) const
inline

Retrieve a segment-op description object by index

Parameters
iis the index
Returns
the indicated segment-op description

Referenced by ghidra::ActionSegmentize::apply(), ghidra::RuleSegment::applyOp(), ghidra::Funcdata::createStackRef(), and ghidra::EmulatePcodeOp::executeSegmentOp().

◆ initialize()

void ghidra::UserOpManage::initialize ( Architecture glb)

Initialize description objects for all user defined ops.

Every user defined p-code op is initially assigned an UnspecializedPcodeOp description, which may get overridden later.

Parameters
glbis the Architecture from which to draw user defined operations

References ghidra::Translate::getUserOpNames(), and ghidra::Architecture::translate.

◆ manualCallOtherFixup()

void ghidra::UserOpManage::manualCallOtherFixup ( const string &  useropname,
const string &  outname,
const vector< string > &  inname,
const string &  snippet,
Architecture glb 
)

Manually install an InjectedUserOp given just names of the user defined op and the p-code snippet.

An alternate way to attach a call-fixup to user defined p-code ops, without using XML. The p-code to inject is presented as a raw string to be handed to the p-code parser.

Parameters
useropnameis the name of the user defined op
outnameis the name of the output variable in the snippet
innameis the list of input variable names in the snippet
snippetis the raw p-code source snippet
glbis the owning Architecture

References ghidra::UserPcodeOp::getIndex(), ghidra::PcodeInjectLibrary::manualCallOtherFixup(), and ghidra::Architecture::pcodeinjectlib.

◆ registerOp()

void ghidra::UserOpManage::registerOp ( UserPcodeOp op)
private

Insert a new UserPcodeOp description object in the map(s)

Add the description to the mapping by index and the mapping by name. Make same basic sanity checks for conflicting values and duplicate operations and throw an exception if there's a problem.

Parameters
opis the new description object

References ghidra::UserPcodeOp::getIndex(), ghidra::AddrSpace::getIndex(), ghidra::UserPcodeOp::getName(), and ghidra::SegmentOp::getSpace().

◆ setDefaults()

void ghidra::UserOpManage::setDefaults ( Architecture glb)

Create any required operations if they weren't explicitly defined.

Establish defaults for necessary operators not already defined. Currently this forces volatile read/write operations to exist.

Parameters
glbis the owning Architecture

The documentation for this class was generated from the following files: