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 <AbstractInterpretation.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 53 of file AbstractInterpretation.h.

Constructor & Destructor Documentation

◆ AEStat()

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

Definition at line 57 of file AbstractInterpretation.h.

57 : _ae(ae)
58 {
59 startTime = getClk(true);
60 }
AbstractInterpretation * _ae
double startTime
Definition SVFStat.h:80
static double getClk(bool mark=false)
Definition SVFStat.cpp:48
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~AEStat()

SVF::AEStat::~AEStat ( )
inline

Definition at line 61 of file AbstractInterpretation.h.

62 {
63 }

Member Function Documentation

◆ countStateSize()

void AEStat::countStateSize ( )

Definition at line 1172 of file AbstractInterpretation.cpp.

1173{
1174 if (count == 0)
1175 {
1176 generalNumMap["ES_Var_AVG_Num"] = 0;
1177 generalNumMap["ES_Loc_AVG_Num"] = 0;
1178 generalNumMap["ES_Var_Addr_AVG_Num"] = 0;
1179 generalNumMap["ES_Loc_Addr_AVG_Num"] = 0;
1180 }
1181 ++count;
1182}
NUMStatMap generalNumMap
Definition SVFStat.h:76

◆ finializeStat()

void AEStat::finializeStat ( )

Definition at line 1184 of file AbstractInterpretation.cpp.

1185{
1187 if (count > 0)
1188 {
1189 generalNumMap["ES_Var_AVG_Num"] /= count;
1190 generalNumMap["ES_Loc_AVG_Num"] /= count;
1191 generalNumMap["ES_Var_Addr_AVG_Num"] /= count;
1192 generalNumMap["ES_Loc_Addr_AVG_Num"] /= count;
1193 }
1194 generalNumMap["SVF_STMT_NUM"] = count;
1195
1197 generalNumMap["ICFG_Node_Num"] = totalICFGNodes;
1198
1199 // Calculate coverage: use allAnalyzedNodes which tracks all nodes across all entry points
1201 generalNumMap["Analyzed_ICFG_Node_Num"] = analyzedNodes;
1202
1203 // Coverage percentage (stored as integer percentage * 100 for precision)
1204 if (totalICFGNodes > 0)
1205 {
1206 double coveragePercent = (double)analyzedNodes / (double)totalICFGNodes * 100.0;
1207 generalNumMap["ICFG_Coverage_Percent"] = (u32_t)(coveragePercent * 100); // Store as percentage * 100
1208 }
1209 else
1210 {
1211 generalNumMap["ICFG_Coverage_Percent"] = 0;
1212 }
1213
1214 u32_t callSiteNum = 0;
1218 for (const auto &it: *_ae->svfir->getICFG())
1219 {
1220 if (it.second->getFun())
1221 {
1222 funs.insert(it.second->getFun());
1223 // Check if this node was analyzed (across all entry points)
1224 if (_ae->allAnalyzedNodes.find(it.second) != _ae->allAnalyzedNodes.end())
1225 {
1226 analyzedFuns.insert(it.second->getFun());
1227 }
1228 }
1229 if (const CallICFGNode *callNode = dyn_cast<CallICFGNode>(it.second))
1230 {
1231 if (!isExtCall(callNode))
1232 {
1233 callSiteNum++;
1234 }
1235 else
1236 {
1238 }
1239 }
1240 }
1241 generalNumMap["Func_Num"] = funs.size();
1242 generalNumMap["Analyzed_Func_Num"] = analyzedFuns.size();
1243
1244 // Function coverage percentage
1245 if (funs.size() > 0)
1246 {
1247 double funcCoveragePercent = (double)analyzedFuns.size() / (double)funs.size() * 100.0;
1248 generalNumMap["Func_Coverage_Percent"] = (u32_t)(funcCoveragePercent * 100); // Store as percentage * 100
1249 }
1250 else
1251 {
1252 generalNumMap["Func_Coverage_Percent"] = 0;
1253 }
1254
1255 generalNumMap["EXT_CallSite_Num"] = extCallSiteNum;
1256 generalNumMap["NonEXT_CallSite_Num"] = callSiteNum;
1257 timeStatMap["Total_Time(sec)"] = (double)(endTime - startTime) / TIMEINTERVAL;
1258
1259}
unsigned u32_t
Definition CommandLine.h:18
#define TIMEINTERVAL
Definition SVFType.h:621
std::string getMemUsage()
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:217
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 88 of file AbstractInterpretation.h.

89 {
90 if (generalNumMap.count("Block_Trace") == 0)
91 {
92 generalNumMap["Block_Trace"] = 0;
93 }
94 return generalNumMap["Block_Trace"];
95 }

◆ getFunctionTrace()

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

Definition at line 80 of file AbstractInterpretation.h.

81 {
82 if (generalNumMap.count("Function_Trace") == 0)
83 {
84 generalNumMap["Function_Trace"] = 0;
85 }
86 return generalNumMap["Function_Trace"];
87 }

◆ getICFGNodeTrace()

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

Definition at line 96 of file AbstractInterpretation.h.

97 {
98 if (generalNumMap.count("ICFG_Node_Trace") == 0)
99 {
100 generalNumMap["ICFG_Node_Trace"] = 0;
101 }
102 return generalNumMap["ICFG_Node_Trace"];
103 }

◆ getMemUsage()

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

Definition at line 64 of file AbstractInterpretation.h.

65 {
67 return SVFUtil::getMemoryUsageKB(&vmrss, &vmsize) ? std::to_string(vmsize) + "KB" : "cannot read memory usage";
68 }
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 1261 of file AbstractInterpretation.cpp.

1262{
1263 std::string fullName(_ae->moduleName);
1264 std::string name;
1265 std::string moduleName;
1266 if (fullName.find('/') == std::string::npos)
1267 {
1268 std::string name = fullName;
1269 moduleName = name.substr(0, fullName.find('.'));
1270 }
1271 else
1272 {
1273 std::string name = fullName.substr(fullName.find('/'), fullName.size());
1274 moduleName = name.substr(0, fullName.find('.'));
1275 }
1276
1277 SVFUtil::outs() << "\n************************\n";
1278 SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
1279 SVFUtil::outs().flags(std::ios::left);
1280 unsigned field_width = 30;
1281 for (NUMStatMap::iterator it = generalNumMap.begin(), eit = generalNumMap.end(); it != eit; ++it)
1282 {
1283 // Special handling for percentage fields (stored as percentage * 100)
1284 if (it->first == "ICFG_Coverage_Percent" || it->first == "Func_Coverage_Percent")
1285 {
1286 double percent = (double)it->second / 100.0;
1287 std::cout << std::setw(field_width) << it->first << std::fixed << std::setprecision(2) << percent << "%\n";
1288 }
1289 else
1290 {
1291 std::cout << std::setw(field_width) << it->first << it->second << "\n";
1292 }
1293 }
1294 SVFUtil::outs() << "-------------------------------------------------------\n";
1295 for (TIMEStatMap::iterator it = timeStatMap.begin(), eit = timeStatMap.end(); it != eit; ++it)
1296 {
1297 // format out put with width 20 space
1298 SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
1299 }
1300 SVFUtil::outs() << "Memory usage: " << memUsage << "\n";
1301
1302 SVFUtil::outs() << "#######################################################" << std::endl;
1303 SVFUtil::outs().flush();
1304}
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 74 of file AbstractInterpretation.h.

◆ count

s32_t SVF::AEStat::count {0}

Definition at line 75 of file AbstractInterpretation.h.

75{0};

◆ memory_usage

std::string SVF::AEStat::memory_usage

Definition at line 76 of file AbstractInterpretation.h.

◆ memUsage

std::string SVF::AEStat::memUsage

Definition at line 77 of file AbstractInterpretation.h.


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