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

A collection of specific union data-type and how they resolve in a given context. More...

#include <unionresolve.hh>

Classes

class  Record
 A specific resolution of a union data-type. More...
 

Public Member Functions

 ResolveCache (Funcdata &fd)
 Constructor.
 
void addResolution (int4 key, Datatype *dt, PcodeOp *op, int4 slot)
 Add a specific resolution to the cache. More...
 
Datatype * resolve (int4 key, Datatype *dt) const
 Look up the in context resolution for the given data-type. More...
 
void inheritResolution (int4 key, Datatype *dt, int4 off, Varnode *vn, PcodeOp *op, int4 slot) const
 Associate a cached resolution with a new Varnode and read/write edge. More...
 
void inheritResolution (int4 key, Varnode *vn, PcodeOp *op, int4 slot) const
 Associate a cached resolution with a Varnode and its new read/write edge. More...
 

Private Attributes

Funcdata & data
 Function to which resolutions apply.
 
list< Record > resolveList
 List of known resolutions.
 

Detailed Description

A collection of specific union data-type and how they resolve in a given context.

Union resolutions are collected before a transform via addResolution(). Then afterwards Varnodes can inherit the the same resolutions via the inheritResolution() methods. Resolutions for multiple contexts can stored and retrieved by providing an id for the context in the key parameter.

Member Function Documentation

◆ addResolution()

void ghidra::ResolveCache::addResolution ( int4  key,
Datatype *  dt,
PcodeOp *  op,
int4  slot 
)

Add a specific resolution to the cache.

If a resolution for the data-type exists along the given edge, it is cached. Otherwise there is no change.

Parameters
keyis the context id associated with the resolution
dtis the data-type needing resolution
opis the PcodeOp reading/writing the resolved data-type
slotis the edge index of the resolution

References data, ghidra::ResolvedUnion::getBase(), ghidra::ResolvedUnion::getFieldNum(), ghidra::Funcdata::getUnionResolution(), ghidra::Datatype::needsResolution(), and resolveList.

Referenced by ghidra::SplitDatatype::RootPointer::find(), and ghidra::SplitDatatype::splitCopy().

◆ inheritResolution() [1/2]

void ghidra::ResolveCache::inheritResolution ( int4  key,
Datatype *  dt,
int4  off,
Varnode *  vn,
PcodeOp *  op,
int4  slot 
) const

Associate a cached resolution with a new Varnode and read/write edge.

The data-type dt can either be the current data-type of the Varnode or it can be a parent data-type, with off corresponding to the offset of the Varnode within the parent.

Parameters
keyis the context id
dtis the data-type needing resolution
offis the offset within the data-type of the Varnode
vnis the new Varnode inheriting the resolution
opis the PcodeOp reading/writing the Varnode
slotis the read/write edge

References data, ghidra::Funcdata::getArch(), ghidra::TypeFactory::getExactPiece(), ghidra::Datatype::getMetatype(), ghidra::Varnode::getSize(), ghidra::Datatype::needsResolution(), resolveList, ghidra::Funcdata::setUnionField(), ghidra::TYPE_PARTIALUNION, ghidra::TYPE_PTR, ghidra::Architecture::types, and ghidra::Varnode::updateType().

Referenced by ghidra::SplitDatatype::buildPointers(), inheritResolution(), and ghidra::SplitDatatype::splitCopy().

◆ inheritResolution() [2/2]

void ghidra::ResolveCache::inheritResolution ( int4  key,
Varnode *  vn,
PcodeOp *  op,
int4  slot 
) const
inline

Associate a cached resolution with a Varnode and its new read/write edge.

Parameters
keyis the context id
vnis the new Varnode inheriting the resolution
opis the PcodeOp reading/writing the Varnode
slotis the read/write edge

References ghidra::Varnode::getType(), and inheritResolution().

◆ resolve()

Datatype * ghidra::ResolveCache::resolve ( int4  key,
Datatype *  dt 
) const

Look up the in context resolution for the given data-type.

If the resolved data-type is in this cache, it is returned. Otherwise the original data-type is returned.

Parameters
keyis the context id
dtis the given data-type needing resolution
Returns
the resolved form of the data-type

References ghidra::Datatype::getDepend(), and resolveList.

Referenced by ghidra::SplitDatatype::buildPointers().


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