decompiler 1.0.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ghidra::BitFieldExpression Class Reference

A container for an expression manipulating a bitfield. More...

#include <expression.hh>

Inheritance diagram for ghidra::BitFieldExpression:
ghidra::InsertExpression ghidra::InsertStoreExpression ghidra::PullExpression

Public Member Functions

const VarnoderecoverStructurePointer (const Varnode *vn, int4 offset)
 Recover the Varnode holding the pointer to the parent structure.
 
bool isValid (void) const
 Is this a valid bitfield expression.
 

Static Public Member Functions

static const TypeBitFieldgetPullField (const PcodeOp *pull)
 Get field description corresponding to given ZPULL or SPULL.
 

Public Attributes

TypeStructtheStruct
 Parent structure containing the bitfield.
 
const TypeBitFieldbitfield
 Formal bitfield description.
 
int4 byteRangeOffset
 Offset of byte range into encompassStruct.
 
int4 offsetToBitStruct
 Offset of structure containing bitfield in encompassStruct.
 

Protected Member Functions

void getStructures (Datatype *dt, int4 initByteOff, int4 leastBitOff, bool isBigEndian)
 Recover the structure(s) holding the bitfield.
 

Detailed Description

A container for an expression manipulating a bitfield.

The expression centers around either a CPUI_INSERT or a CPUI_EXTRACT op but encompasses multiple p-code ops that represent either a single read of or single write to a bitfield within a structure. This class recovers the expected elements of the expression. The method isValid() returns true if the expression has the expected form and can be interpreted as a single read or write.

Member Function Documentation

◆ getPullField()

const TypeBitField * ghidra::BitFieldExpression::getPullField ( const PcodeOp pull)
static

Get field description corresponding to given ZPULL or SPULL.

Parameters
pullis the given ZPULL or SPULL
Returns
the corresponding bitfield description or null

References byteRangeOffset, ghidra::TypeStruct::findMatchingBitField(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::getSpace(), getStructures(), ghidra::Varnode::getTypeReadFacing(), ghidra::AddrSpace::isBigEndian(), offsetToBitStruct, and theStruct.

Referenced by ghidra::RulePullAbsorb::absorbCompZero().

◆ getStructures()

void ghidra::BitFieldExpression::getStructures ( Datatype dt,
int4  initByteOff,
int4  leastBitOff,
bool  isBigEndian 
)
protected

Recover the structure(s) holding the bitfield.

Find the structure immediately containing the byte range described by the given data-type. Then, given the least significant bit of the bitfield, find the structure immediately containing the bitfield, which may be a different structure.

Parameters
dtis the data-type describing the byte range
initByteOffis the initial offset of the byte range within the data-type (may be -1)
leastBitOffis the least significant bit of the bitfield within the byte range
isBigEndianis true if the data-type is stored in big endian memory

References ghidra::Datatype::getMetatype(), ghidra::TypePartialStruct::getOffset(), ghidra::TypePartialStruct::getParent(), ghidra::Datatype::getSize(), ghidra::Datatype::getSubType(), ghidra::TYPE_PARTIALSTRUCT, and ghidra::TYPE_STRUCT.

Referenced by getPullField().


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