Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::UserPcodeOp Class Referenceabstract

The base class for a detailed definition of a user-defined p-code operation. More...

#include <userop.hh>

Inheritance diagram for ghidra::UserPcodeOp:
[legend]
Collaboration diagram for ghidra::UserPcodeOp:
[legend]

Public Types

enum  userop_flags { annotation_assignment = 1 , no_operator = 2 , display_string = 4 }
 Enumeration of different boolean properties that can be assigned to a CALLOTHER. More...
 
enum  userop_type {
  unspecialized = 1 , injected = 2 , volatile_read = 3 , volatile_write = 4 ,
  segment = 5 , jumpassist = 6 , string_data = 7 , datatype = 8
}
 User-op class encoded as an enum. More...
 

Public Member Functions

 UserPcodeOp (const string &nm, Architecture *g, uint4 tp, int4 ind)
 Construct from name and index.
 
const string & getName (void) const
 Get the low-level name of the p-code op.
 
uint4 getType (void) const
 Get the encoded class type.
 
int4 getIndex (void) const
 Get the constant id of the op.
 
uint4 getDisplay (void) const
 Get display type (0=functional)
 
virtual ~UserPcodeOp (void)
 Destructor.
 
virtual string getOperatorName (const PcodeOp *op) const
 Get the symbol representing this operation in decompiled code.
 
virtual DatatypegetOutputLocal (const PcodeOp *op) const
 Return the output data-type of the user-op if specified.
 
virtual DatatypegetInputLocal (const PcodeOp *op, int4 slot) const
 Return the input data-type to the user-op in the given slot.
 
virtual int4 extractAnnotationSize (const Varnode *vn, const PcodeOp *op)
 Assign a size to an annotation input to this userop.
 
virtual void decode (Decoder &decoder)=0
 Restore the detailed description from a stream element.
 

Static Public Attributes

static const uint4 BUILTIN_STRINGDATA = 0x10000000
 Built-in id for the InternalStringOp.
 
static const uint4 BUILTIN_VOLATILE_READ = 0x10000001
 Built-in id for VolatileReadOp.
 
static const uint4 BUILTIN_VOLATILE_WRITE = 0x10000002
 Built-in id for VolatileWriteOp.
 
static const uint4 BUILTIN_MEMCPY = 0x10000003
 Built-in id for memcpy.
 
static const uint4 BUILTIN_STRNCPY = 0x10000004
 Built-in id for strcpy.
 
static const uint4 BUILTIN_WCSNCPY = 0x10000005
 Built-in id for wcsncpy.
 

Protected Attributes

string name
 Low-level name of p-code operator.
 
Architectureglb
 Architecture owning the user defined op.
 
uint4 type
 Encoded class type (userop_type)
 
int4 useropindex
 Index passed in the CALLOTHER op.
 
uint4 flags
 Boolean attributes of the CALLOTHER.
 

Detailed Description

The base class for a detailed definition of a user-defined p-code operation.

Within the raw p-code framework, the CALLOTHER opcode represents a user defined operation. At this level, the operation is just a placeholder for inputs and outputs to same black-box procedure. The first input parameter (index 0) must be a constant id associated with the particular procedure. Classes derived off of this base class provide a more specialized definition of an operation/procedure. The specialized classes are managed via UserOpManage and are associated with CALLOTHER ops via the constant id.

The derived classes can in principle implement any functionality, tailored to the architecture or program. At this base level, the only commonality is a formal name of the operator and its CALLOTHER index. A facility for reading in implementation details is provided via decode().

Member Enumeration Documentation

◆ userop_flags

Enumeration of different boolean properties that can be assigned to a CALLOTHER.

Enumerator
annotation_assignment 

Displayed as assignment, in1 = in2, where the first parameter is an annotation.

no_operator 

Don't emit special token, just emit the first input parameter as expression.

display_string 

Emit as a string constant.

◆ userop_type

User-op class encoded as an enum.

Enumerator
unspecialized 

Encoding for UnspecializedPcodeOp.

injected 

InjectedUserOp.

volatile_read 

VolatileReadOp.

volatile_write 

VolatileWriteOp.

segment 

SegmentOp.

jumpassist 

JumpAssistOp.

string_data 

InternalStringOp.

datatype 

DatatypeUserOp.

Member Function Documentation

◆ decode()

virtual void ghidra::UserPcodeOp::decode ( Decoder decoder)
pure virtual

Restore the detailed description from a stream element.

The details of how a user defined operation behaves are parsed from the element.

Parameters
decoderis the stream decoder

Implemented in ghidra::UnspecializedPcodeOp, ghidra::DatatypeUserOp, ghidra::InjectedUserOp, ghidra::VolatileOp, ghidra::SegmentOp, ghidra::JumpAssistOp, and ghidra::InternalStringOp.

◆ extractAnnotationSize()

int4 ghidra::UserPcodeOp::extractAnnotationSize ( const Varnode vn,
const PcodeOp op 
)
virtual

Assign a size to an annotation input to this userop.

Assuming an annotation refers to a special symbol accessed by this operation, retrieve the size (in bytes) of the symbol, which isn't ordinarily stored as part of the annotation.

Parameters
vnis the annotation Varnode
opis the specific PcodeOp instance of this userop

Reimplemented in ghidra::VolatileReadOp, and ghidra::VolatileWriteOp.

References name.

Referenced by ghidra::PrintC::pushAnnotation().

◆ getInputLocal()

virtual Datatype * ghidra::UserPcodeOp::getInputLocal ( const PcodeOp op,
int4  slot 
) const
inlinevirtual

Return the input data-type to the user-op in the given slot.

Parameters
opif the instantiation of the user-op
slotis the given input slot
Returns
the data-type or null to indicate the data-type is unspecified

Reimplemented in ghidra::DatatypeUserOp, and ghidra::VolatileWriteOp.

Referenced by ghidra::TypeOpCallother::getInputLocal().

◆ getOperatorName()

virtual string ghidra::UserPcodeOp::getOperatorName ( const PcodeOp op) const
inlinevirtual

Get the symbol representing this operation in decompiled code.

This will return the symbol formally displayed in source code, which can be tailored more than the low-level name

Parameters
opis the operation (in context) where a symbol is needed
Returns
the symbol as a string

Reimplemented in ghidra::VolatileReadOp, and ghidra::VolatileWriteOp.

References name.

Referenced by ghidra::TypeOpCallother::getOperatorName().

◆ getOutputLocal()

virtual Datatype * ghidra::UserPcodeOp::getOutputLocal ( const PcodeOp op) const
inlinevirtual

Return the output data-type of the user-op if specified.

Parameters
opis the instantiation of the user-op
Returns
the data-type or null to indicate the data-type is unspecified

Reimplemented in ghidra::DatatypeUserOp, ghidra::VolatileReadOp, and ghidra::InternalStringOp.

Referenced by ghidra::TypeOpCallother::getOutputLocal().


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