Skip to content

SVF APIs

guanqin-123 edited this page Apr 8, 2022 · 6 revisions
Members Meanings
SVF::SVFUtil::outs output stream similar to std::outs
SVF::SVFUtil::isa instance of a class
SVF::SVFUtil::cast casting from a parent class to a child class
SVF::SVFUtil::dyn_cast dynamic casting from a parent class to a child class, return null if not successful
Members Meanings
ICFGNode::toString return the content of this ICFGNode in the form of a string consisting of the nodeID, llvm instructions ...
SVF::ICFGNode::getSVFStmts return a list of program statements residing in this ICFGNode
SVF::CallICFGNode::getCallSite return the LLVM callsite
SVF::RetICFGNode::getCallSite return the LLVM callsite
SVF::CallICFGNode::getRetICFGNode Given a CallICFGNode, return its corresponding RetICFGNode
SVF::RetICFGNode::getActualRet Get the return variable (SVFVar) of this RetICFGNode
SVF::CallICFGNode::getActualParms Get all the actual parameters of this CallICFGNode
SVF::RetICFGNode:: getCallICFGNode Given a RetICFGNode, return its corresponding CallICFGNode
Members Meanings
SVF::ICFGEdge::isIntraCFGEdge return true if it is an intra-procedural edge
SVF::ICFGEdge::isCallCFGEdge return true if it is a call edge
SVF::ICFGEdge::isRetCFGEdge return true if it is a return edge
SVF::ICFGEdge::getSrcNode return the edge's source node
SVF::ICFGEdge::getSrcNode return the edge's destination node
SVF::CallCFGEdge::getCallSite return its corresponding llvm call instruction
SVF::CallCFGEdge:: getCallPEs get parameter edges from this CallCFGEdge (return a vector)
SVF::RetCFGEdge::getCallSite return its corresponding llvm call instruction
SVF::RetCFGEdge::getRetPE get parameter edge to this CallCFGEdge (return a RetPE)
SVF::IntraCFGEdge:: getCondition Given an IntraCFGEdge, return its conditionVar
SVF::IntraCFGEdge:: getSuccessorCondValue Given an IntraCFGEdge (must be a Branch edge, return its conditional number)
Members Meanings
SVF::SVFVar:: getValue return SVFVar's value
SVF::SVFVar:: hasValue check whether SVFVar has a value
SVF::SVFVar::isPointer check whether it is a pointer
SVF::SVFVar::isConstantData check whether it is a constant data, i.e., "0", "1.001", "str"
SVF::SVFVar::getValueName return name of the LLVM value, i.e., "%a", "@main"
Members Meanings
SVF::AssignStmt:: getRHSVar return Right Hand Side (RHS) SVFVar
SVF::AssignStmt:: getRHSVarID return Right Hand Side (RHS) SVFVar's ID
SVF::AssignStmt:: getLHSVar return Left Hand Side (LHS) SVFVar
SVF::AssignStmt:: getLHSVarID return Left Hand Side (LHS) SVFVar's ID
SVF::MultiOpndStmt:: getRes return operand result SVFVar
SVF::MultiOpndStmt:: getResID return operand result SVFVar's ID number
SVF::MultiOpndStmt:: getOpndVars return a vector of operands (vector<SVFVar*>)
SVF::MultiOpndStmt:: getOpVar(u32_t pos) return an operands at position $pos
SVF::MultiOpndStmt:: getOpVarID(u32_t pos) return an operands's ID at position $pos
Members Meanings
SVF:: Z3Mgr::resetZ3ExprMap reset added expressions and clean all declared values
SVF:: Z3Mgr::storeValue(const z3::expr loc, const z3::expr value) store expr(value) to expr(loc), which is used for store instructions
SVF:: Z3Mgr::loadValue(const z3::expr loc) retrieve the expression from expr(loc)
SVF:: Z3Mgr::getZ3Expr(u32_t idx) return Z3 expression based on SVFVar ID
SVF:: Z3Mgr::updateZ3Expr(u32_t idx, z3::expr target) update expression when assignments
SVF:: Z3Mgr::getEvalExpr(z3::expr e) return int value from an expression if it is a numeral, otherwise return an approximate value
SVF:: Z3Mgr::getSolver return the Z3's solver
SVF:: Z3Mgr::getCtx return the Z3's context
SVF:: Z3SSEMgr:: createExprForValVar(const ValVar* val) declare the expr type for each top-level pointers
SVF:: Z3SSEMgr:: createExprForObjVar(const ObjVar* obj) initialize the expr value for each objects (address-taken variables and constants)
SVF:: Z3SSEMgr::getMemObjAddress(u32_t idx) return the address expr of a ObjVar
SVF:: Z3SSEMgr::getGepObjAddress(z3::expr pointer, u32_t offset) return the field address given a pointer points to a struct object and an offset
SVF:: Z3SSEMgr::getGepOffset(const GepStmt* gep) return the offset expression of a GepStmt
SVF:: Z3SSEMgr:: printExprValues dump values of all added expressions in the solver

SVF::SVFUtil::outs()

  • Output the content of a node on ICFG

    For example,

     ICFGNode *inode = ...;  // subclass object CallICFGNode : %call = call i32 (...) @source(),
     SVFUtil::outs() << inode->toString() << "\n"
    

    The output is IntraICFGNode 21 : %call = call i32 (...) @source()


ICFGNode::toString()

  • return the content of this ICFGNode in the form of a string consisting of the nodeID, llvm instructions and its containing function

    Output Sample: NodeID: 15\nIntraICFGNode ID: 15 store i32 1, i32* %a, align 4 \{fun: main\}}


SVFUtil::cast<>()

  • Casting a pointer or reference to an instance of a specified class. This casting fails and abort the program if the object or reference is not the specified class at runtime.

    For example,

    SVFUtil::cast<CallICFGNode>(inode)->getParent()
    

SVFUtil::dyn_cast<>()

  • The dyn_cast<> operator is a "checking cast" operation. It checks to see if the operand is of the specified type, and if so, returns a pointer to it (this operator does not work with references). If the operand is not of the correct type, a null pointer is returned. Thus, this works very much like the dynamic_cast<> operator in C++, and should be used in the same circumstances.

    For example,

    if (CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(inode)) {
    // ...
    }
    

    This form of dyn_cast<> is an effective combination of isa<> and cast<> as below:

    if (SVFUtil::isa<CallICFGNode>(inode)) { 
         CallICFGNode* callNode =  SVFUtil::cast<CallICFGNode>(inode);
    }
    

Clone this wiki locally