decompiler  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ghidra::Varnode Class Reference

A low-level variable or contiguous set of bytes described by an Address and a size. More...

#include <varnode.hh>

Public Types

enum  varnode_flags {
  mark = 0x01, constant = 0x02, annotation = 0x04, input = 0x08,
  written = 0x10, insert = 0x20, implied = 0x40, explict = 0x80,
  typelock = 0x100, namelock = 0x200, nolocalalias = 0x400, volatil = 0x800,
  externref = 0x1000, readonly = 0x2000, persist = 0x4000, addrtied = 0x8000,
  unaffected = 0x10000, spacebase = 0x20000, indirectonly = 0x40000, directwrite = 0x80000,
  addrforce = 0x100000, mapped = 0x200000, indirect_creation = 0x400000, return_address = 0x800000,
  coverdirty = 0x1000000, precislo = 0x2000000, precishi = 0x4000000, indirectstorage = 0x8000000,
  hiddenretparm = 0x10000000, incidental_copy = 0x20000000, autolive_hold = 0x40000000, proto_partial = 0x80000000
}
 
enum  addl_flags {
  activeheritage = 0x01, writemask = 0x02, vacconsume = 0x04, lisconsume = 0x08,
  ptrcheck = 0x10, ptrflow = 0x20, unsignedprint = 0x40, longprint = 0x80,
  stack_store = 0x100, locked_input = 0x200, spacebase_placeholder = 0x400, stop_uppropagation = 0x800,
  has_implied_field = 0x1000
}
 Additional boolean properties on a Varnode. More...
 

Public Member Functions

void setHigh (HighVariable *tv, int2 mg)
 Set the HighVariable owning this Varnode.
 
const AddressgetAddr (void) const
 Get the storage Address.
 
AddrSpacegetSpace (void) const
 Get the AddrSpace storing this Varnode.
 
AddrSpacegetSpaceFromConst (void) const
 Get AddrSpace from this encoded constant Varnode. More...
 
uintb getOffset (void) const
 Get the offset (within its AddrSpace) where this is stored.
 
int4 getSize (void) const
 Get the number of bytes this Varnode stores.
 
int2 getMergeGroup (void) const
 Get the forced merge group of this Varnode.
 
PcodeOpgetDef (void)
 Get the defining PcodeOp of this Varnode.
 
const PcodeOpgetDef (void) const
 Get the defining PcodeOp.
 
HighVariablegetHigh (void) const
 Get the high-level variable associated with this Varnode. More...
 
SymbolEntrygetSymbolEntry (void) const
 Get symbol and scope information associated with this Varnode.
 
uint4 getFlags (void) const
 Get all the boolean attributes.
 
DatatypegetType (void) const
 Get the Datatype associated with this Varnode.
 
DatatypegetTypeDefFacing (void) const
 Return the data-type of this when it is written to. More...
 
DatatypegetTypeReadFacing (const PcodeOp *op) const
 Get the data-type of this when it is read by the given PcodeOp. More...
 
DatatypegetHighTypeDefFacing (void) const
 Return the data-type of the HighVariable when this is written to. More...
 
DatatypegetHighTypeReadFacing (const PcodeOp *op) const
 Return data-type of the HighVariable when read by the given PcodeOp. More...
 
void setTempType (Datatype *t) const
 Set the temporary Datatype.
 
DatatypegetTempType (void) const
 Get the temporary Datatype (used during type propagation)
 
void setValueSet (ValueSet *v) const
 Set the temporary ValueSet record.
 
ValueSetgetValueSet (void) const
 Get the temporary ValueSet record.
 
uint4 getCreateIndex (void) const
 Get the creation index.
 
CovergetCover (void) const
 Get Varnode coverage information.
 
list< PcodeOp * >::const_iterator beginDescend (void) const
 Get iterator to list of syntax tree descendants (reads)
 
list< PcodeOp * >::const_iterator endDescend (void) const
 Get the end iterator to list of descendants.
 
uintb getConsume (void) const
 Get mask of consumed bits.
 
void setConsume (uintb val)
 Set the mask of consumed bits (used by dead-code algorithm)
 
bool isConsumeList (void) const
 Get marker used by dead-code algorithm.
 
bool isConsumeVacuous (void) const
 Get marker used by dead-code algorithm.
 
void setConsumeList (void)
 Set marker used by dead-code algorithm.
 
void setConsumeVacuous (void)
 Set marker used by dead-code algorithm.
 
void clearConsumeList (void)
 Clear marker used by dead-code algorithm.
 
void clearConsumeVacuous (void)
 Clear marker used by dead-code algorithm.
 
PcodeOploneDescend (void) const
 Return unique reading PcodeOp, or null if there are zero or more than 1. More...
 
Address getUsePoint (const Funcdata &fd) const
 Get Address when this Varnode first comes into scope. More...
 
int4 printRawNoMarkup (ostream &s) const
 Print a simple identifier for the Varnode. More...
 
void printRaw (ostream &s) const
 Print a simple identifier plus additional info identifying Varnode with SSA form. More...
 
void printCover (ostream &s) const
 Print raw coverage info about the Varnode. More...
 
void printInfo (ostream &s) const
 Print raw attribute info about the Varnode. More...
 
 Varnode (int4 s, const Address &m, Datatype *dt)
 Construct a free Varnode. More...
 
bool operator< (const Varnode &op2) const
 Comparison operator on Varnode. More...
 
bool operator== (const Varnode &op2) const
 Equality operator. More...
 
bool operator!= (const Varnode &op2) const
 Inequality operator.
 
 ~Varnode (void)
 Destructor. More...
 
bool intersects (const Varnode &op) const
 Return true if the storage locations intersect. More...
 
bool intersects (const Address &op2loc, int4 op2size) const
 Check intersection against an Address range. More...
 
int4 contains (const Varnode &op) const
 Return info about the containment of op in this. More...
 
int4 characterizeOverlap (const Varnode &op) const
 Return 0, 1, or 2 for "no overlap", "partial overlap", "identical storage".
 
int4 overlap (const Varnode &op) const
 Return relative point of overlap between two Varnodes. More...
 
int4 overlapJoin (const Varnode &op) const
 Return relative point of overlap, where the given Varnode may be in the join space. More...
 
int4 overlap (const Address &op2loc, int4 op2size) const
 Return relative point of overlap with Address range. More...
 
uintb getNZMask (void) const
 Get the mask of bits within this that are known to be zero.
 
int4 termOrder (const Varnode *op) const
 Compare two Varnodes based on their term order. More...
 
void printRawHeritage (ostream &s, int4 depth) const
 Print a simple SSA subtree rooted at this. More...
 
bool isAnnotation (void) const
 Is this an annotation?
 
bool isImplied (void) const
 Is this an implied variable?
 
bool isExplicit (void) const
 Is this an explicitly printed variable?
 
bool isConstant (void) const
 Is this a constant?
 
bool isFree (void) const
 Is this free, not in SSA form?
 
bool isInput (void) const
 Is this an SSA input node?
 
bool isIllegalInput (void) const
 Is this an abnormal input to the function?
 
bool isIndirectOnly (void) const
 Is this read only by INDIRECT operations?
 
bool isExternalRef (void) const
 Is this storage location mapped by the loader to an external location?
 
bool hasActionProperty (void) const
 Will this Varnode be replaced dynamically?
 
bool isReadOnly (void) const
 Is this a read-only storage location?
 
bool isVolatile (void) const
 Is this a volatile storage location?
 
bool isPersist (void) const
 Does this storage location persist beyond the end of the function?
 
bool isDirectWrite (void) const
 Is this value affected by a legitimate function input.
 
bool isAddrTied (void) const
 Are all Varnodes at this storage location components of the same high-level variable?
 
bool isAddrForce (void) const
 Is this value forced into a particular storage location?
 
bool isAutoLive (void) const
 Is this varnode exempt from dead-code removal?
 
bool isAutoLiveHold (void) const
 Is there a temporary hold on dead-code removal?
 
bool isMapped (void) const
 Is there or should be formal symbol information associated with this?
 
bool isUnaffected (void) const
 Is this a value that is supposed to be preserved across the function?
 
bool isSpacebase (void) const
 Is this location used to store the base point for a virtual address space?
 
bool isReturnAddress (void) const
 Is this storage for a calls return address?
 
bool isProtoPartial (void) const
 Is this getting pieced together into a larger whole.
 
bool isPtrCheck (void) const
 Has this been checked as a constant pointer to a mapped symbol?
 
bool isPtrFlow (void) const
 Does this varnode flow to or from a known pointer.
 
bool isSpacebasePlaceholder (void) const
 Is this used specifically to track stackpointer values?
 
bool hasNoLocalAlias (void) const
 Are there (not) any local pointers that might affect this?
 
bool isMark (void) const
 Has this been visited by the current algorithm?
 
bool isActiveHeritage (void) const
 Is this currently being traced by the Heritage algorithm?
 
bool isStackStore (void) const
 Was this originally produced by an explicit STORE.
 
bool isLockedInput (void) const
 Is always an input, even if unused.
 
bool stopsUpPropagation (void) const
 Is data-type propagation stopped.
 
bool hasImpliedField (void) const
 Does this have an implied field.
 
bool isIndirectZero (void) const
 Is this just a special placeholder representing INDIRECT creation?
 
bool isExtraOut (void) const
 Is this Varnode created indirectly by a CALL operation?
 
bool isPrecisLo (void) const
 Is this the low portion of a double precision value?
 
bool isPrecisHi (void) const
 Is this the high portion of a double precision value?
 
bool isIncidentalCopy (void) const
 Does this varnode get copied as a side-effect.
 
bool isWriteMask (void) const
 Is this (not) considered a true write location when calculating SSA form?
 
bool isUnsignedPrint (void) const
 Must this be printed as unsigned.
 
bool isLongPrint (void) const
 Must this be printed as a long token.
 
bool isWritten (void) const
 Does this have a defining write operation?
 
bool hasCover (void) const
 Does this have Cover information?
 
bool hasNoDescend (void) const
 Return true if nothing reads this Varnode.
 
bool constantMatch (uintb val) const
 Return true if this is a constant with value val.
 
int4 isConstantExtended (uintb &val) const
 
bool isHeritageKnown (void) const
 Return true if this Varnode is linked into the SSA tree.
 
bool isTypeLock (void) const
 Does this have a locked Datatype?
 
bool isNameLock (void) const
 Does this have a locked name?
 
void setActiveHeritage (void)
 Mark this as currently being linked into the SSA tree.
 
void clearActiveHeritage (void)
 Mark this as not (actively) being linked into the SSA tree.
 
void setMark (void) const
 Mark this Varnode for breadcrumb algorithms.
 
void clearMark (void) const
 Clear the mark on this Varnode.
 
void setDirectWrite (void)
 Mark this as directly affected by a legal input.
 
void clearDirectWrite (void)
 Mark this as not directly affected by a legal input.
 
void setAddrForce (void)
 Mark as forcing a value into this particular storage location.
 
void clearAddrForce (void)
 Clear the forcing attribute.
 
void setImplied (void)
 Mark this as an implied variable in the final C source.
 
void clearImplied (void)
 Clear the implied mark on this Varnode.
 
void setExplicit (void)
 Mark this as an explicit variable in the final C source.
 
void clearExplicit (void)
 Clear the explicit mark on this Varnode.
 
void setReturnAddress (void)
 Mark as storage location for a return address.
 
void clearReturnAddress (void)
 Clear return address attribute.
 
void setPtrCheck (void)
 Set this as checked for a constant symbol reference.
 
void clearPtrCheck (void)
 Clear the pointer check mark on this Varnode.
 
void setPtrFlow (void)
 Set this as flowing to or from pointer.
 
void clearPtrFlow (void)
 Indicate that this varnode is not flowing to or from pointer.
 
void setSpacebasePlaceholder (void)
 Mark this as a special Varnode for tracking stackpointer values.
 
void clearSpacebasePlaceholder (void)
 Clear the stackpointer tracking mark.
 
void setPrecisLo (void)
 Mark this as the low portion of a double precision value.
 
void clearPrecisLo (void)
 Clear the mark indicating a double precision portion.
 
void setPrecisHi (void)
 Mark this as the high portion of a double precision value.
 
void clearPrecisHi (void)
 Clear the mark indicating a double precision portion.
 
void setWriteMask (void)
 Mark this as not a true write when computing SSA form.
 
void clearWriteMask (void)
 Clear the mark indicating this is not a true write.
 
void setAutoLiveHold (void)
 Place temporary hold on dead code removal.
 
void clearAutoLiveHold (void)
 Clear temporary hold on dead code removal.
 
void setProtoPartial (void)
 Mark this gets pieced into larger structure.
 
void clearProtoPartial (void)
 Clear mark indicating this gets pieced into larger structure.
 
void setUnsignedPrint (void)
 Force this to be printed as unsigned.
 
void setLongPrint (void)
 Force this to be printed as a long token.
 
void setStopUpPropagation (void)
 Stop up-propagation thru this.
 
void clearStopUpPropagation (void)
 Stop up-propagation thru this.
 
void setImpliedField (void)
 Mark this as having an implied field.
 
bool updateType (Datatype *ct, bool lock, bool override)
 (Possibly) set the Datatype given various restrictions More...
 
void setStackStore (void)
 Mark as produced by explicit CPUI_STORE.
 
void setLockedInput (void)
 Mark as existing input, even if unused.
 
void copySymbol (const Varnode *vn)
 Copy symbol info from vn. More...
 
void copySymbolIfValid (const Varnode *vn)
 Copy symbol info from vn if constant value matches. More...
 
DatatypegetLocalType (bool &blockup) const
 Calculate type of Varnode based on local information. More...
 
bool isBooleanValue (bool useAnnotation) const
 Does this Varnode hold a formal boolean value. More...
 
bool copyShadow (const Varnode *op2) const
 Are this and op2 copied from the same source? More...
 
bool findSubpieceShadow (int4 leastByte, const Varnode *whole, int4 recurse) const
 Try to find a SUBPIECE operation producing the value in this from the given whole Varnode. More...
 
bool findPieceShadow (int4 leastByte, const Varnode *piece) const
 Try to find a PIECE operation that produces this from a given Varnode piece. More...
 
bool partialCopyShadow (const Varnode *op2, int4 relOff) const
 Is one of this or op2 a partial copy of the other? More...
 
DatatypegetStructuredType (void) const
 Get structure/array/union that this is a piece of. More...
 
void encode (Encoder &encoder) const
 Encode a description of this to a stream. More...
 

Static Public Member Functions

static bool comparePointers (const Varnode *a, const Varnode *b)
 Compare Varnodes as pointers.
 
static void printRaw (ostream &s, const Varnode *vn)
 Print raw info about a Varnode to stream. More...
 

Private Member Functions

void updateCover (void) const
 Internal function for update coverage information. More...
 
void calcCover (void) const
 Turn on the Cover object for this Varnode. More...
 
void clearCover (void) const
 Turn off any coverage information. More...
 
void setFlags (uint4 fl) const
 Internal method for setting boolean attributes. More...
 
void clearFlags (uint4 fl) const
 Internal method for clearing boolean attributes. More...
 
void clearSymbolLinks (void)
 Clear any Symbol attached to this Varnode. More...
 
void setUnaffected (void)
 Mark Varnode as unaffected.
 
void setInput (void)
 Mark Varnode as input.
 
void setDef (PcodeOp *op)
 Set the defining PcodeOp of this Varnode. More...
 
bool setSymbolProperties (SymbolEntry *entry)
 Set properties from the given Symbol to this Varnode. More...
 
void setSymbolEntry (SymbolEntry *entry)
 Attach a Symbol to this Varnode. More...
 
void setSymbolReference (SymbolEntry *entry, int4 off)
 Attach a Symbol reference to this. More...
 
void addDescend (PcodeOp *op)
 Add a descendant (reading) PcodeOp to this Varnode's list. More...
 
void eraseDescend (PcodeOp *op)
 Erase a descendant (reading) PcodeOp from this Varnode's list. More...
 
void destroyDescend (void)
 Clear all descendant (reading) PcodeOps. More...
 

Private Attributes

uint4 flags
 The collection of boolean attributes for this Varnode.
 
int4 size
 Size of the Varnode in bytes.
 
uint4 create_index
 A unique one-up index assigned to Varnode at its creation.
 
int2 mergegroup
 Which group of forced merges does this Varnode belong to.
 
uint2 addlflags
 Additional flags.
 
Address loc
 Storage location (or constant value) of the Varnode.
 
PcodeOpdef
 The defining operation of this Varnode.
 
HighVariablehigh
 High-level variable of which this is an instantiation.
 
SymbolEntrymapentry
 cached SymbolEntry associated with Varnode
 
Datatypetype
 Datatype associated with this varnode.
 
VarnodeLocSet::iterator lociter
 Iterator into VarnodeBank sorted by location.
 
VarnodeDefSet::iterator defiter
 Iterator into VarnodeBank sorted by definition.
 
list< PcodeOp * > descend
 List of every op using this varnode as input.
 
Covercover
 Addresses covered by the def->use of this Varnode.
 
union {
   Datatype *   dataType
 Temporary data-type associated with this for use in type propagate algorithm.
 
   ValueSet *   valueSet
 Value set associated with this when performing Value Set Analysis.
 
temp
 Temporary storage for analysis algorithms.
 
uintb consumed
 What parts of this varnode are used.
 
uintb nzm
 Which bits do we know are zero.
 

Friends

class VarnodeBank
 
class Merge
 
class Funcdata
 

Detailed Description

A low-level variable or contiguous set of bytes described by an Address and a size.

A Varnode is the fundemental variable in the p-code language model. A Varnode represents anything that holds data, including registers, stack locations, global RAM locations, and constants. It is described most simply as a storage location for some number of bytes, and is identified by

In its raw form, the Varnode is referred to as free, and this pair uniquely identifies the Varnode, as determined by its comparison operators. In terms of the Static Single Assignment (SSA) form for the decompiler analysis, the Varnode class also represents a node in the tree. In this case the Varnode is not free, and each individual write to a storage location, as per SSA form, creates a unique Varnode, which is represented by a separate instance, so there may be multiple Varnode instances with the same Address and size.

Member Enumeration Documentation

◆ addl_flags

Additional boolean properties on a Varnode.

Enumerator
activeheritage 

The varnode is actively being heritaged.

writemask 

Should not be considered a write in heritage calculation.

vacconsume 

Vacuous consume.

lisconsume 

In consume worklist.

ptrcheck 

The Varnode value is NOT a pointer.

ptrflow 

If this varnode flows to or from a pointer.

unsignedprint 

Constant that must be explicitly printed as an unsigned token.

longprint 

Constant that must be explicitly printed as a long integer token.

stack_store 

Created by an explicit STORE.

locked_input 

Input that exists even if its unused.

spacebase_placeholder 

value at a specific point in the code

This varnode is inserted artificially to track a register

stop_uppropagation 

Data-types do not propagate from an output into this.

has_implied_field 

The varnode is implied but also has a data-type that needs resolution.

◆ varnode_flags

There are a large number of boolean attributes that can be placed on a Varnode. Some are calculated and maintained by the friend classes Funcdata and VarnodeBank, and others can be set and cleared publicly by separate subsystems.

Enumerator
mark 

Prevents infinite loops.

constant 

The varnode is constant.

annotation 

This varnode is an annotation and has no dataflow.

input 

This varnode has no ancestor.

written 

This varnode has a defining op (def is nonzero)

insert 

This varnode has been inserted in a tree This means the varnode is the output of an op or The output is a constant or the output is an input

implied 

This varnode is a temporary variable.

explict 

This varnode CANNOT be a temporary variable.

typelock 

The Dataype of the Varnode is locked.

namelock 

The Name of the Varnode is locked.

nolocalalias 

There are no aliases pointing to this varnode.

volatil 

This varnode's value is volatile.

externref 

Varnode address is specially mapped by the loader.

readonly 

Varnode is stored at a readonly location.

persist 

Persists after (and before) function.

addrtied 

High-level variable is tied to address.

unaffected 

Input which is unaffected by the function.

spacebase 

This is a base register for an address space.

indirectonly 

If all uses of illegalinput varnode are inputs to INDIRECT.

directwrite 

(could be) Directly affected by a valid input

addrforce 

Varnode is used to force variable into an address.

mapped 

Varnode has a database entry associated with it.

indirect_creation 

The value in this Varnode is created indirectly.

return_address 

Is the varnode storage for a return address.

coverdirty 

Cover is not upto date.

precislo 

Is this Varnode the low part of a double precision value.

precishi 

Is this Varnode the high part of a double precision value.

indirectstorage 

Is this Varnode storing a pointer to the actual symbol.

hiddenretparm 

Does this varnode point to the return value storage location.

incidental_copy 

Do copies of this varnode happen as a side-effect.

autolive_hold 

Temporarily block dead-code removal of this.

proto_partial 

Varnode is getting PIECEd together into an (unmapped) structure.

Constructor & Destructor Documentation

◆ Varnode()

ghidra::Varnode::Varnode ( int4  s,
const Address m,
Datatype dt 
)

Construct a free Varnode.

This is the constructor for making an unmanaged Varnode It creates a free Varnode with possibly a Datatype attribute. Most applications create Varnodes through the Funcdata interface

Parameters
sis the size of the new Varnode
mis the starting storage Address
dtis the Datatype

References addlflags, annotation, constant, consumed, cover, coverdirty, def, flags, ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::AddrSpace::getType(), high, ghidra::IPTR_CONSTANT, ghidra::IPTR_FSPEC, ghidra::IPTR_IOP, mapentry, mergegroup, nzm, size, and type.

◆ ~Varnode()

ghidra::Varnode::~Varnode ( void  )

Destructor.

Delete the Varnode object. This routine assumes all other cross-references have been removed.

References cover, high, ghidra::HighVariable::isUnattached(), and ghidra::HighVariable::remove().

Member Function Documentation

◆ addDescend()

void ghidra::Varnode::addDescend ( PcodeOp op)
private

Add a descendant (reading) PcodeOp to this Varnode's list.

Put a new operator in the descendant list and set the cover dirty flag

Parameters
opis PcodeOp to add

References coverdirty.

Referenced by ghidra::Funcdata::opSetInput(), and ghidra::VarnodeBank::replace().

◆ calcCover()

void ghidra::Varnode::calcCover ( void  ) const
private

Turn on the Cover object for this Varnode.

Initialize a new Cover and set dirty bit so that updateCover will rebuild.

References coverdirty.

Referenced by ghidra::Funcdata::assignHigh(), and ghidra::Funcdata::setVarnodeProperties().

◆ clearCover()

void ghidra::Varnode::clearCover ( void  ) const
private

Turn off any coverage information.

Delete the Cover object. Used for dead Varnodes before full deletion.

Referenced by ghidra::Funcdata::clearDeadVarnodes(), and ghidra::Funcdata::opUnsetOutput().

◆ clearFlags()

void ghidra::Varnode::clearFlags ( uint4  fl) const
private

Internal method for clearing boolean attributes.

Clear desired boolean attributes on this Varnode and then set dirty bits if appropriate

Parameters
flis the mask containing the list of attributes to clear

References coverdirty.

Referenced by clearSymbolLinks(), ghidra::Funcdata::fillinReadOnly(), ghidra::VarnodeBank::makeFree(), and ghidra::Funcdata::syncVarnodesWithSymbol().

◆ clearSymbolLinks()

void ghidra::Varnode::clearSymbolLinks ( void  )
private

Clear any Symbol attached to this Varnode.

For this Varnode and any others attached to the same HighVariable, remove any SymbolEntry reference and associated properties.

References clearFlags(), mapentry, mapped, namelock, and typelock.

Referenced by ghidra::Funcdata::remapDynamicVarnode(), and ghidra::Funcdata::remapVarnode().

◆ contains()

int4 ghidra::Varnode::contains ( const Varnode op) const

Return info about the containment of op in this.

Return various values depending on the containment of another Varnode within this. Return

  • -1 if op.loc starts before -this-
  • 0 if op is contained in -this-
  • 1 if op.start is contained in -this-
  • 2 if op.loc comes after -this- or
  • 3 if op and -this- are in non-comparable spaces
    Parameters
    opis the Varnode to test for containment
    Returns
    the integer containment code

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::IPTR_CONSTANT, loc, and size.

Referenced by ghidra::RuleIndirectCollapse::applyOp(), and ghidra::ActionMarkExplicit::baseExplicit().

◆ copyShadow()

bool ghidra::Varnode::copyShadow ( const Varnode op2) const

Are this and op2 copied from the same source?

Make a local determination if this and op2 hold the same value. We check if there is a common ancester for which both this and op2 are created from a direct sequence of COPY operations. NOTE: This is a transitive relationship

Parameters
op2is the Varnode to compare to this
Returns
true if the Varnodes are copied from a common ancestor

References ghidra::PcodeOp::code(), ghidra::CPUI_COPY, getDef(), ghidra::PcodeOp::getIn(), and isWritten().

Referenced by ghidra::Merge::buildDominantCopy(), ghidra::Merge::eliminateIntersect(), ghidra::Merge::hideShadows(), ghidra::Merge::inflateTest(), ghidra::HighVariable::markExpression(), and ghidra::HighIntersectTest::testBlockIntersection().

◆ copySymbol()

void ghidra::Varnode::copySymbol ( const Varnode vn)

Copy symbol info from vn.

Copy any symbol and type information from -vn- into this

Parameters
vnis the Varnode to copy from

References flags, mapentry, namelock, type, and typelock.

Referenced by ghidra::RuleAndCompare::applyOp(), ghidra::RuleAddUnsigned::applyOp(), ghidra::Funcdata::opSetInput(), and ghidra::Funcdata::replaceLessequal().

◆ copySymbolIfValid()

void ghidra::Varnode::copySymbolIfValid ( const Varnode vn)

Copy symbol info from vn if constant value matches.

Symbol information (if present) is copied from the given constant Varnode into this, which also must be constant, but only if the two constants are close in the sense of an equate.

Parameters
vnis the given constant Varnode

References ghidra::SymbolEntry::getSymbol(), getSymbolEntry(), and ghidra::EquateSymbol::isValueClose().

Referenced by ghidra::RuleRangeMeld::applyOp(), ghidra::RuleZextEliminate::applyOp(), ghidra::RuleXorCollapse::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleEqual2Zero::applyOp(), ghidra::PcodeOp::collapseConstantSymbol(), and ghidra::SubvariableFlow::getReplaceVarnode().

◆ destroyDescend()

void ghidra::Varnode::destroyDescend ( void  )
private

Clear all descendant (reading) PcodeOps.

Completely clear the descendant list Only called if Varnode is about to be irrevocably destroyed

Referenced by ghidra::Funcdata::destroyVarnode().

◆ encode()

void ghidra::Varnode::encode ( Encoder encoder) const

Encode a description of this to a stream.

Encode this as an <addr> element, with at least the following attributes:

Additionally the element will contain other optional attributes.

Parameters
encoderis the stream encoder

References ghidra::Encoder::closeElement(), ghidra::AddrSpace::encodeAttributes(), getCreateIndex(), getMergeGroup(), ghidra::Address::getOffset(), ghidra::Address::getSpace(), isAddrTied(), isInput(), isPersist(), isUnaffected(), isVolatile(), loc, mergegroup, ghidra::Encoder::openElement(), size, ghidra::Encoder::writeBool(), ghidra::Encoder::writeSignedInteger(), and ghidra::Encoder::writeUnsignedInteger().

Referenced by ghidra::Funcdata::encodeVarnode().

◆ eraseDescend()

void ghidra::Varnode::eraseDescend ( PcodeOp op)
private

Erase a descendant (reading) PcodeOp from this Varnode's list.

Erase the operation from our descendant list and set the cover dirty flag

Parameters
opis the PcodeOp to remove

References coverdirty.

Referenced by ghidra::Funcdata::opUnsetInput().

◆ findPieceShadow()

bool ghidra::Varnode::findPieceShadow ( int4  leastByte,
const Varnode piece 
) const

Try to find a PIECE operation that produces this from a given Varnode piece.

Parameters
leastByteis the number of least significant bytes being truncated from the putative this to get piece. The routine can backtrack through COPY operations and more than one PIECE operations to verify that this is formed out of piece.
pieceis the given Varnode piece
Returns
true if this and whole have the prescribed PIECE relationship

References ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_PIECE, findPieceShadow(), getDef(), ghidra::PcodeOp::getIn(), getSize(), and isWritten().

Referenced by findPieceShadow(), and partialCopyShadow().

◆ findSubpieceShadow()

bool ghidra::Varnode::findSubpieceShadow ( int4  leastByte,
const Varnode whole,
int4  recurse 
) const

Try to find a SUBPIECE operation producing the value in this from the given whole Varnode.

The amount of truncation producing this must be known apriori. Allow for COPY and MULTIEQUAL operations in the flow path from whole to this. This method will search recursively through branches of MULTIEQUAL up to a maximum depth.

Parameters
leastByteis the number of least significant bytes being truncated from whole to get this
wholeis the given whole Varnode
recurseis the current depth of recursion
Returns
true if this and whole have the prescribed SUBPIECE relationship

References ghidra::calc_mask(), ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_SUBPIECE, findSubpieceShadow(), getDef(), ghidra::PcodeOp::getIn(), getOffset(), ghidra::PcodeOp::getParent(), getSize(), isConstant(), isWritten(), and ghidra::PcodeOp::numInput().

Referenced by findSubpieceShadow(), and partialCopyShadow().

◆ getHigh()

HighVariable * ghidra::Varnode::getHigh ( void  ) const

Get the high-level variable associated with this Varnode.

During the course of analysis Varnodes are merged into high-level variables that are intended to be closer to the concept of variables in C source code. For a large portion of the decompiler analysis this concept hasn't been built yet, and this routine will return null. But after a certain point, every Varnode managed by the Funcdata object, with the exception of ones that are marked as annotations, is associated with some HighVariable and will return a non-null result.

Returns
the associated HighVariable

Referenced by ghidra::ActionMarkImplied::apply(), ghidra::ActionNameVars::apply(), ghidra::ActionMarkExplicit::baseExplicit(), ghidra::Scope::buildDefaultName(), ghidra::Merge::buildDominantCopy(), ghidra::Funcdata::buildDynamicSymbol(), ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), ghidra::ActionMarkImplied::checkImpliedCover(), ghidra::Funcdata::coverVarnodes(), ghidra::PrintC::emitInplaceOp(), ghidra::Funcdata::encodeHigh(), ghidra::IfcPrintVarnode::execute(), ghidra::IfcVarnodehighCover::execute(), ghidra::IfcForceFormat::execute(), ghidra::Merge::findAllIntoCopies(), ghidra::Funcdata::findHigh(), ghidra::Merge::findSingleCopy(), ghidra::MapState::gatherHighs(), ghidra::Merge::groupPartialRoot(), ghidra::Funcdata::handleSymbolConflict(), ghidra::Merge::inflate(), ghidra::Merge::inflateTest(), ghidra::Funcdata::linkProtoPartial(), ghidra::Funcdata::linkSymbol(), ghidra::Funcdata::linkSymbolReference(), ghidra::ActionNameVars::linkSymbols(), ghidra::ActionNameVars::lookForBadJumpTables(), ghidra::ActionNameVars::lookForFuncParamNames(), ghidra::ActionNameVars::makeRec(), ghidra::Funcdata::mapGlobals(), ghidra::CastStrategy::markExplicitLongSize(), ghidra::HighVariable::markExpression(), ghidra::Merge::markInternalCopies(), ghidra::Merge::mergeAddrTied(), ghidra::Merge::mergeAdjacent(), ghidra::Merge::mergeIndirect(), ghidra::Merge::mergeOp(), ghidra::Merge::mergeOpcode(), ghidra::Merge::mergeRangeMust(), ghidra::Merge::mergeTest(), ghidra::Funcdata::moveRespectingCover(), ghidra::PrintC::opPtrsub(), ghidra::PrintC::opSubpiece(), ghidra::IfcPrintInputs::print(), ghidra::PrintC::push_integer(), ghidra::PrintC::pushCharConstant(), ghidra::PrintC::pushImpliedField(), ghidra::PrintC::pushPartialSymbol(), ghidra::PrintC::pushSymbol(), ghidra::PrintLanguage::pushSymbolDetail(), ghidra::ScopeLocal::recoverNameRecommendationsForSymbols(), ghidra::ActionSetCasts::resolveUnion(), ghidra::Merge::shadowedVarnode(), ghidra::Merge::snipIndirect(), ghidra::Funcdata::syncVarnodesWithSymbol(), ghidra::BlockWhileDo::testIterateForm(), ghidra::ActionSetCasts::tryResolutionAdjustment(), and ghidra::FuncProto::updateInputTypes().

◆ getHighTypeDefFacing()

Datatype * ghidra::Varnode::getHighTypeDefFacing ( void  ) const

Return the data-type of the HighVariable when this is written to.

This generally just returns the data-type of the HighVariable associated with this, unless it is a union data-type. In this case, the data-type of the resolved field of the union, associated with writing to the Varnode, is returned.

Returns
the resolved data-type

References def, ghidra::Datatype::findResolve(), ghidra::HighVariable::getType(), high, and ghidra::Datatype::needsResolution().

Referenced by ghidra::ActionSetCasts::castOutput(), ghidra::TypeOpCopy::getInputCast(), ghidra::TypeOpLoad::getInputCast(), ghidra::TypeOpLoad::getOutputToken(), ghidra::TypeOpPiece::getOutputToken(), ghidra::TypeOpSubpiece::getOutputToken(), ghidra::PrintC::opIntSext(), ghidra::PrintC::opIntZext(), ghidra::PrintC::opSubpiece(), and ghidra::PrintC::opTypeCast().

◆ getHighTypeReadFacing()

Datatype * ghidra::Varnode::getHighTypeReadFacing ( const PcodeOp op) const

Return data-type of the HighVariable when read by the given PcodeOp.

This generally just returns the data-type of the HighVariable associated with this, unless it is a union data-type. In this case, the data-type of the resolved field of the union, associated with reading the Varnode, is returned.

Parameters
opis the PcodeOp reading this Varnode
Returns
the resolved data-type

References ghidra::Datatype::findResolve(), ghidra::PcodeOp::getSlot(), ghidra::HighVariable::getType(), high, and ghidra::Datatype::needsResolution().

Referenced by ghidra::ActionSetCasts::apply(), ghidra::CastStrategyC::arithmeticOutputStandard(), ghidra::ActionSetCasts::checkPointerIssues(), ghidra::TypeOp::getInputCast(), ghidra::TypeOpCopy::getInputCast(), ghidra::TypeOpLoad::getInputCast(), ghidra::TypeOpStore::getInputCast(), ghidra::TypeOpEqual::getInputCast(), ghidra::TypeOpNotEqual::getInputCast(), ghidra::TypeOpIntSless::getInputCast(), ghidra::TypeOpIntSlessEqual::getInputCast(), ghidra::TypeOpIntLess::getInputCast(), ghidra::TypeOpIntLessEqual::getInputCast(), ghidra::TypeOpIntZext::getInputCast(), ghidra::TypeOpIntSext::getInputCast(), ghidra::TypeOpIntRight::getInputCast(), ghidra::TypeOpIntSright::getInputCast(), ghidra::TypeOpIntDiv::getInputCast(), ghidra::TypeOpIntSdiv::getInputCast(), ghidra::TypeOpIntRem::getInputCast(), ghidra::TypeOpIntSrem::getInputCast(), ghidra::TypeOpPtradd::getInputCast(), ghidra::TypeOpPtrsub::getInputCast(), ghidra::TypeOpCopy::getOutputToken(), ghidra::TypeOpLoad::getOutputToken(), ghidra::TypeOpIntLeft::getOutputToken(), ghidra::TypeOpIntRight::getOutputToken(), ghidra::TypeOpIntSright::getOutputToken(), ghidra::TypeOpSubpiece::getOutputToken(), ghidra::TypeOpPtradd::getOutputToken(), ghidra::TypeOpPtrsub::getOutputToken(), ghidra::TypeOpSegment::getOutputToken(), ghidra::BlockSwitch::getSwitchType(), ghidra::CastStrategyC::isExtensionCastImplied(), ghidra::CastStrategyC::localExtensionType(), ghidra::CastStrategy::markExplicitUnsigned(), ghidra::PrintC::opIntSext(), ghidra::PrintC::opIntZext(), ghidra::PrintC::opPtradd(), ghidra::PrintC::opPtrsub(), ghidra::PrintC::opSubpiece(), ghidra::PrintLanguage::pushVnExplicit(), and ghidra::ActionSetCasts::testStructOffset0().

◆ getLocalType()

Datatype * ghidra::Varnode::getLocalType ( bool &  blockup) const

Calculate type of Varnode based on local information.

Make an initial determination of the Datatype of this Varnode. If a Datatype is already set and locked return it. Otherwise look through all the read PcodeOps and the write PcodeOp to determine if the Varnode is getting used as an int, float, or pointer, etc. Throw an exception if no Datatype can be found at all.

Returns
the determined Datatype

References def, descend, ghidra::PcodeOp::getSlot(), ghidra::PcodeOp::inputTypeLocal(), isTypeLock(), ghidra::PcodeOp::outputTypeLocal(), ghidra::PcodeOp::stopsTypePropagation(), type, and ghidra::Datatype::typeOrder().

Referenced by ghidra::ActionInferTypes::buildLocaltypes().

◆ getSpaceFromConst()

AddrSpace * ghidra::Varnode::getSpaceFromConst ( void  ) const
inline

◆ getStructuredType()

Datatype * ghidra::Varnode::getStructuredType ( void  ) const

Get structure/array/union that this is a piece of.

If this has a data-type built out of separate pieces, return it. If this is mapped as a partial to a symbol with one of these data-types, return it. Return null otherwise.

Returns
the associated structured data-type or null

References ghidra::SymbolEntry::getSymbol(), ghidra::Symbol::getType(), ghidra::Datatype::isPieceStructured(), mapentry, and type.

Referenced by ghidra::RulePieceStructure::determineDatatype().

◆ getTypeDefFacing()

Datatype * ghidra::Varnode::getTypeDefFacing ( void  ) const

Return the data-type of this when it is written to.

This generally just returns the data-type of the Varnode itself unless it is a union data-type. In this case, the data-type of the resolved field of the union, associated with writing to the Varnode, is returned. The Varnode must be written to, to call this method.

Returns
the resolved data-type

References def, ghidra::Datatype::findResolve(), ghidra::Datatype::needsResolution(), and type.

Referenced by ghidra::RulePtrsubCharConstant::applyOp(), ghidra::RuleSplitCopy::applyOp(), ghidra::AddTreeState::buildDegenerate(), ghidra::ActionConstantPtr::isPointer(), ghidra::PrintC::opConstructor(), ghidra::PrintC::opNewOp(), ghidra::SplitDatatype::splitLoad(), and ghidra::Merge::trimOpOutput().

◆ getTypeReadFacing()

Datatype * ghidra::Varnode::getTypeReadFacing ( const PcodeOp op) const

◆ getUsePoint()

Address ghidra::Varnode::getUsePoint ( const Funcdata fd) const

Get Address when this Varnode first comes into scope.

A Varnode can be defined as "coming into scope" at the Address of the first PcodeOp that writes to that storage location. Within SSA form this first-use address always exists and is unique if we consider inputs to come into scope at the start Address of the function they are in

Parameters
fdis the Funcdata containing the tree
Returns
the first-use Address

References def, ghidra::PcodeOp::getAddr(), ghidra::Funcdata::getAddress(), and isWritten().

Referenced by ghidra::Scope::buildDefaultName(), ghidra::Funcdata::coverVarnodes(), ghidra::Funcdata::findLinkedVarnode(), ghidra::Funcdata::findLinkedVarnodes(), ghidra::Funcdata::linkSymbol(), ghidra::Funcdata::setVarnodeProperties(), and ghidra::Funcdata::syncVarnodesWithSymbols().

◆ intersects() [1/2]

bool ghidra::Varnode::intersects ( const Varnode op) const

Return true if the storage locations intersect.

Check whether the storage locations of two varnodes intersect

Parameters
opis the Varnode to compare with this
Returns
true if the locations intersect

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::IPTR_CONSTANT, loc, and size.

Referenced by ghidra::Funcdata::earlyJumpTableFail().

◆ intersects() [2/2]

bool ghidra::Varnode::intersects ( const Address op2loc,
int4  op2size 
) const

Check intersection against an Address range.

Check if this intersects the given Address range

Parameters
op2locis the start of the range
op2sizeis the size of the range in bytes
Returns
true if this intersects the range

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), and ghidra::IPTR_CONSTANT.

◆ isBooleanValue()

bool ghidra::Varnode::isBooleanValue ( bool  useAnnotation) const

Does this Varnode hold a formal boolean value.

If this varnode is produced by an operation with a boolean output, or if it is formally marked with a boolean data-type, return true. The parameter trustAnnotation toggles whether or not the formal data-type is trusted.

Returns
true if this is a formal boolean, false otherwise

References def, flags, ghidra::Datatype::getMetatype(), input, ghidra::PcodeOp::isCalculatedBool(), isWritten(), size, type, ghidra::TYPE_BOOL, and typelock.

Referenced by ghidra::RuleBooleanNegate::applyOp(), ghidra::RuleBoolZext::applyOp(), and ghidra::RuleLogic2Bool::applyOp().

◆ isConstantExtended()

int4 ghidra::Varnode::isConstantExtended ( uintb &  val) const

Is this an (extended) constant

If this is a constant, or is extended (INT_ZEXT,INT_SEXT) from a constant, the value of the constant is passed back and a non-negative integer is returned, either:

  • 0 for a normal constant Varnode
  • 1 for a zero extension (INT_ZEXT) of a normal constant
  • 2 for a sign extension (INT_SEXT) of a normal constant
    Parameters
    valis a reference to the constant value that is passed back
    Returns
    the extension code (or -1 if this cannot be interpreted as a constant)

References ghidra::PcodeOp::code(), ghidra::CPUI_INT_SEXT, ghidra::CPUI_INT_ZEXT, def, ghidra::PcodeOp::getIn(), getOffset(), isConstant(), and isWritten().

Referenced by ghidra::RuleDivTermAdd::applyOp(), and ghidra::RuleDivOpt::findForm().

◆ loneDescend()

PcodeOp * ghidra::Varnode::loneDescend ( void  ) const

Return unique reading PcodeOp, or null if there are zero or more than 1.

This is a convenience method for quickly finding the unique PcodeOp that reads this Varnode

Returns
only descendant (if there is 1 and ONLY 1) or null otherwise

References descend.

Referenced by ghidra::ActionConstantPtr::apply(), ghidra::RuleCollectTerms::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleHighOrderAnd::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleZextEliminate::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleXorCollapse::applyOp(), ghidra::RuleLoadVarnode::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleShiftAnd::applyOp(), ghidra::RuleSubZext::applyOp(), ghidra::RuleSLess2Zero::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::Rule2Comp2Sub::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RuleExtensionPush::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::RuleDivChain::applyOp(), ghidra::RuleSignMod2nOpt::applyOp(), ghidra::RuleSignMod2Opt::applyOp(), ghidra::RuleSubvarSubpiece::applyOp(), ghidra::Funcdata::attemptDynamicMappingLate(), ghidra::ActionMarkExplicit::baseExplicit(), ghidra::DynamicHash::buildVnDown(), ghidra::RuleSubCommute::cancelExtensions(), ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), ghidra::IfcDuplicateHash::check(), ghidra::RuleOrPredicate::checkSingle(), ghidra::TermOrder::collect(), ghidra::RulePushPtr::collectDuplicateNeeds(), ghidra::ValueSetSolver::establishValueSets(), ghidra::FuncCallSpecs::findPreexistingWhole(), ghidra::Heritage::floatExtensionRead(), ghidra::DynamicHash::gatherFirstLevelVars(), ghidra::SplitDatatype::generateConstants(), ghidra::TypeOpStore::getInputCast(), ghidra::CastStrategyC::intPromotionType(), ghidra::TraverseNode::isAlternatePathValid(), ghidra::PieceNode::isLeaf(), ghidra::Funcdata::linkSymbolReference(), ghidra::CastStrategy::markExplicitUnsigned(), ghidra::DynamicHash::moveOffSkip(), ghidra::opFlipInPlaceExecute(), ghidra::opFlipInPlaceTest(), ghidra::ActionConditionalConst::propagateConstant(), ghidra::Heritage::refineRead(), ghidra::Funcdata::replaceVolatile(), ghidra::ActionConstantPtr::searchForSpaceAttribute(), ghidra::Heritage::splitJoinRead(), ghidra::SplitDatatype::splitLoad(), ghidra::SplitDatatype::splitStore(), and ghidra::SplitDatatype::testCopyConstraints().

◆ operator<()

bool ghidra::Varnode::operator< ( const Varnode op2) const

Comparison operator on Varnode.

Compare two Varnodes

  • First by storage location
  • Second by size
  • Then by defining PcodeOp SeqNum if appropriate

Input Varnodes come before written Varnodes Free Varnodes come after everything else

Parameters
op2is the Varnode to compare this to
Returns
true if this is less than op2

References def, flags, ghidra::PcodeOp::getSeqNum(), input, loc, size, and written.

◆ operator==()

bool ghidra::Varnode::operator== ( const Varnode op2) const

Equality operator.

Determine if two Varnodes are equivalent. They must match

  • Storage location
  • Size
  • Defining PcodeOp if it exists
Parameters
op2is the Varnode to compare this to
Returns
true if they are equivalent

References def, flags, ghidra::PcodeOp::getSeqNum(), input, loc, size, and written.

◆ overlap() [1/2]

int4 ghidra::Varnode::overlap ( const Varnode op) const

Return relative point of overlap between two Varnodes.

Return whether Least Signifigant Byte of this occurs in op I.e. return

  • 0 if it overlaps op's lsb
  • 1 if it overlaps op's second lsb and so on
    Parameters
    opis the Varnode to test for overlap
    Returns
    the relative overlap point or -1

References loc, and size.

Referenced by ghidra::Funcdata::ancestorOpUse(), ghidra::RuleSubRight::applyOp(), ghidra::AncestorRealistic::enterNode(), ghidra::PcodeOp::isMoveable(), ghidra::Heritage::normalizeReadSize(), ghidra::Heritage::normalizeWriteSize(), ghidra::Heritage::removeRevisitedMarkers(), and ghidra::Funcdata::setInputVarnode().

◆ overlap() [2/2]

int4 ghidra::Varnode::overlap ( const Address op2loc,
int4  op2size 
) const

Return relative point of overlap with Address range.

Return whether Least Signifigant Byte of this occurs in an Address range I.e. return

  • 0 if it overlaps op's lsb
  • 1 if it overlaps op's second lsb and so on
    Parameters
    op2locis the starting Address of the range
    op2sizeis the size of the range in bytes
    Returns
    the relative overlap point or -1

◆ overlapJoin()

int4 ghidra::Varnode::overlapJoin ( const Varnode op) const

Return relative point of overlap, where the given Varnode may be in the join space.

Return whether Least Signifigant Byte of this occurs in op. If op is in the join space, this can be in one of the pieces associated with the join range, and the offset returned will take into account the relative position of the piece within the whole join. Otherwise, this method is equivalent to Varnode::overlap.

Parameters
opis the Varnode to test for overlap
Returns
the relative overlap point or -1

References loc, and size.

Referenced by ghidra::ActionMarkExplicit::baseExplicit().

◆ partialCopyShadow()

bool ghidra::Varnode::partialCopyShadow ( const Varnode op2,
int4  relOff 
) const

Is one of this or op2 a partial copy of the other?

For this and another Varnode, establish that either:

  • bigger = CONCAT(smaller,..) or
  • smaller = SUBPIECE(bigger)

Check through COPY chains and verify that the form of the CONCAT or SUBPIECE matches a given relative offset between the Varnodes.

Parameters
op2is the Varnode to compare to this
relOffis the putative relative byte offset of this to op2
Returns
true if one Varnode is contained, as a value, in the other

References findPieceShadow(), findSubpieceShadow(), getSize(), getSpace(), ghidra::AddrSpace::isBigEndian(), and size.

Referenced by ghidra::Merge::eliminateIntersect(), ghidra::Merge::inflateTest(), and ghidra::HighIntersectTest::testBlockIntersection().

◆ printCover()

void ghidra::Varnode::printCover ( ostream &  s) const

Print raw coverage info about the Varnode.

Print, to a stream, textual information about where this Varnode is in scope within its particular Funcdata. This amounts to a list of address ranges bounding the writes and reads of the Varnode

Parameters
sis the output stream

References coverdirty.

Referenced by ghidra::IfcVarnodeCover::execute().

◆ printInfo()

void ghidra::Varnode::printInfo ( ostream &  s) const

Print raw attribute info about the Varnode.

Print boolean attribute information about this as keywords to a stream

Parameters
sis the output stream

Referenced by ghidra::IfcPrintVarnode::execute(), ghidra::HighVariable::printInfo(), and ghidra::Funcdata::printVarnodeTree().

◆ printRaw() [1/2]

void ghidra::Varnode::printRaw ( ostream &  s) const

◆ printRaw() [2/2]

void ghidra::Varnode::printRaw ( ostream &  s,
const Varnode vn 
)
static

Print raw info about a Varnode to stream.

Invoke the printRaw method on the given Varnode pointer, but take into account that it might be null.

Parameters
sis the output stream to write to
vnis the given Varnode pointer (may be null)

References printRaw().

◆ printRawHeritage()

void ghidra::Varnode::printRawHeritage ( ostream &  s,
int4  depth 
) const

Print a simple SSA subtree rooted at this.

Recursively print a terse textual representation of the data-flow (SSA) tree rooted at this Varnode

Parameters
sis the output stream
depthis the current depth of the tree we are at

References annotation, constant, def, flags, ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getSeqNum(), input, isConstant(), ghidra::PcodeOp::numInput(), printRaw(), ghidra::PcodeOp::printRaw(), and printRawHeritage().

Referenced by printRawHeritage().

◆ printRawNoMarkup()

int4 ghidra::Varnode::printRawNoMarkup ( ostream &  s) const

Print a simple identifier for the Varnode.

Print to the stream either the name of the Varnode, such as a register name, if it exists or print a shortcut character representing the AddrSpace and a hex representation of the offset. This function also computes and returns the expected size of the identifier it prints to facilitate the printing of size modifiers by other print routines

Parameters
sis the output stream
Returns
the expected size

References ghidra::AddrSpaceManager::getDefaultSize(), ghidra::Address::getOffset(), ghidra::Translate::getRegister(), ghidra::Translate::getRegisterName(), ghidra::Address::getShortcut(), ghidra::Address::getSpace(), ghidra::AddrSpace::getTrans(), loc, ghidra::Address::printRaw(), and size.

Referenced by ghidra::Heritage::heritage(), and printRaw().

◆ setDef()

void ghidra::Varnode::setDef ( PcodeOp op)
private

Set the defining PcodeOp of this Varnode.

Directly change the defining PcodeOp and set appropriate dirty bits

Parameters
opis the pointer to the new PcodeOp, which can be null

References coverdirty, and written.

Referenced by ghidra::VarnodeBank::createDef(), ghidra::VarnodeBank::makeFree(), and ghidra::VarnodeBank::setDef().

◆ setFlags()

void ghidra::Varnode::setFlags ( uint4  fl) const
private

◆ setSymbolEntry()

void ghidra::Varnode::setSymbolEntry ( SymbolEntry entry)
private

◆ setSymbolProperties()

bool ghidra::Varnode::setSymbolProperties ( SymbolEntry entry)
private

Set properties from the given Symbol to this Varnode.

The given Symbol's data-type and flags are inherited by this Varnode. If the Symbol is type-locked, a reference to the Symbol is set on this Varnode.

Parameters
entryis a mapping to the given Symbol
Returns
true if any properties have changed

References ghidra::SymbolEntry::getAllFlags(), ghidra::SymbolEntry::getSymbol(), ghidra::Symbol::isTypeLocked(), and ghidra::SymbolEntry::updateType().

Referenced by ghidra::Funcdata::attemptDynamicMapping(), ghidra::Funcdata::newVarnode(), ghidra::Funcdata::newVarnodeOut(), and ghidra::Funcdata::setVarnodeProperties().

◆ setSymbolReference()

void ghidra::Varnode::setSymbolReference ( SymbolEntry entry,
int4  off 
)
private

Attach a Symbol reference to this.

Link Symbol information to this as a reference. This only works for a constant Varnode. This used when there is a constant address reference to the Symbol and the Varnode holds the reference, not the actual value of the Symbol.

Parameters
entryis a mapping to the given Symbol
offis the byte offset into the Symbol of the reference

References ghidra::SymbolEntry::getSymbol().

Referenced by ghidra::Funcdata::linkSymbolReference().

◆ termOrder()

int4 ghidra::Varnode::termOrder ( const Varnode op) const

Compare two Varnodes based on their term order.

Compare term order of two Varnodes. Used in Term Rewriting strategies to order operands of commutative ops

Parameters
opis the Varnode to order against this
Returns
-1 if this comes before op, 1 if op before this, or 0

References ghidra::PcodeOp::code(), ghidra::CPUI_INT_MULT, getAddr(), getDef(), ghidra::PcodeOp::getIn(), isConstant(), and isWritten().

Referenced by ghidra::TermOrder::additiveCompare().

◆ updateCover()

void ghidra::Varnode::updateCover ( void  ) const
private

Internal function for update coverage information.

Rebuild variable cover based on where the Varnode is defined and read. This is only called by the Merge class which knows when to call it properly

References coverdirty.

◆ updateType()

bool ghidra::Varnode::updateType ( Datatype ct,
bool  lock,
bool  override 
)

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