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 ()
 
 ~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 ()
 
virtual ~DDAClient ()
 
virtual void initialise ()
 
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.
 
virtual void answerQueries (PointerAnalysis *pta)
 
virtual void collectWPANum ()
 

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.
 
NodeID curPtr
 current pointer being queried
 
OrderedNodeSet candidateQueries
 store all candidate pointers to be queried
 

Detailed Description

DDA client with function pointers as query candidates.

Definition at line 120 of file DDAClient.h.

Member Typedef Documentation

◆ VTablePtrToCallSiteMap

Definition at line 123 of file DDAClient.h.

Constructor & Destructor Documentation

◆ FunptrDDAClient()

SVF::FunptrDDAClient::FunptrDDAClient ( )
inline

Definition at line 126 of file DDAClient.h.

126: DDAClient() {}

◆ ~FunptrDDAClient()

SVF::FunptrDDAClient::~FunptrDDAClient ( )
inline

Definition at line 127 of file DDAClient.h.

127{}

Member Function Documentation

◆ collectCandidateQueries()

OrderedNodeSet & FunptrDDAClient::collectCandidateQueries ( SVFIR p)
virtual

Only collect function pointers as query candidates.

Reimplemented from SVF::DDAClient.

Definition at line 80 of file DDAClient.cpp.

81{
82 setPAG(p);
83 for(SVFIR::CallSiteToFunPtrMap::const_iterator it = pag->getIndirectCallsites().begin(),
84 eit = pag->getIndirectCallsites().end(); it!=eit; ++it)
85 {
86 if (it->first->isVirtualCall())
87 {
88 const SVFVar* vtblPtr = it->first->getVtablePtr();
89 assert(vtblPtr != nullptr && "not a vtable pointer?");
90 NodeID vtblId = vtblPtr->getId();
93 }
94 else
95 {
96 addCandidate(it->second);
97 }
98 }
99 return candidateQueries;
100}
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:107
void addCandidate(NodeID id)
Definition DDAClient.h:101
OrderedNodeSet candidateQueries
store all candidate pointers to be queried
Definition DDAClient.h:109
VTablePtrToCallSiteMap vtableToCallSiteMap
Definition DDAClient.h:124
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:451
u32_t NodeID
Definition GeneralType.h:56
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ performStat()

void FunptrDDAClient::performStat ( PointerAnalysis pta)
virtual

Reimplemented from SVF::DDAClient.

Definition at line 102 of file DDAClient.cpp.

103{
104
112
113 for (VTablePtrToCallSiteMap::iterator nIter = vtableToCallSiteMap.begin();
114 nIter != vtableToCallSiteMap.end(); ++nIter)
115 {
116 NodeID vtptr = nIter->first;
117 const PointsTo& ddaPts = pta->getPts(vtptr);
118 const PointsTo& anderPts = ander->getPts(vtptr);
119
120 CallGraph* callgraph = ander->getCallGraph();
121 const CallICFGNode* cbn = nIter->second;
122
123 if(!callgraph->hasIndCSCallees(cbn))
124 {
125 //outs() << "virtual callsite has no callee" << *(nIter->second.getInstruction()) << "\n";
126 continue;
127 }
128
131 if(callees.size() == 0)
133 else if(callees.size() == 1)
135 else if(callees.size() == 2)
137 else
139
140 if(ddaPts.count() >= anderPts.count() || ddaPts.empty())
141 continue;
142
147
149 outs() << "============more precise callsite =================\n";
150 outs() << (nIter->second)->toString() << "\n";
151 outs() << (nIter->second)->getSourceLoc() << "\n";
152 outs() << "\n";
153 outs() << "------ander pts or vtable num---(" << anderPts.count() << ")--\n";
154 outs() << "------DDA vfn num---(" << ander_vfns.size() << ")--\n";
155 //ander->dumpPts(vtptr, anderPts);
156 outs() << "------DDA pts or vtable num---(" << ddaPts.count() << ")--\n";
157 outs() << "------DDA vfn num---(" << dda_vfns.size() << ")--\n";
158 //pta->dumpPts(vtptr, ddaPts);
159 outs() << "-------------------------\n";
160 outs() << "\n";
161 outs() << "=================================================\n";
162 }
163
164 outs() << "=================================================\n";
165 outs() << "Total virtual callsites: " << vtableToCallSiteMap.size() << "\n";
166 outs() << "Total analyzed virtual callsites: " << totalCallsites << "\n";
167 outs() << "Indirect call map size: " << ander->getCallGraph()->getIndCallMap().size() << "\n";
168 outs() << "Precise callsites: " << morePreciseCallsites << "\n";
169 outs() << "Zero target callsites: " << zeroTargetCallsites << "\n";
170 outs() << "One target callsites: " << oneTargetCallsites << "\n";
171 outs() << "Two target callsites: " << twoTargetCallsites << "\n";
172 outs() << "More than two target callsites: " << moreThanTwoCallsites << "\n";
173 outs() << "=================================================\n";
174}
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:407
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition Andersen.h:238
bool hasIndCSCallees(const CallICFGNode *cs) const
Definition CallGraph.h:335
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
Definition CallGraph.h:339
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Definition CallGraph.h:331
Set< const FunObjVar * > FunctionSet
Definition CallGraph.h:247
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
CallGraph * getCallGraph() const
Return call graph.
const std::string getSourceLoc(const Value *val)
Definition LLVMUtil.cpp:453
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

Member Data Documentation

◆ vtableToCallSiteMap

VTablePtrToCallSiteMap SVF::FunptrDDAClient::vtableToCallSiteMap
private

Definition at line 124 of file DDAClient.h.


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