Static Value-Flow Analysis
LockResultValidator.h
Go to the documentation of this file.
1 /*
2  * LOCKResultValidator.h
3  *
4  * Created on: 24/07/2021
5  */
6 
7 
8 
9 #ifndef LOCKRESULTVALIDATOR_H_
10 #define LOCKRESULTVALIDATOR_H_
11 
12 #include "MTA/LockAnalysis.h"
13 #include "SVF-LLVM/LLVMUtil.h"
14 
15 /* Validate the result of lock analysis */
16 
17 namespace SVF
18 {
20 {
21 public:
24 
25  typedef unsigned LOCK_FLAG;
26 
28  {
29  _mod = _la->getTCT()->getSVFModule();
30  }
31 
33 
34  void analyze();
35 
36  inline SVFModule* getModule() const
37  {
38  return _mod;
39  }
40 private:
41  // Get CallICFGNode
42  inline CallICFGNode* getCBN(const SVFInstruction* inst)
43  {
44  return _la->getTCT()->getCallICFGNode(inst);
45  }
47 
48  inline bool inFilter(const std::string& name)
49  {
50  return filterFun.find(name) != filterFun.end();
51  }
52 
53  inline bool match(const std::string& lockName, CxtLockSetStr LS)
54  {
55  return LS.find(lockName) != LS.end();
56  }
57 
58  Set<std::string> &split(const std::string &s, char delim, Set<std::string> &elems);
59  Set<std::string> split(const std::string &s, char delim);
60 
61  std::string getOutput(const char* scenario, LOCK_FLAG analysisRes);
62 
63  Set<std::string> getStringArg(const Instruction* inst, unsigned int arg_num);
64 
65  bool collectLockTargets();
67 
71 
74 
75  static const LOCK_FLAG LOCK_TRUE = 0x01;
76  static const LOCK_FLAG LOCK_IMPRECISE = 0x02;
77  static const LOCK_FLAG LOCK_UNSOUND = 0x04;
78 
79  static constexpr char const *LOCK = "LOCK";
80 
81  Set<std::string> filterFun = {"LOCK", "INTERLEV_ACCESS", "PAUSE", "CXT_THREAD", "TCT_ACCESS"};
82 };
83 } // End namespace SVF
84 #endif /* LOCKRESULTVALIDATOR_H_ */
const char *const name
Definition: cJSON.h:264
const char *const string
Definition: cJSON.h:172
Set< CxtLock > CxtLockSet
Definition: LockAnalysis.h:70
TCT * getTCT()
Get tct.
Definition: LockAnalysis.h:324
Map< CxtStmt, CxtLockSet > CxtStmtToCxtLockSet
Definition: LockAnalysis.h:76
static const LOCK_FLAG LOCK_TRUE
static const LOCK_FLAG LOCK_UNSOUND
Set< std::string > getStringArg(const Instruction *inst, unsigned int arg_num)
Map< const SVFInstruction *, CxtLockSetStr > CxtStmtToCxtLockS
bool match(const std::string &lockName, CxtLockSetStr LS)
LockAnalysis::CxtLockSet cxtLockSet
bool inFilter(const std::string &name)
Set< std::string > filterFun
static const LOCK_FLAG LOCK_IMPRECISE
CallICFGNode * getCBN(const SVFInstruction *inst)
SVFModule * getModule() const
CxtStmtToCxtLockS instToCxtLockSet
const Instruction * getPreviousMemoryAccessInst(const Instruction *I)
std::string getOutput(const char *scenario, LOCK_FLAG analysisRes)
Set< std::string > & split(const std::string &s, char delim, Set< std::string > &elems)
LockResultValidator(LockAnalysis *la)
LockAnalysis::CxtStmtToCxtLockSet cxtStmtToCxtLockSet
static constexpr char const * LOCK
Set< std::string > CxtLockSetStr
CallICFGNode * getCallICFGNode(const SVFInstruction *inst)
Get CallICFGNode given inst.
Definition: TCT.h:171
SVFModule * getSVFModule() const
Get SVFFModule.
Definition: TCT.h:176
for isBitcode
Definition: BasicTypes.h:68
llvm::Instruction Instruction
Definition: BasicTypes.h:87
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96