Predator
[unstable] git snapshot
|
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::Range & | rngFromCustom (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 |
some generic utilities working on top of a symbolic heap
Definition in file symutil.hh.
extract either offset range, or integral range from the given value
|
inline |
Definition at line 196 of file symutil.hh.
References areValProtosEqual(), UniformBlock::off, UniformBlock::size, and UniformBlock::tplValue.
|
inline |
Definition at line 167 of file symutil.hh.
References CL_BREAK_IF, SymHeapCore::valOffset(), SymHeapCore::valOrigin(), SymHeapCore::valTarget(), and VT_UNKNOWN.
Referenced by areUniBlocksEqual().
|
inline |
Definition at line 42 of file symutil.hh.
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 | ||
) |
Definition at line 231 of file symutil.hh.
References gatherProgramVarsCore().
Referenced by traverseProgramVarsGeneric().
Definition at line 244 of file symutil.hh.
References gatherProgramVarsCore().
void gatherProgramVarsCore | ( | TDst & | dst, |
const SymHeap & | sh, | ||
TInserter | ins | ||
) |
Definition at line 215 of file symutil.hh.
References SymHeapCore::cVarByObject(), SymHeapCore::gatherObjects(), isProgramVar(), and OBJ_RETURN.
Referenced by gatherProgramVars().
Definition at line 133 of file symutil.hh.
References SymHeap::objKind(), and OK_REGION.
|
inline |
Definition at line 139 of file symutil.hh.
References SymHeapCore::isValid(), SymHeapCore::objByAddr(), SymHeapCore::valTarget(), and VT_RANGE.
Definition at line 150 of file symutil.hh.
References OBJ_INVALID, and SymHeapCore::regionByVar().
Referenced by traverseProgramVarsGeneric().
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
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.
extract string literal from the given value if possible, fail otherwise
|
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 |
||
) |
take the given visitor through all live program variables in all heaps
Definition at line 384 of file symutil.hh.
References CL_BREAK_IF, SymHeapCore::cVarByObject(), SymHeapCore::gatherObjects(), gatherProgramVars(), insertOnce(), CVar::inst, isProgramVar(), IR::isSingular(), isVarAlive(), Range::lo, OBJ_RETURN, SymHeapCore::objSize(), SymHeapCore::regionByVar(), SymHeapCore::valCreate(), VO_UNKNOWN, VT_UNKNOWN, and SymHeapCore::writeUniformBlock().
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 | ||
) |
TSizeRange valSizeOfTarget | ( | const SymHeapCore & | , |
TValId | at | ||
) |
return size (in bytes) that we can safely write at the given addr