Predator  [unstable] git snapshot
Functions
symutil.hh File Reference

some generic utilities working on top of a symbolic heap More...

#include "config.h"
#include <cl/code_listener.h>
#include <cl/clutil.hh>
#include "symheap.hh"
#include "util.hh"
#include <set>
#include <boost/foreach.hpp>
#include <boost/static_assert.hpp>

Go to the source code of this file.

Functions

TValId boolToVal (const bool b)
bool numFromVal (IR::TInt *pDst, const SymHeapCore &, TValId)
 extract integral constant from the given value if possible, fail otherwise
bool rngFromVal (IR::Range *pDst, const SymHeapCore &, TValId)
 extract integral range from the given value if possible, fail otherwise
bool anyRangeFromVal (IR::Range *pDst, const SymHeap &, TValId)
 extract either offset range, or integral range from the given value
bool stringFromVal (std::string *pDst, const SymHeap &, TValId)
 extract string literal from the given value if possible, fail otherwise
void moveKnownValueToLeft (const SymHeap &sh, TValId &valA, TValId &valB)
bool valInsideSafeRange (const SymHeapCore &sh, TValId val)
bool canWriteDataPtrAt (const SymHeapCore &sh, TValId val)
bool proveNeq (const SymHeap &sh, TValId v1, TValId v2)
 true if the given values are proven to be non-equal in non-abstract world
const IR::RangerngFromCustom (const CustomValue &)
 extract an integral range from an unwrapped CV_INT/CV_INT_RANGE custom value
TSizeRange valSizeOfTarget (const SymHeapCore &, TValId at)
 return size (in bytes) that we can safely write at the given addr
bool canPointToFront (const ETargetSpecifier)
 true for TS_REGION and TS_FIRST
bool canPointToBack (const ETargetSpecifier)
 true for TS_REGION and TS_LAST
bool compareIntRanges (bool *pDst, enum cl_binop_e code, const IR::Range &range1, const IR::Range &range2)
template<class TMap >
TMap::mapped_type roMapLookup (const TMap &roMap, const typename TMap::key_type id)
 known to work only with TFldId/TValId
bool translateValId (TValId *pVal, SymHeapCore &dst, const SymHeapCore &src, const TValMap &valMap)
TValId translateValProto (SymHeapCore &dst, const SymHeapCore &src, TValId valProto)
FldHandle translateFldHandle (SymHeap &dst, const TObjId dstObj, const FldHandle &srcField)
TValId valOfPtr (SymHeap &sh, TObjId obj, TOffset off)
bool isAbstractObject (const SymHeap &sh, const TObjId obj)
bool isPossibleToDeref (const SymHeapCore &sh, const TValId val)
bool isVarAlive (SymHeap &sh, const CVar &cv)
void initGlVar (SymHeap &sh, const CVar &cv)
TObjId nextObj (SymHeap &sh, TObjId obj, TOffset offNext)
bool areValProtosEqual (const SymHeapCore &sh1, const SymHeapCore &sh2, const TValId v1, const TValId v2)
bool areUniBlocksEqual (const SymHeap &sh1, const SymHeap &sh2, const UniformBlock &bl1, const UniformBlock &bl2)
template<class TDst , typename TInserter >
void gatherProgramVarsCore (TDst &dst, const SymHeap &sh, TInserter ins)
void gatherProgramVars (TCVarList &dst, const SymHeap &sh)
void gatherProgramVars (TCVarSet &dst, const SymHeap &sh)
template<class THeap , class TVisitor >
bool traverseLiveFields (THeap &sh, const TObjId obj, TVisitor &visitor)
 take the given visitor through all live objects
template<class THeap , class TVisitor >
bool traverseUniformBlocks (THeap &sh, const TObjId obj, TVisitor &visitor)
 take the given visitor through all uniform blocks
template<unsigned N, class THeap , class TVisitor >
bool traverseLiveFieldsGeneric (THeap *const heaps[N], const TObjId objs[N], TVisitor &visitor)
 take the given visitor through all live objects object-wise
template<unsigned N, class THeap , class TVisitor >
bool traverseLiveFields (THeap &sh, const TObjId objs[N], TVisitor &visitor)
 take the given visitor through all live objects object-wise
bool redirectRefs (SymHeap &sh, TObjId pointingFrom, TObjId pointingTo, ETargetSpecifier pointingWith, TObjId redirectTo, ETargetSpecifier redirectWith, TOffset offHead=0)
 (OBJ_INVALID != pointingFrom) means 'pointing from anywhere'
void redirectRefsNotFrom (SymHeap &sh, const TObjSet &pointingNotFrom, TObjId pointingTo, TObjId redirectTo, ETargetSpecifier redirectWith, bool(*tsFilter)(ETargetSpecifier)=0)
void transferOutgoingEdges (SymHeap &sh, TObjId ofObj, TObjId toObj)
template<unsigned N_DST, unsigned N_SRC, class THeap , class TVisitor >
bool traverseProgramVarsGeneric (THeap *const heaps[N_DST+N_SRC], TVisitor &visitor, const bool allowRecovery=false)
 take the given visitor through all live program variables in all heaps

Detailed Description

some generic utilities working on top of a symbolic heap

Todo:
API documentation

Definition in file symutil.hh.

Function Documentation

bool anyRangeFromVal ( IR::Range pDst,
const SymHeap ,
TValId   
)

extract either offset range, or integral range from the given value

bool areUniBlocksEqual ( const SymHeap sh1,
const SymHeap sh2,
const UniformBlock bl1,
const UniformBlock bl2 
)
inline
bool areValProtosEqual ( const SymHeapCore sh1,
const SymHeapCore sh2,
const TValId  v1,
const TValId  v2 
)
inline
TValId boolToVal ( const bool  b)
inline

Definition at line 42 of file symutil.hh.

References VAL_FALSE, and VAL_TRUE.

bool canPointToBack ( const ETargetSpecifier  )

true for TS_REGION and TS_LAST

bool canPointToFront ( const ETargetSpecifier  )

true for TS_REGION and TS_FIRST

bool canWriteDataPtrAt ( const SymHeapCore sh,
TValId  val 
)
bool compareIntRanges ( bool *  pDst,
enum cl_binop_e  code,
const IR::Range range1,
const IR::Range range2 
)
void gatherProgramVars ( TCVarList dst,
const SymHeap sh 
)
inline

Definition at line 231 of file symutil.hh.

References gatherProgramVarsCore().

Referenced by traverseProgramVarsGeneric().

void gatherProgramVars ( TCVarSet dst,
const SymHeap sh 
)
inline

Definition at line 244 of file symutil.hh.

References gatherProgramVarsCore().

void gatherProgramVarsCore ( TDst &  dst,
const SymHeap sh,
TInserter  ins 
)
void initGlVar ( SymHeap sh,
const CVar cv 
)
bool isAbstractObject ( const SymHeap sh,
const TObjId  obj 
)
inline

Definition at line 133 of file symutil.hh.

References SymHeap::objKind(), and OK_REGION.

bool isPossibleToDeref ( const SymHeapCore sh,
const TValId  val 
)
inline
bool isVarAlive ( SymHeap sh,
const CVar cv 
)
inline

Definition at line 150 of file symutil.hh.

References OBJ_INVALID, and SymHeapCore::regionByVar().

Referenced by traverseProgramVarsGeneric().

void moveKnownValueToLeft ( const SymHeap sh,
TValId valA,
TValId valB 
)
TObjId nextObj ( SymHeap sh,
TObjId  obj,
TOffset  offNext 
)
inline

Definition at line 158 of file symutil.hh.

References SymHeapCore::isValid(), OBJ_INVALID, SymHeapCore::objByAddr(), and valOfPtr().

bool numFromVal ( IR::TInt pDst,
const SymHeapCore ,
TValId   
)

extract integral constant from the given value if possible, fail otherwise

bool proveNeq ( const SymHeap sh,
TValId  v1,
TValId  v2 
)

true if the given values are proven to be non-equal in non-abstract world

bool redirectRefs ( SymHeap sh,
TObjId  pointingFrom,
TObjId  pointingTo,
ETargetSpecifier  pointingWith,
TObjId  redirectTo,
ETargetSpecifier  redirectWith,
TOffset  offHead = 0 
)

(OBJ_INVALID != pointingFrom) means 'pointing from anywhere'

void redirectRefsNotFrom ( SymHeap sh,
const TObjSet pointingNotFrom,
TObjId  pointingTo,
TObjId  redirectTo,
ETargetSpecifier  redirectWith,
bool(*)(ETargetSpecifier tsFilter = 0 
)
const IR::Range& rngFromCustom ( const CustomValue )

extract an integral range from an unwrapped CV_INT/CV_INT_RANGE custom value

bool rngFromVal ( IR::Range pDst,
const SymHeapCore ,
TValId   
)

extract integral range from the given value if possible, fail otherwise

TMap::mapped_type roMapLookup ( const TMap &  roMap,
const typename TMap::key_type  id 
)

known to work only with TFldId/TValId

Definition at line 90 of file symutil.hh.

bool stringFromVal ( std::string *  pDst,
const SymHeap ,
TValId   
)

extract string literal from the given value if possible, fail otherwise

void transferOutgoingEdges ( SymHeap sh,
TObjId  ofObj,
TObjId  toObj 
)
FldHandle translateFldHandle ( SymHeap dst,
const TObjId  dstObj,
const FldHandle srcField 
)
inline

Definition at line 114 of file symutil.hh.

References FldHandle::offset(), and FldHandle::type().

bool translateValId ( TValId pVal,
SymHeapCore dst,
const SymHeapCore src,
const TValMap valMap 
)
TValId translateValProto ( SymHeapCore dst,
const SymHeapCore src,
TValId  valProto 
)
bool traverseLiveFields ( THeap &  sh,
const TObjId  obj,
TVisitor &  visitor 
)

take the given visitor through all live objects

Definition at line 255 of file symutil.hh.

References CL_BREAK_IF, and OBJ_INVALID.

bool traverseLiveFields ( THeap &  sh,
const TObjId  objs[N],
TVisitor &  visitor 
)

take the given visitor through all live objects object-wise

Definition at line 347 of file symutil.hh.

bool traverseLiveFieldsGeneric ( THeap *const  heaps[N],
const TObjId  objs[N],
TVisitor &  visitor 
)

take the given visitor through all live objects object-wise

Definition at line 300 of file symutil.hh.

References SymHeapCore::gatherLiveFields(), OBJ_INVALID, FldHandle::offset(), and FldHandle::type().

bool traverseProgramVarsGeneric ( THeap *const  heaps[N_DST+N_SRC],
TVisitor &  visitor,
const bool  allowRecovery = false 
)
bool traverseUniformBlocks ( THeap &  sh,
const TObjId  obj,
TVisitor &  visitor 
)

take the given visitor through all uniform blocks

Definition at line 278 of file symutil.hh.

References CL_BREAK_IF, and OBJ_INVALID.

bool valInsideSafeRange ( const SymHeapCore sh,
TValId  val 
)
TValId valOfPtr ( SymHeap sh,
TObjId  obj,
TOffset  off 
)
inline

Definition at line 127 of file symutil.hh.

References FldHandle::value().

Referenced by nextObj().

TSizeRange valSizeOfTarget ( const SymHeapCore ,
TValId  at 
)

return size (in bytes) that we can safely write at the given addr