Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
SVF::FunptrDDAClient Class Reference

#include <DDAClient.h>

Inheritance diagram for SVF::FunptrDDAClient:
SVF::DDAClient

Public Member Functions

 FunptrDDAClient (SVFModule *module)
 
 ~FunptrDDAClient ()
 
virtual OrderedNodeSetcollectCandidateQueries (SVFIR *p)
 Only collect function pointers as query candidates.
 
virtual void performStat (PointerAnalysis *pta)
 
- Public Member Functions inherited from SVF::DDAClient
 DDAClient (SVFModule *mod)
 
virtual ~DDAClient ()
 
virtual void initialise (SVFModule *)
 
const OrderedNodeSetgetCandidateQueries () const
 Get candidate queries.
 
virtual void handleStatement (const SVFGNode *, NodeID)
 Call back used by DDAVFSolver.
 
void setPAG (SVFIR *g)
 Set SVFIR graph.
 
void setCurrentQueryPtr (NodeID ptr)
 Set the pointer being queried.
 
void setQuery (NodeID ptr)
 Set pointer to be queried by DDA analysis.
 
SVFModulegetModule () const
 Get LLVM module.
 
virtual void answerQueries (PointerAnalysis *pta)
 
virtual void collectWPANum (SVFModule *)
 

Private Types

typedef OrderedMap< NodeID, const CallICFGNode * > VTablePtrToCallSiteMap
 

Private Attributes

VTablePtrToCallSiteMap vtableToCallSiteMap
 

Additional Inherited Members

- Protected Member Functions inherited from SVF::DDAClient
void addCandidate (NodeID id)
 
- Protected Attributes inherited from SVF::DDAClient
SVFIRpag
 SVFIR graph used by current DDA analysis.
 
SVFModule *NodeID curPtr
 < LLVM module
 
OrderedNodeSet candidateQueries
 store all candidate pointers to be queried
 

Detailed Description

DDA client with function pointers as query candidates.

Definition at line 125 of file DDAClient.h.

Member Typedef Documentation

◆ VTablePtrToCallSiteMap

Definition at line 128 of file DDAClient.h.

Constructor & Destructor Documentation

◆ FunptrDDAClient()

SVF::FunptrDDAClient::FunptrDDAClient ( SVFModule module)
inline

Definition at line 131 of file DDAClient.h.

131: DDAClient(module) {}
DDAClient(SVFModule *mod)
Definition DDAClient.h:51
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~FunptrDDAClient()

SVF::FunptrDDAClient::~FunptrDDAClient ( )
inline

Definition at line 132 of file DDAClient.h.

132{}

Member Function Documentation

◆ collectCandidateQueries()

OrderedNodeSet & FunptrDDAClient::collectCandidateQueries ( SVFIR p)
virtual

Only collect function pointers as query candidates.

Reimplemented from SVF::DDAClient.

Definition at line 78 of file DDAClient.cpp.

79{
80 setPAG(p);
81 for(SVFIR::CallSiteToFunPtrMap::const_iterator it = pag->getIndirectCallsites().begin(),
82 eit = pag->getIndirectCallsites().end(); it!=eit; ++it)
83 {
84 if (it->first->isVirtualCall())
85 {
86 const SVFVar* vtblPtr = it->first->getVtablePtr();
87 assert(vtblPtr != nullptr && "not a vtable pointer?");
88 NodeID vtblId = vtblPtr->getId();
91 }
92 else
93 {
94 addCandidate(it->second);
95 }
96 }
97 return candidateQueries;
98}
cJSON * p
Definition cJSON.cpp:2559
void setPAG(SVFIR *g)
Set SVFIR graph.
Definition DDAClient.h:79
SVFIR * pag
SVFIR graph used by current DDA analysis.
Definition DDAClient.h:111
void addCandidate(NodeID id)
Definition DDAClient.h:105
OrderedNodeSet candidateQueries
store all candidate pointers to be queried
Definition DDAClient.h:114
VTablePtrToCallSiteMap vtableToCallSiteMap
Definition DDAClient.h:129
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:351
u32_t NodeID
Definition GeneralType.h:55

◆ performStat()

void FunptrDDAClient::performStat ( PointerAnalysis pta)
virtual

Reimplemented from SVF::DDAClient.

Definition at line 100 of file DDAClient.cpp.

101{
102
110
111 for (VTablePtrToCallSiteMap::iterator nIter = vtableToCallSiteMap.begin();
112 nIter != vtableToCallSiteMap.end(); ++nIter)
113 {
114 NodeID vtptr = nIter->first;
115 const PointsTo& ddaPts = pta->getPts(vtptr);
116 const PointsTo& anderPts = ander->getPts(vtptr);
117
118 PTACallGraph* callgraph = ander->getCallGraph();
119 const CallICFGNode* cbn = nIter->second;
120
121 if(!callgraph->hasIndCSCallees(cbn))
122 {
123 //outs() << "virtual callsite has no callee" << *(nIter->second.getInstruction()) << "\n";
124 continue;
125 }
126
129 if(callees.size() == 0)
131 else if(callees.size() == 1)
133 else if(callees.size() == 2)
135 else
137
138 if(ddaPts.count() >= anderPts.count() || ddaPts.empty())
139 continue;
140
145
147 outs() << "============more precise callsite =================\n";
148 outs() << (nIter->second)->toString() << "\n";
149 outs() << (nIter->second)->getSourceLoc() << "\n";
150 outs() << "\n";
151 outs() << "------ander pts or vtable num---(" << anderPts.count() << ")--\n";
152 outs() << "------DDA vfn num---(" << ander_vfns.size() << ")--\n";
153 //ander->dumpPts(vtptr, anderPts);
154 outs() << "------DDA pts or vtable num---(" << ddaPts.count() << ")--\n";
155 outs() << "------DDA vfn num---(" << dda_vfns.size() << ")--\n";
156 //pta->dumpPts(vtptr, ddaPts);
157 outs() << "-------------------------\n";
158 outs() << "\n";
159 outs() << "=================================================\n";
160 }
161
162 outs() << "=================================================\n";
163 outs() << "Total virtual callsites: " << vtableToCallSiteMap.size() << "\n";
164 outs() << "Total analyzed virtual callsites: " << totalCallsites << "\n";
165 outs() << "Indirect call map size: " << ander->getCallGraph()->getIndCallMap().size() << "\n";
166 outs() << "Precise callsites: " << morePreciseCallsites << "\n";
167 outs() << "Zero target callsites: " << zeroTargetCallsites << "\n";
168 outs() << "One target callsites: " << oneTargetCallsites << "\n";
169 outs() << "Two target callsites: " << twoTargetCallsites << "\n";
170 outs() << "More than two target callsites: " << moreThanTwoCallsites << "\n";
171 outs() << "=================================================\n";
172}
unsigned u32_t
Definition CommandLine.h:18
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:408
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition Andersen.h:239
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Set< const SVFFunction * > FunctionSet
bool hasIndCSCallees(const CallICFGNode *cs) const
void getVFnsFromPts(const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
virtual const PointsTo & getPts(NodeID ptr)=0
Get points-to targets of a pointer. It needs to be implemented in child class.
SVFIR * getPAG() const
PTACallGraph * getCallGraph() const
Return call graph.
const std::string getSourceLoc(const Value *val)
Definition LLVMUtil.cpp:429
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50

Member Data Documentation

◆ vtableToCallSiteMap

VTablePtrToCallSiteMap SVF::FunptrDDAClient::vtableToCallSiteMap
private

Definition at line 129 of file DDAClient.h.


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