Static Value-Flow Analysis
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
SVF::DDAClient Class Reference

#include <DDAClient.h>

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

Public Member Functions

 DDAClient (SVFModule *mod)
 
virtual ~DDAClient ()
 
virtual void initialise (SVFModule *)
 
virtual OrderedNodeSetcollectCandidateQueries (SVFIR *p)
 Collect candidate pointers for query. More...
 
const OrderedNodeSetgetCandidateQueries () const
 Get candidate queries. More...
 
virtual void handleStatement (const SVFGNode *, NodeID)
 Call back used by DDAVFSolver. More...
 
void setPAG (SVFIR *g)
 Set SVFIR graph. More...
 
void setCurrentQueryPtr (NodeID ptr)
 Set the pointer being queried. More...
 
void setQuery (NodeID ptr)
 Set pointer to be queried by DDA analysis. More...
 
SVFModulegetModule () const
 Get LLVM module. More...
 
virtual void answerQueries (PointerAnalysis *pta)
 
virtual void performStat (PointerAnalysis *)
 
virtual void collectWPANum (SVFModule *)
 

Protected Member Functions

void addCandidate (NodeID id)
 

Protected Attributes

SVFIRpag
 SVFIR graph used by current DDA analysis. More...
 
SVFModulemodule
 LLVM module. More...
 
NodeID curPtr
 current pointer being queried More...
 
OrderedNodeSet candidateQueries
 store all candidate pointers to be queried More...
 

Private Attributes

OrderedNodeSet userInput
 User input queries. More...
 
bool solveAll
 TRUE if all top level pointers are being queried. More...
 

Detailed Description

General DDAClient which queries all top level pointers by default.

Definition at line 48 of file DDAClient.h.

Constructor & Destructor Documentation

◆ DDAClient()

SVF::DDAClient::DDAClient ( SVFModule mod)
inline

Definition at line 51 of file DDAClient.h.

51 : pag(nullptr), module(mod), curPtr(0), solveAll(true) {}
SVFModule * module
LLVM module.
Definition: DDAClient.h:112
SVFIR * pag
SVFIR graph used by current DDA analysis.
Definition: DDAClient.h:111
NodeID curPtr
current pointer being queried
Definition: DDAClient.h:113
bool solveAll
TRUE if all top level pointers are being queried.
Definition: DDAClient.h:118

◆ ~DDAClient()

virtual SVF::DDAClient::~DDAClient ( )
inlinevirtual

Definition at line 53 of file DDAClient.h.

53 {}

Member Function Documentation

◆ addCandidate()

void SVF::DDAClient::addCandidate ( NodeID  id)
inlineprotected

Definition at line 105 of file DDAClient.h.

106  {
107  if (pag->isValidTopLevelPtr(pag->getGNode(id)))
108  candidateQueries.insert(id);
109  }
OrderedNodeSet candidateQueries
store all candidate pointers to be queried
Definition: DDAClient.h:114
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
bool isValidTopLevelPtr(const SVFVar *node)
Definition: SVFIR.cpp:673

◆ answerQueries()

void DDAClient::answerQueries ( PointerAnalysis pta)
virtual

Definition at line 46 of file DDAClient.cpp.

47 {
48 
49  DDAStat* stat = static_cast<DDAStat*>(pta->getStat());
50  u32_t vmrss = 0;
51  u32_t vmsize = 0;
52  SVFUtil::getMemoryUsageKB(&vmrss, &vmsize);
53  stat->setMemUsageBefore(vmrss, vmsize);
54 
56 
57  u32_t count = 0;
58  for (OrderedNodeSet::iterator nIter = candidateQueries.begin();
59  nIter != candidateQueries.end(); ++nIter,++count)
60  {
61  PAGNode* node = pta->getPAG()->getGNode(*nIter);
62  if(pta->getPAG()->isValidTopLevelPtr(node))
63  {
64  DBOUT(DGENERAL,outs() << "\n@@Computing PointsTo for :" << node->getId() <<
65  " [" << count + 1<< "/" << candidateQueries.size() << "]" << " \n");
66  DBOUT(DDDA,outs() << "\n@@Computing PointsTo for :" << node->getId() <<
67  " [" << count + 1<< "/" << candidateQueries.size() << "]" << " \n");
68  setCurrentQueryPtr(node->getId());
69  pta->computeDDAPts(node->getId());
70  }
71  }
72 
73  vmrss = vmsize = 0;
74  SVFUtil::getMemoryUsageKB(&vmrss, &vmsize);
75  stat->setMemUsageAfter(vmrss, vmsize);
76 }
unsigned u32_t
Definition: CommandLine.h:18
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DGENERAL
Definition: SVFType.h:490
#define DDDA
Definition: SVFType.h:496
int count
Definition: cJSON.h:216
void setCurrentQueryPtr(NodeID ptr)
Set the pointer being queried.
Definition: DDAClient.h:84
virtual OrderedNodeSet & collectCandidateQueries(SVFIR *p)
Collect candidate pointers for query.
Definition: DDAClient.h:58
void setMemUsageBefore(u32_t vmrss, u32_t vmsize)
Definition: PTAStat.h:56
void setMemUsageAfter(u32_t vmrss, u32_t vmsize)
Definition: PTAStat.h:62
virtual void computeDDAPts(NodeID)
Compute points-to results on-demand, overridden by derived classes.
PTAStat * getStat() const
Get PTA stat.
SVFIR * getPAG() const
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
Definition: SVFUtil.cpp:177
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ collectCandidateQueries()

virtual OrderedNodeSet& SVF::DDAClient::collectCandidateQueries ( SVFIR p)
inlinevirtual

Collect candidate pointers for query.

Reimplemented in SVF::AliasDDAClient, and SVF::FunptrDDAClient.

Definition at line 58 of file DDAClient.h.

59  {
60  setPAG(p);
61  if (solveAll)
63  else
64  {
65  for (OrderedNodeSet::iterator it = userInput.begin(), eit = userInput.end(); it != eit; ++it)
66  addCandidate(*it);
67  }
68  return candidateQueries;
69  }
cJSON * p
Definition: cJSON.cpp:2559
void setPAG(SVFIR *g)
Set SVFIR graph.
Definition: DDAClient.h:79
OrderedNodeSet userInput
User input queries.
Definition: DDAClient.h:117
void addCandidate(NodeID id)
Definition: DDAClient.h:105
OrderedNodeSet & getAllValidPtrs()
Return valid pointers.
Definition: SVFIR.h:139

◆ collectWPANum()

virtual void SVF::DDAClient::collectWPANum ( SVFModule )
inlinevirtual

Definition at line 103 of file DDAClient.h.

103 {}

◆ getCandidateQueries()

const OrderedNodeSet& SVF::DDAClient::getCandidateQueries ( ) const
inline

Get candidate queries.

Definition at line 71 of file DDAClient.h.

72  {
73  return candidateQueries;
74  }

◆ getModule()

SVFModule* SVF::DDAClient::getModule ( ) const
inline

Get LLVM module.

Definition at line 95 of file DDAClient.h.

96  {
97  return module;
98  }

◆ handleStatement()

virtual void SVF::DDAClient::handleStatement ( const SVFGNode ,
NodeID   
)
inlinevirtual

Call back used by DDAVFSolver.

Definition at line 77 of file DDAClient.h.

77 {}

◆ initialise()

virtual void SVF::DDAClient::initialise ( SVFModule )
inlinevirtual

Definition at line 55 of file DDAClient.h.

55 {}

◆ performStat()

virtual void SVF::DDAClient::performStat ( PointerAnalysis )
inlinevirtual

Reimplemented in SVF::AliasDDAClient, and SVF::FunptrDDAClient.

Definition at line 101 of file DDAClient.h.

101 {}

◆ setCurrentQueryPtr()

void SVF::DDAClient::setCurrentQueryPtr ( NodeID  ptr)
inline

Set the pointer being queried.

Definition at line 84 of file DDAClient.h.

85  {
86  curPtr = ptr;
87  }

◆ setPAG()

void SVF::DDAClient::setPAG ( SVFIR g)
inline

Set SVFIR graph.

Definition at line 79 of file DDAClient.h.

80  {
81  pag = g;
82  }

◆ setQuery()

void SVF::DDAClient::setQuery ( NodeID  ptr)
inline

Set pointer to be queried by DDA analysis.

Definition at line 89 of file DDAClient.h.

90  {
91  userInput.insert(ptr);
92  solveAll = false;
93  }

Member Data Documentation

◆ candidateQueries

OrderedNodeSet SVF::DDAClient::candidateQueries
protected

store all candidate pointers to be queried

Definition at line 114 of file DDAClient.h.

◆ curPtr

NodeID SVF::DDAClient::curPtr
protected

current pointer being queried

Definition at line 113 of file DDAClient.h.

◆ module

SVFModule* SVF::DDAClient::module
protected

LLVM module.

Definition at line 112 of file DDAClient.h.

◆ pag

SVFIR* SVF::DDAClient::pag
protected

SVFIR graph used by current DDA analysis.

Definition at line 111 of file DDAClient.h.

◆ solveAll

bool SVF::DDAClient::solveAll
private

TRUE if all top level pointers are being queried.

Definition at line 118 of file DDAClient.h.

◆ userInput

OrderedNodeSet SVF::DDAClient::userInput
private

User input queries.

Definition at line 117 of file DDAClient.h.


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