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

AEStat: Statistic for AE. More...

#include <AEStat.h>

Inheritance diagram for SVF::AEStat:
SVF::SVFStat

Public Member Functions

void countStateSize ()
 
 AEStat (AbstractInterpretation *ae)
 
 ~AEStat ()
 
std::string getMemUsage ()
 
void finializeStat ()
 
void performStat () override
 
u32_tgetFunctionTrace ()
 
u32_tgetBlockTrace ()
 
u32_tgetICFGNodeTrace ()
 
- Public Member Functions inherited from SVF::SVFStat
 SVFStat ()
 
virtual ~SVFStat ()
 
virtual void startClk ()
 
virtual void endClk ()
 
virtual void printStat (std::string str="")
 
virtual void performStatPerQuery (NodeID)
 
virtual void printStatPerQuery (NodeID, const PointsTo &)
 
virtual void callgraphStat ()
 

Public Attributes

AbstractInterpretation_ae
 
s32_t count {0}
 
std::string memory_usage
 
std::string memUsage
 
- Public Attributes inherited from SVF::SVFStat
NUMStatMap generalNumMap
 
NUMStatMap PTNumStatMap
 
TIMEStatMap timeStatMap
 
double startTime
 
double endTime
 

Additional Inherited Members

- Public Types inherited from SVF::SVFStat
enum  ClockType { Wall , CPU }
 
typedef OrderedMap< std::string, u32_tNUMStatMap
 
typedef OrderedMap< std::string, doubleTIMEStatMap
 
- Static Public Member Functions inherited from SVF::SVFStat
static double getClk (bool mark=false)
 
- Static Public Attributes inherited from SVF::SVFStat
static bool printGeneralStats = true
 SVF's general statistics are only printed once even if you run multiple anayses.
 
static double timeOfBuildingLLVMModule = 0
 
static double timeOfBuildingSymbolTable = 0
 
static double timeOfBuildingSVFIR = 0
 

Detailed Description

AEStat: Statistic for AE.

Definition at line 35 of file AEStat.h.

Constructor & Destructor Documentation

◆ AEStat()

SVF::AEStat::AEStat ( AbstractInterpretation ae)
inline

Definition at line 39 of file AEStat.h.

39 : _ae(ae)
40 {
41 startTime = getClk(true);
42 }
AbstractInterpretation * _ae
Definition AEStat.h:56
double startTime
Definition SVFStat.h:80
static double getClk(bool mark=false)
Definition SVFStat.cpp:48
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~AEStat()

SVF::AEStat::~AEStat ( )
inline

Definition at line 43 of file AEStat.h.

44 {
45 }

Member Function Documentation

◆ countStateSize()

void AEStat::countStateSize ( )

Definition at line 31 of file AEStat.cpp.

32{
33 if (count == 0)
34 {
35 generalNumMap["ES_Var_AVG_Num"] = 0;
36 generalNumMap["ES_Loc_AVG_Num"] = 0;
37 generalNumMap["ES_Var_Addr_AVG_Num"] = 0;
38 generalNumMap["ES_Loc_Addr_AVG_Num"] = 0;
39 }
40 ++count;
41}
s32_t count
Definition AEStat.h:57
NUMStatMap generalNumMap
Definition SVFStat.h:76

◆ finializeStat()

void AEStat::finializeStat ( )

Definition at line 44 of file AEStat.cpp.

45{
47 if (count > 0)
48 {
49 generalNumMap["ES_Var_AVG_Num"] /= count;
50 generalNumMap["ES_Loc_AVG_Num"] /= count;
51 generalNumMap["ES_Var_Addr_AVG_Num"] /= count;
52 generalNumMap["ES_Loc_Addr_AVG_Num"] /= count;
53 }
54 generalNumMap["SVF_STMT_NUM"] = count;
55
57 generalNumMap["ICFG_Node_Num"] = totalICFGNodes;
58
59 // Calculate coverage: use allAnalyzedNodes which tracks all nodes across all entry points
61 generalNumMap["Analyzed_ICFG_Node_Num"] = analyzedNodes;
62
63 // Coverage percentage (stored as integer percentage * 100 for precision)
64 if (totalICFGNodes > 0)
65 {
66 double coveragePercent = (double)analyzedNodes / (double)totalICFGNodes * 100.0;
67 generalNumMap["ICFG_Coverage_Percent"] = (u32_t)(coveragePercent * 100); // Store as percentage * 100
68 }
69 else
70 {
71 generalNumMap["ICFG_Coverage_Percent"] = 0;
72 }
73
78 for (const auto &it: *_ae->svfir->getICFG())
79 {
80 if (it.second->getFun())
81 {
82 funs.insert(it.second->getFun());
83 // Check if this node was analyzed (across all entry points)
84 if (_ae->allAnalyzedNodes.find(it.second) != _ae->allAnalyzedNodes.end())
85 {
86 analyzedFuns.insert(it.second->getFun());
87 }
88 }
90 {
91 if (!isExtCall(callNode))
92 {
94 }
95 else
96 {
98 }
99 }
100 }
101 generalNumMap["Func_Num"] = funs.size();
102 generalNumMap["Analyzed_Func_Num"] = analyzedFuns.size();
103
104 // Function coverage percentage
105 if (funs.size() > 0)
106 {
107 double funcCoveragePercent = (double)analyzedFuns.size() / (double)funs.size() * 100.0;
108 generalNumMap["Func_Coverage_Percent"] = (u32_t)(funcCoveragePercent * 100); // Store as percentage * 100
109 }
110 else
111 {
112 generalNumMap["Func_Coverage_Percent"] = 0;
113 }
114
115 generalNumMap["EXT_CallSite_Num"] = extCallSiteNum;
116 generalNumMap["NonEXT_CallSite_Num"] = callSiteNum;
117 timeStatMap["Total_Time(sec)"] = (double)(endTime - startTime) / TIMEINTERVAL;
118
119}
unsigned u32_t
Definition CommandLine.h:18
#define TIMEINTERVAL
Definition SVFType.h:621
std::string memUsage
Definition AEStat.h:59
std::string getMemUsage()
Definition AEStat.h:46
SVFIR * svfir
protected data members, also used in subclasses
Set< const ICFGNode * > allAnalyzedNodes
u32_t nodeNum
total num of edge
ICFG * getICFG() const
Definition SVFIR.h:229
TIMEStatMap timeStatMap
Definition SVFStat.h:78
double endTime
Definition SVFStat.h:81
bool isExtCall(const FunObjVar *fun)
Definition SVFUtil.cpp:437
unsigned u32_t
Definition GeneralType.h:47

◆ getBlockTrace()

u32_t & SVF::AEStat::getBlockTrace ( )
inline

Definition at line 70 of file AEStat.h.

71 {
72 if (generalNumMap.count("Block_Trace") == 0)
73 {
74 generalNumMap["Block_Trace"] = 0;
75 }
76 return generalNumMap["Block_Trace"];
77 }

◆ getFunctionTrace()

u32_t & SVF::AEStat::getFunctionTrace ( )
inline

Definition at line 62 of file AEStat.h.

63 {
64 if (generalNumMap.count("Function_Trace") == 0)
65 {
66 generalNumMap["Function_Trace"] = 0;
67 }
68 return generalNumMap["Function_Trace"];
69 }

◆ getICFGNodeTrace()

u32_t & SVF::AEStat::getICFGNodeTrace ( )
inline

Definition at line 78 of file AEStat.h.

79 {
80 if (generalNumMap.count("ICFG_Node_Trace") == 0)
81 {
82 generalNumMap["ICFG_Node_Trace"] = 0;
83 }
84 return generalNumMap["ICFG_Node_Trace"];
85 }

◆ getMemUsage()

std::string SVF::AEStat::getMemUsage ( )
inline

Definition at line 46 of file AEStat.h.

47 {
49 return SVFUtil::getMemoryUsageKB(&vmrss, &vmsize) ? std::to_string(vmsize) + "KB" : "cannot read memory usage";
50 }
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
Definition SVFUtil.cpp:179

◆ performStat()

void AEStat::performStat ( )
overridevirtual

Implements SVF::SVFStat.

Definition at line 121 of file AEStat.cpp.

122{
123 std::string fullName(_ae->moduleName);
124 std::string name;
125 std::string moduleName;
126 if (fullName.find('/') == std::string::npos)
127 {
128 std::string name = fullName;
129 moduleName = name.substr(0, fullName.find('.'));
130 }
131 else
132 {
133 std::string name = fullName.substr(fullName.find('/'), fullName.size());
134 moduleName = name.substr(0, fullName.find('.'));
135 }
136
137 SVFUtil::outs() << "\n************************\n";
138 SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
139 SVFUtil::outs().flags(std::ios::left);
140 unsigned field_width = 30;
141 for (NUMStatMap::iterator it = generalNumMap.begin(), eit = generalNumMap.end(); it != eit; ++it)
142 {
143 // Special handling for percentage fields (stored as percentage * 100)
144 if (it->first == "ICFG_Coverage_Percent" || it->first == "Func_Coverage_Percent")
145 {
146 double percent = (double)it->second / 100.0;
147 std::cout << std::setw(field_width) << it->first << std::fixed << std::setprecision(2) << percent << "%\n";
148 }
149 else
150 {
151 std::cout << std::setw(field_width) << it->first << it->second << "\n";
152 }
153 }
154 SVFUtil::outs() << "-------------------------------------------------------\n";
155 for (TIMEStatMap::iterator it = timeStatMap.begin(), eit = timeStatMap.end(); it != eit; ++it)
156 {
157 // format out put with width 20 space
158 SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
159 }
160 SVFUtil::outs() << "Memory usage: " << memUsage << "\n";
161
162 SVFUtil::outs() << "#######################################################" << std::endl;
163 SVFUtil::outs().flush();
164}
const char *const name
Definition cJSON.h:264
std::string moduleName
Definition SVFStat.h:99
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

Member Data Documentation

◆ _ae

AbstractInterpretation* SVF::AEStat::_ae

Definition at line 56 of file AEStat.h.

◆ count

s32_t SVF::AEStat::count {0}

Definition at line 57 of file AEStat.h.

57{0};

◆ memory_usage

std::string SVF::AEStat::memory_usage

Definition at line 58 of file AEStat.h.

◆ memUsage

std::string SVF::AEStat::memUsage

Definition at line 59 of file AEStat.h.


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