svf-tools 1.0.981 → 1.0.983
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/AE/Svfexe/AEDetector.h +1 -13
- package/svf/include/Graphs/ICFGNode.h +33 -0
- package/svf/include/Graphs/VFGNode.h +0 -6
- package/svf/include/MTA/LockAnalysis.h +1 -1
- package/svf/include/MTA/TCT.h +1 -10
- package/svf/include/SABER/SaberCondAllocator.h +5 -5
- package/svf/include/Util/SVFBugReport.h +2 -2
- package/svf/include/Util/SVFUtil.h +19 -36
- package/svf/include/Util/ThreadAPI.h +1 -55
- package/svf/lib/AE/Svfexe/AEDetector.cpp +4 -4
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +6 -6
- package/svf/lib/CFL/CFLAlias.cpp +3 -3
- package/svf/lib/DDA/DDAClient.cpp +2 -2
- package/svf/lib/Graphs/CallGraph.cpp +1 -1
- package/svf/lib/Graphs/IRGraph.cpp +2 -4
- package/svf/lib/Graphs/ThreadCallGraph.cpp +4 -4
- package/svf/lib/Graphs/VFG.cpp +1 -1
- package/svf/lib/MTA/LockAnalysis.cpp +4 -4
- package/svf/lib/MTA/MHP.cpp +2 -2
- package/svf/lib/MTA/MTA.cpp +0 -1
- package/svf/lib/MTA/MTAStat.cpp +1 -1
- package/svf/lib/MTA/TCT.cpp +4 -4
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +15 -18
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +2 -2
- package/svf/lib/SABER/DoubleFreeChecker.cpp +1 -1
- package/svf/lib/SABER/FileChecker.cpp +2 -5
- package/svf/lib/SABER/LeakChecker.cpp +2 -2
- package/svf/lib/SABER/ProgSlice.cpp +2 -2
- package/svf/lib/SABER/SaberCondAllocator.cpp +2 -2
- package/svf/lib/Util/CallGraphBuilder.cpp +1 -1
- package/svf/lib/Util/SVFBugReport.cpp +1 -1
- package/svf/lib/Util/SVFUtil.cpp +10 -2
- package/svf/lib/Util/ThreadAPI.cpp +2 -19
- package/svf/lib/WPA/Andersen.cpp +1 -1
- package/svf/lib/WPA/AndersenSCD.cpp +1 -1
- package/svf/lib/WPA/Steensgaard.cpp +1 -1
- package/svf/lib/WPA/TypeAnalysis.cpp +1 -1
- package/svf-llvm/lib/CHGBuilder.cpp +1 -1
- package/svf-llvm/lib/SVFIRExtAPI.cpp +5 -5
- package/svf-llvm/lib/SymbolTableBuilder.cpp +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.983",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -218,21 +218,9 @@ public:
|
|
|
218
218
|
*/
|
|
219
219
|
void addBugToReporter(const AEException& e, const ICFGNode* node)
|
|
220
220
|
{
|
|
221
|
-
const SVFInstruction* inst = nullptr;
|
|
222
|
-
|
|
223
|
-
// Determine the instruction associated with the ICFG node
|
|
224
|
-
if (const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(node))
|
|
225
|
-
{
|
|
226
|
-
inst = call->getCallSite(); // If the node is a call node, get the call site instruction
|
|
227
|
-
}
|
|
228
|
-
else
|
|
229
|
-
{
|
|
230
|
-
inst = node->getSVFStmts().back()->getInst(); // Otherwise, get the last instruction of the node's
|
|
231
|
-
// statements
|
|
232
|
-
}
|
|
233
221
|
|
|
234
222
|
GenericBug::EventStack eventStack;
|
|
235
|
-
SVFBugEvent sourceInstEvent(SVFBugEvent::EventType::SourceInst,
|
|
223
|
+
SVFBugEvent sourceInstEvent(SVFBugEvent::EventType::SourceInst, node);
|
|
236
224
|
eventStack.push_back(sourceInstEvent); // Add the source instruction event to the event stack
|
|
237
225
|
|
|
238
226
|
if (eventStack.empty())
|
|
@@ -132,6 +132,8 @@ public:
|
|
|
132
132
|
|
|
133
133
|
virtual const std::string toString() const;
|
|
134
134
|
|
|
135
|
+
virtual const std::string getSourceLoc() const = 0;
|
|
136
|
+
|
|
135
137
|
void dump() const;
|
|
136
138
|
|
|
137
139
|
protected:
|
|
@@ -172,6 +174,11 @@ public:
|
|
|
172
174
|
//@}
|
|
173
175
|
|
|
174
176
|
virtual const std::string toString() const;
|
|
177
|
+
|
|
178
|
+
virtual const std::string getSourceLoc() const
|
|
179
|
+
{
|
|
180
|
+
return "Global ICFGNode";
|
|
181
|
+
}
|
|
175
182
|
};
|
|
176
183
|
|
|
177
184
|
/*!
|
|
@@ -218,6 +225,11 @@ public:
|
|
|
218
225
|
//@}
|
|
219
226
|
|
|
220
227
|
const std::string toString() const;
|
|
228
|
+
|
|
229
|
+
virtual const std::string getSourceLoc() const
|
|
230
|
+
{
|
|
231
|
+
return inst->getSourceLoc();
|
|
232
|
+
}
|
|
221
233
|
};
|
|
222
234
|
|
|
223
235
|
class InterICFGNode : public ICFGNode
|
|
@@ -252,6 +264,7 @@ public:
|
|
|
252
264
|
|| node->getNodeKind() == FunRetBlock;
|
|
253
265
|
}
|
|
254
266
|
//@}
|
|
267
|
+
virtual const std::string getSourceLoc() const = 0;
|
|
255
268
|
};
|
|
256
269
|
|
|
257
270
|
|
|
@@ -316,6 +329,11 @@ public:
|
|
|
316
329
|
//@}
|
|
317
330
|
|
|
318
331
|
const virtual std::string toString() const;
|
|
332
|
+
|
|
333
|
+
virtual const std::string getSourceLoc() const
|
|
334
|
+
{
|
|
335
|
+
return "function entry: " + fun->getSourceLoc();
|
|
336
|
+
}
|
|
319
337
|
};
|
|
320
338
|
|
|
321
339
|
/*!
|
|
@@ -377,6 +395,11 @@ public:
|
|
|
377
395
|
//@}
|
|
378
396
|
|
|
379
397
|
virtual const std::string toString() const;
|
|
398
|
+
|
|
399
|
+
virtual const std::string getSourceLoc() const
|
|
400
|
+
{
|
|
401
|
+
return "function ret: " + fun->getSourceLoc();
|
|
402
|
+
}
|
|
380
403
|
};
|
|
381
404
|
|
|
382
405
|
/*!
|
|
@@ -478,6 +501,11 @@ public:
|
|
|
478
501
|
//@}
|
|
479
502
|
|
|
480
503
|
virtual const std::string toString() const;
|
|
504
|
+
|
|
505
|
+
virtual const std::string getSourceLoc() const
|
|
506
|
+
{
|
|
507
|
+
return "CallICFGNode: " + cs->getSourceLoc();
|
|
508
|
+
}
|
|
481
509
|
};
|
|
482
510
|
|
|
483
511
|
|
|
@@ -554,6 +582,11 @@ public:
|
|
|
554
582
|
//@}
|
|
555
583
|
|
|
556
584
|
virtual const std::string toString() const;
|
|
585
|
+
|
|
586
|
+
virtual const std::string getSourceLoc() const
|
|
587
|
+
{
|
|
588
|
+
return "RetICFGNode: " + cs->getSourceLoc();
|
|
589
|
+
}
|
|
557
590
|
};
|
|
558
591
|
|
|
559
592
|
} // End namespace SVF
|
|
@@ -181,12 +181,6 @@ public:
|
|
|
181
181
|
|| node->getNodeKind() == Store
|
|
182
182
|
|| node->getNodeKind() == Load;
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
inline const SVFInstruction* getInst() const
|
|
186
|
-
{
|
|
187
|
-
/// should return a valid instruction unless it is a global PAGEdge
|
|
188
|
-
return pagEdge->getInst();
|
|
189
|
-
}
|
|
190
184
|
//@}
|
|
191
185
|
|
|
192
186
|
const SVFValue* getValue() const override;
|
|
@@ -339,7 +339,7 @@ private:
|
|
|
339
339
|
void handleIntra(const CxtStmt& cts);
|
|
340
340
|
|
|
341
341
|
/// Handle call relations
|
|
342
|
-
void handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge,
|
|
342
|
+
void handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge, const CallICFGNode* call);
|
|
343
343
|
|
|
344
344
|
/// Return true it a lock matches an unlock
|
|
345
345
|
bool isAliasedLocks(const CxtLock& cl1, const CxtLock& cl2)
|
package/svf/include/MTA/TCT.h
CHANGED
|
@@ -167,15 +167,6 @@ public:
|
|
|
167
167
|
{
|
|
168
168
|
destroy();
|
|
169
169
|
}
|
|
170
|
-
/// Get CallICFGNode given inst
|
|
171
|
-
CallICFGNode* getCallICFGNode(const SVFInstruction* inst)
|
|
172
|
-
{
|
|
173
|
-
return pta->getICFG()->getCallICFGNode(inst);
|
|
174
|
-
}
|
|
175
|
-
const ICFGNode* getICFGNode(const SVFInstruction* inst)
|
|
176
|
-
{
|
|
177
|
-
return pta->getICFG()->getICFGNode(inst);
|
|
178
|
-
}
|
|
179
170
|
|
|
180
171
|
/// Get SVFFModule
|
|
181
172
|
SVFModule* getSVFModule() const
|
|
@@ -497,7 +488,7 @@ private:
|
|
|
497
488
|
//@}
|
|
498
489
|
|
|
499
490
|
/// Handle call relations
|
|
500
|
-
void handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge,
|
|
491
|
+
void handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, const CallICFGNode* call);
|
|
501
492
|
|
|
502
493
|
/// Get or create a tct node based on CxtThread
|
|
503
494
|
//@{
|
|
@@ -49,7 +49,7 @@ class SaberCondAllocator
|
|
|
49
49
|
public:
|
|
50
50
|
|
|
51
51
|
typedef Z3Expr Condition; /// z3 condition
|
|
52
|
-
typedef Map<u32_t, const
|
|
52
|
+
typedef Map<u32_t, const ICFGNode*> IndexToTermInstMap; /// id to instruction map for z3
|
|
53
53
|
typedef Map<u32_t,Condition> CondPosMap; ///< map a branch to its Condition
|
|
54
54
|
typedef Map<const SVFBasicBlock*, CondPosMap > BBCondMap; /// map bb to a Condition
|
|
55
55
|
typedef Set<const SVFBasicBlock*> BasicBlockSet;
|
|
@@ -118,21 +118,21 @@ public:
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/// Allocate a new condition
|
|
121
|
-
Condition newCond(const
|
|
121
|
+
Condition newCond(const ICFGNode* inst);
|
|
122
122
|
|
|
123
123
|
/// Perform path allocation
|
|
124
124
|
void allocate(const SVFModule* module);
|
|
125
125
|
|
|
126
126
|
/// Get/Set instruction based on Z3 expression id
|
|
127
127
|
//{@
|
|
128
|
-
inline const
|
|
128
|
+
inline const ICFGNode* getCondInst(u32_t id) const
|
|
129
129
|
{
|
|
130
130
|
IndexToTermInstMap::const_iterator it = idToTermInstMap.find(id);
|
|
131
131
|
assert(it != idToTermInstMap.end() && "this should be a fresh condition");
|
|
132
132
|
return it->second;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
inline void setCondInst(const Condition &condition, const
|
|
135
|
+
inline void setCondInst(const Condition &condition, const ICFGNode* inst)
|
|
136
136
|
{
|
|
137
137
|
assert(idToTermInstMap.find(condition.id()) == idToTermInstMap.end() && "this should be a fresh condition");
|
|
138
138
|
idToTermInstMap[condition.id()] = inst;
|
|
@@ -235,7 +235,7 @@ public:
|
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
/// mark neg Z3 expression
|
|
238
|
-
inline void setNegCondInst(const Condition &condition, const
|
|
238
|
+
inline void setNegCondInst(const Condition &condition, const ICFGNode* inst)
|
|
239
239
|
{
|
|
240
240
|
setCondInst(condition, inst);
|
|
241
241
|
negConds.set(condition.id());
|
|
@@ -62,10 +62,10 @@ public:
|
|
|
62
62
|
|
|
63
63
|
protected:
|
|
64
64
|
u32_t typeAndInfoFlag;
|
|
65
|
-
const
|
|
65
|
+
const ICFGNode *eventInst;
|
|
66
66
|
|
|
67
67
|
public:
|
|
68
|
-
SVFBugEvent(u32_t typeAndInfoFlag, const
|
|
68
|
+
SVFBugEvent(u32_t typeAndInfoFlag, const ICFGNode *eventInst): typeAndInfoFlag(typeAndInfoFlag), eventInst(eventInst) { };
|
|
69
69
|
virtual ~SVFBugEvent() = default;
|
|
70
70
|
|
|
71
71
|
inline u32_t getEventType() const
|
|
@@ -169,14 +169,8 @@ void dumpPointsToList(const PointsToList& ptl);
|
|
|
169
169
|
/// Return true if it is an llvm intrinsic instruction
|
|
170
170
|
bool isIntrinsicInst(const SVFInstruction* inst);
|
|
171
171
|
bool isIntrinsicInst(const ICFGNode* inst);
|
|
172
|
-
|
|
173
172
|
//@}
|
|
174
173
|
|
|
175
|
-
/// Whether an instruction is a call or invoke instruction
|
|
176
|
-
inline bool isCallSite(const SVFInstruction* inst)
|
|
177
|
-
{
|
|
178
|
-
return SVFUtil::isa<SVFCallInst>(inst);
|
|
179
|
-
}
|
|
180
174
|
/// Whether an instruction is a call or invoke instruction
|
|
181
175
|
inline bool isCallSite(const SVFValue* val)
|
|
182
176
|
{
|
|
@@ -206,27 +200,16 @@ inline bool isNonInstricCallSite(const ICFGNode* inst)
|
|
|
206
200
|
return isCallSite(inst);
|
|
207
201
|
}
|
|
208
202
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
CallSite cs(inst);
|
|
214
|
-
return cs;
|
|
215
|
-
}
|
|
203
|
+
|
|
204
|
+
/// Return callsite given an instruction
|
|
205
|
+
CallSite getSVFCallSite(const ICFGNode* inst);
|
|
206
|
+
|
|
216
207
|
|
|
217
208
|
/// Match arguments for callsite at caller and callee
|
|
218
209
|
/// if the arg size does not match then we do not need to connect this parameter
|
|
219
210
|
/// unless the callee is a variadic function (the first parameter of variadic function is its parameter number)
|
|
220
|
-
bool matchArgs(const
|
|
211
|
+
bool matchArgs(const CallICFGNode* cs, const SVFFunction* callee);
|
|
221
212
|
|
|
222
|
-
/// Return LLVM callsite given a value
|
|
223
|
-
inline CallSite getSVFCallSite(const SVFValue* value)
|
|
224
|
-
{
|
|
225
|
-
assert(isCallSite(value) && "not a callsite?");
|
|
226
|
-
const SVFCallInst* svfInst = SVFUtil::cast<SVFCallInst>(value);
|
|
227
|
-
CallSite cs(svfInst);
|
|
228
|
-
return cs;
|
|
229
|
-
}
|
|
230
213
|
|
|
231
214
|
/// Split into two substrings around the first occurrence of a separator string.
|
|
232
215
|
inline std::vector<std::string> split(const std::string& s, char separator)
|
|
@@ -418,7 +401,7 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
|
|
|
418
401
|
|
|
419
402
|
/// Return thread fork function
|
|
420
403
|
//@{
|
|
421
|
-
inline const SVFValue* getForkedFun(const
|
|
404
|
+
inline const SVFValue* getForkedFun(const ICFGNode *inst)
|
|
422
405
|
{
|
|
423
406
|
return ThreadAPI::getThreadAPI()->getForkedFun(inst);
|
|
424
407
|
}
|
|
@@ -483,7 +466,7 @@ inline bool isReallocExtCall(const CallSite cs)
|
|
|
483
466
|
|
|
484
467
|
/// Return true if this is a thread creation call
|
|
485
468
|
///@{
|
|
486
|
-
inline bool isThreadForkCall(const
|
|
469
|
+
inline bool isThreadForkCall(const ICFGNode *inst)
|
|
487
470
|
{
|
|
488
471
|
return ThreadAPI::getThreadAPI()->isTDFork(inst);
|
|
489
472
|
}
|
|
@@ -491,49 +474,49 @@ inline bool isThreadForkCall(const SVFInstruction *inst)
|
|
|
491
474
|
|
|
492
475
|
/// Return true if this is a thread join call
|
|
493
476
|
///@{
|
|
494
|
-
inline bool isThreadJoinCall(const
|
|
477
|
+
inline bool isThreadJoinCall(const ICFGNode* cs)
|
|
495
478
|
{
|
|
496
|
-
return ThreadAPI::getThreadAPI()->isTDJoin(cs
|
|
479
|
+
return ThreadAPI::getThreadAPI()->isTDJoin(cs);
|
|
497
480
|
}
|
|
498
481
|
//@}
|
|
499
482
|
|
|
500
483
|
/// Return true if this is a thread exit call
|
|
501
484
|
///@{
|
|
502
|
-
inline bool isThreadExitCall(const
|
|
485
|
+
inline bool isThreadExitCall(const ICFGNode* cs)
|
|
503
486
|
{
|
|
504
|
-
return ThreadAPI::getThreadAPI()->isTDExit(cs
|
|
487
|
+
return ThreadAPI::getThreadAPI()->isTDExit(cs);
|
|
505
488
|
}
|
|
506
489
|
//@}
|
|
507
490
|
|
|
508
491
|
/// Return true if this is a lock acquire call
|
|
509
492
|
///@{
|
|
510
|
-
inline bool isLockAquireCall(const
|
|
493
|
+
inline bool isLockAquireCall(const ICFGNode* cs)
|
|
511
494
|
{
|
|
512
|
-
return ThreadAPI::getThreadAPI()->isTDAcquire(cs
|
|
495
|
+
return ThreadAPI::getThreadAPI()->isTDAcquire(cs);
|
|
513
496
|
}
|
|
514
497
|
//@}
|
|
515
498
|
|
|
516
499
|
/// Return true if this is a lock acquire call
|
|
517
500
|
///@{
|
|
518
|
-
inline bool isLockReleaseCall(const
|
|
501
|
+
inline bool isLockReleaseCall(const ICFGNode* cs)
|
|
519
502
|
{
|
|
520
|
-
return ThreadAPI::getThreadAPI()->isTDRelease(cs
|
|
503
|
+
return ThreadAPI::getThreadAPI()->isTDRelease(cs);
|
|
521
504
|
}
|
|
522
505
|
//@}
|
|
523
506
|
|
|
524
507
|
/// Return true if this is a barrier wait call
|
|
525
508
|
//@{
|
|
526
|
-
inline bool isBarrierWaitCall(const
|
|
509
|
+
inline bool isBarrierWaitCall(const ICFGNode* cs)
|
|
527
510
|
{
|
|
528
|
-
return ThreadAPI::getThreadAPI()->isTDBarWait(cs
|
|
511
|
+
return ThreadAPI::getThreadAPI()->isTDBarWait(cs);
|
|
529
512
|
}
|
|
530
513
|
//@}
|
|
531
514
|
|
|
532
515
|
/// Return sole argument of the thread routine
|
|
533
516
|
//@{
|
|
534
|
-
inline const SVFValue* getActualParmAtForkSite(const
|
|
517
|
+
inline const SVFValue* getActualParmAtForkSite(const ICFGNode* cs)
|
|
535
518
|
{
|
|
536
|
-
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs
|
|
519
|
+
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs);
|
|
537
520
|
}
|
|
538
521
|
//@}
|
|
539
522
|
|
|
@@ -37,6 +37,7 @@ namespace SVF
|
|
|
37
37
|
|
|
38
38
|
class SVFModule;
|
|
39
39
|
class ICFGNode;
|
|
40
|
+
class CallICFGNode;
|
|
40
41
|
|
|
41
42
|
/*
|
|
42
43
|
* ThreadAPI class contains interfaces for pthread programs
|
|
@@ -121,8 +122,6 @@ public:
|
|
|
121
122
|
/// Return the callee/callsite/func
|
|
122
123
|
//@{
|
|
123
124
|
const SVFFunction* getCallee(const ICFGNode *inst) const;
|
|
124
|
-
const SVFFunction* getCallee(const SVFInstruction *inst) const;
|
|
125
|
-
const CallSite getSVFCallSite(const SVFInstruction *inst) const;
|
|
126
125
|
const CallSite getSVFCallSite(const ICFGNode *inst) const;
|
|
127
126
|
//@}
|
|
128
127
|
|
|
@@ -132,10 +131,6 @@ public:
|
|
|
132
131
|
{
|
|
133
132
|
return getType(getCallee(inst)) == TD_FORK;
|
|
134
133
|
}
|
|
135
|
-
inline bool isTDFork(const SVFInstruction* cs) const
|
|
136
|
-
{
|
|
137
|
-
return getType(getCallee(cs)) == TD_FORK;
|
|
138
|
-
}
|
|
139
134
|
//@}
|
|
140
135
|
|
|
141
136
|
/// Return arguments/attributes of pthread_create / hare_parallel_for
|
|
@@ -148,13 +143,6 @@ public:
|
|
|
148
143
|
CallSite cs = getSVFCallSite(inst);
|
|
149
144
|
return cs.getArgument(0);
|
|
150
145
|
}
|
|
151
|
-
inline const SVFValue* getForkedThread(const SVFInstruction* inst) const
|
|
152
|
-
{
|
|
153
|
-
assert(isTDFork(inst) && "not a thread fork function!");
|
|
154
|
-
CallSite cs = getSVFCallSite(inst);
|
|
155
|
-
return cs.getArgument(0);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
146
|
/// Return the third argument of the call,
|
|
159
147
|
/// Note that, it could be function type or a void* pointer
|
|
160
148
|
inline const SVFValue* getForkedFun(const ICFGNode *inst) const
|
|
@@ -163,12 +151,6 @@ public:
|
|
|
163
151
|
CallSite cs = getSVFCallSite(inst);
|
|
164
152
|
return cs.getArgument(2);
|
|
165
153
|
}
|
|
166
|
-
inline const SVFValue* getForkedFun(const SVFInstruction* inst) const
|
|
167
|
-
{
|
|
168
|
-
assert(isTDFork(inst) && "not a thread fork function!");
|
|
169
|
-
CallSite cs = getSVFCallSite(inst);
|
|
170
|
-
return cs.getArgument(2);
|
|
171
|
-
}
|
|
172
154
|
|
|
173
155
|
/// Return the forth argument of the call,
|
|
174
156
|
/// Note that, it is the sole argument of start routine ( a void* pointer )
|
|
@@ -178,12 +160,6 @@ public:
|
|
|
178
160
|
CallSite cs = getSVFCallSite(inst);
|
|
179
161
|
return cs.getArgument(3);
|
|
180
162
|
}
|
|
181
|
-
inline const SVFValue* getActualParmAtForkSite(const SVFInstruction* inst) const
|
|
182
|
-
{
|
|
183
|
-
assert(isTDFork(inst) && "not a thread fork function!");
|
|
184
|
-
CallSite cs = getSVFCallSite(inst);
|
|
185
|
-
return cs.getArgument(3);
|
|
186
|
-
}
|
|
187
163
|
//@}
|
|
188
164
|
|
|
189
165
|
/// Return true if this call wait for a worker thread
|
|
@@ -192,10 +168,6 @@ public:
|
|
|
192
168
|
{
|
|
193
169
|
return getType(getCallee(inst)) == TD_JOIN;
|
|
194
170
|
}
|
|
195
|
-
inline bool isTDJoin(const SVFInstruction* inst) const
|
|
196
|
-
{
|
|
197
|
-
return getType(getCallee(inst)) == TD_JOIN;
|
|
198
|
-
}
|
|
199
171
|
//@}
|
|
200
172
|
|
|
201
173
|
/// Return arguments/attributes of pthread_join
|
|
@@ -211,12 +183,6 @@ public:
|
|
|
211
183
|
CallSite cs = getSVFCallSite(inst);
|
|
212
184
|
return cs.getArgument(1);
|
|
213
185
|
}
|
|
214
|
-
inline const SVFValue* getRetParmAtJoinedSite(const SVFInstruction* inst) const
|
|
215
|
-
{
|
|
216
|
-
assert(isTDJoin(inst) && "not a thread join function!");
|
|
217
|
-
CallSite cs = getSVFCallSite(inst);
|
|
218
|
-
return cs.getArgument(1);
|
|
219
|
-
}
|
|
220
186
|
//@}
|
|
221
187
|
|
|
222
188
|
|
|
@@ -226,11 +192,6 @@ public:
|
|
|
226
192
|
{
|
|
227
193
|
return getType(getCallee(inst)) == TD_EXIT;
|
|
228
194
|
}
|
|
229
|
-
|
|
230
|
-
inline bool isTDExit(const SVFInstruction* inst) const
|
|
231
|
-
{
|
|
232
|
-
return getType(getCallee(inst)) == TD_EXIT;
|
|
233
|
-
}
|
|
234
195
|
//@}
|
|
235
196
|
|
|
236
197
|
/// Return true if this call acquire a lock
|
|
@@ -239,11 +200,6 @@ public:
|
|
|
239
200
|
{
|
|
240
201
|
return getType(getCallee(inst)) == TD_ACQUIRE;
|
|
241
202
|
}
|
|
242
|
-
|
|
243
|
-
inline bool isTDAcquire(const SVFInstruction* inst) const
|
|
244
|
-
{
|
|
245
|
-
return getType(getCallee(inst)) == TD_ACQUIRE;
|
|
246
|
-
}
|
|
247
203
|
//@}
|
|
248
204
|
|
|
249
205
|
/// Return true if this call release a lock
|
|
@@ -252,11 +208,6 @@ public:
|
|
|
252
208
|
{
|
|
253
209
|
return getType(getCallee(inst)) == TD_RELEASE;
|
|
254
210
|
}
|
|
255
|
-
|
|
256
|
-
inline bool isTDRelease(const SVFInstruction* inst) const
|
|
257
|
-
{
|
|
258
|
-
return getType(getCallee(inst)) == TD_RELEASE;
|
|
259
|
-
}
|
|
260
211
|
//@}
|
|
261
212
|
|
|
262
213
|
/// Return lock value
|
|
@@ -271,11 +222,6 @@ public:
|
|
|
271
222
|
{
|
|
272
223
|
return getType(getCallee(inst)) == TD_BAR_WAIT;
|
|
273
224
|
}
|
|
274
|
-
|
|
275
|
-
inline bool isTDBarWait(const SVFInstruction* inst) const
|
|
276
|
-
{
|
|
277
|
-
return getType(getCallee(inst)) == TD_BAR_WAIT;
|
|
278
|
-
}
|
|
279
225
|
//@}
|
|
280
226
|
|
|
281
227
|
void performAPIStat(SVFModule* m);
|
|
@@ -148,7 +148,7 @@ void BufOverflowDetector::detectExtAPI(AbstractState& as,
|
|
|
148
148
|
SVFIR* svfir = PAG::getPAG();
|
|
149
149
|
const SVFFunction *fun = SVFUtil::getCallee(call->getCallSite());
|
|
150
150
|
assert(fun && "SVFFunction* is nullptr");
|
|
151
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
151
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
152
152
|
|
|
153
153
|
AbstractInterpretation::ExtAPIType extType = AbstractInterpretation::UNCLASSIFIED;
|
|
154
154
|
|
|
@@ -322,7 +322,7 @@ void BufOverflowDetector::updateGepObjOffsetFromBase(SVF::AddressValue gepAddrs,
|
|
|
322
322
|
*/
|
|
323
323
|
bool BufOverflowDetector::detectStrcpy(AbstractState& as, const CallICFGNode *call)
|
|
324
324
|
{
|
|
325
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
325
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
326
326
|
const SVFValue* arg0Val = cs.getArgument(0);
|
|
327
327
|
const SVFValue* arg1Val = cs.getArgument(1);
|
|
328
328
|
IntervalValue strLen = AbstractInterpretation::getAEInstance().getStrlen(as, arg1Val);
|
|
@@ -349,7 +349,7 @@ bool BufOverflowDetector::detectStrcat(AbstractState& as, const CallICFGNode *ca
|
|
|
349
349
|
|
|
350
350
|
if (std::find(strcatGroup.begin(), strcatGroup.end(), fun->getName()) != strcatGroup.end())
|
|
351
351
|
{
|
|
352
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
352
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
353
353
|
const SVFValue* arg0Val = cs.getArgument(0);
|
|
354
354
|
const SVFValue* arg1Val = cs.getArgument(1);
|
|
355
355
|
IntervalValue strLen0 = AbstractInterpretation::getAEInstance().getStrlen(as, arg0Val);
|
|
@@ -359,7 +359,7 @@ bool BufOverflowDetector::detectStrcat(AbstractState& as, const CallICFGNode *ca
|
|
|
359
359
|
}
|
|
360
360
|
else if (std::find(strncatGroup.begin(), strncatGroup.end(), fun->getName()) != strncatGroup.end())
|
|
361
361
|
{
|
|
362
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
362
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
363
363
|
const SVFValue* arg0Val = cs.getArgument(0);
|
|
364
364
|
const SVFValue* arg2Val = cs.getArgument(2);
|
|
365
365
|
IntervalValue arg2Num = as[svfir->getValueNode(arg2Val)].getInterval();
|
|
@@ -1359,7 +1359,7 @@ void AbstractInterpretation::handleExtAPI(const CallICFGNode *call)
|
|
|
1359
1359
|
AbstractState& as = getAbsStateFromTrace(call);
|
|
1360
1360
|
const SVFFunction *fun = SVFUtil::getCallee(call->getCallSite());
|
|
1361
1361
|
assert(fun && "SVFFunction* is nullptr");
|
|
1362
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
1362
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
1363
1363
|
ExtAPIType extType = UNCLASSIFIED;
|
|
1364
1364
|
// get type of mem api
|
|
1365
1365
|
for (const std::string &annotation: fun->getAnnotations())
|
|
@@ -1381,7 +1381,7 @@ void AbstractInterpretation::handleExtAPI(const CallICFGNode *call)
|
|
|
1381
1381
|
}
|
|
1382
1382
|
else
|
|
1383
1383
|
{
|
|
1384
|
-
u32_t lhsId = svfir->getValueNode(SVFUtil::getSVFCallSite(call
|
|
1384
|
+
u32_t lhsId = svfir->getValueNode(SVFUtil::getSVFCallSite(call).getInstruction());
|
|
1385
1385
|
if (as.inVarToAddrsTable(lhsId))
|
|
1386
1386
|
{
|
|
1387
1387
|
|
|
@@ -1463,7 +1463,7 @@ void AbstractInterpretation::handleStrcpy(const CallICFGNode *call)
|
|
|
1463
1463
|
// strcpy, __strcpy_chk, stpcpy , wcscpy, __wcscpy_chk
|
|
1464
1464
|
// get the dst and src
|
|
1465
1465
|
AbstractState& as = getAbsStateFromTrace(call);
|
|
1466
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
1466
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
1467
1467
|
const SVFValue* arg0Val = cs.getArgument(0);
|
|
1468
1468
|
const SVFValue* arg1Val = cs.getArgument(1);
|
|
1469
1469
|
IntervalValue strLen = getStrlen(as, arg1Val);
|
|
@@ -1553,12 +1553,12 @@ void AbstractInterpretation::handleStrcat(const SVF::CallICFGNode *call)
|
|
|
1553
1553
|
// __strcat_chk, strcat, __wcscat_chk, wcscat, __strncat_chk, strncat, __wcsncat_chk, wcsncat
|
|
1554
1554
|
// to check it is strcat group or strncat group
|
|
1555
1555
|
AbstractState& as = getAbsStateFromTrace(call);
|
|
1556
|
-
const SVFFunction *fun = SVFUtil::getCallee(call
|
|
1556
|
+
const SVFFunction *fun = SVFUtil::getCallee(call);
|
|
1557
1557
|
const std::vector<std::string> strcatGroup = {"__strcat_chk", "strcat", "__wcscat_chk", "wcscat"};
|
|
1558
1558
|
const std::vector<std::string> strncatGroup = {"__strncat_chk", "strncat", "__wcsncat_chk", "wcsncat"};
|
|
1559
1559
|
if (std::find(strcatGroup.begin(), strcatGroup.end(), fun->getName()) != strcatGroup.end())
|
|
1560
1560
|
{
|
|
1561
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
1561
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
1562
1562
|
const SVFValue* arg0Val = cs.getArgument(0);
|
|
1563
1563
|
const SVFValue* arg1Val = cs.getArgument(1);
|
|
1564
1564
|
IntervalValue strLen0 = getStrlen(as, arg0Val);
|
|
@@ -1569,7 +1569,7 @@ void AbstractInterpretation::handleStrcat(const SVF::CallICFGNode *call)
|
|
|
1569
1569
|
}
|
|
1570
1570
|
else if (std::find(strncatGroup.begin(), strncatGroup.end(), fun->getName()) != strncatGroup.end())
|
|
1571
1571
|
{
|
|
1572
|
-
CallSite cs = SVFUtil::getSVFCallSite(call
|
|
1572
|
+
CallSite cs = SVFUtil::getSVFCallSite(call);
|
|
1573
1573
|
const SVFValue* arg0Val = cs.getArgument(0);
|
|
1574
1574
|
const SVFValue* arg1Val = cs.getArgument(1);
|
|
1575
1575
|
const SVFValue* arg2Val = cs.getArgument(2);
|
package/svf/lib/CFL/CFLAlias.cpp
CHANGED
|
@@ -42,9 +42,9 @@ void CFLAlias::onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites, Call
|
|
|
42
42
|
{
|
|
43
43
|
const CallICFGNode* cs = iter->first;
|
|
44
44
|
|
|
45
|
-
if (SVFUtil::getSVFCallSite(cs
|
|
45
|
+
if (SVFUtil::getSVFCallSite(cs).isVirtualCall())
|
|
46
46
|
{
|
|
47
|
-
const SVFValue* vtbl = SVFUtil::getSVFCallSite(cs
|
|
47
|
+
const SVFValue* vtbl = SVFUtil::getSVFCallSite(cs).getVtablePtr();
|
|
48
48
|
assert(pag->hasValueNode(vtbl));
|
|
49
49
|
NodeID vtblId = pag->getValueNode(vtbl);
|
|
50
50
|
resolveCPPIndCalls(cs, getCFLPts(vtblId), newEdges);
|
|
@@ -175,7 +175,7 @@ bool CFLAlias::updateCallGraph(const CallSiteToFunPtrMap& callsites)
|
|
|
175
175
|
onTheFlyCallGraphSolve(callsites,newEdges);
|
|
176
176
|
for(CallEdgeMap::iterator it = newEdges.begin(), eit = newEdges.end(); it!=eit; ++it )
|
|
177
177
|
{
|
|
178
|
-
CallSite cs = SVFUtil::getSVFCallSite(it->first
|
|
178
|
+
CallSite cs = SVFUtil::getSVFCallSite(it->first);
|
|
179
179
|
for(FunctionSet::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
|
|
180
180
|
{
|
|
181
181
|
connectCaller2CalleeParams(cs,*cit);
|
|
@@ -81,9 +81,9 @@ OrderedNodeSet& FunptrDDAClient::collectCandidateQueries(SVFIR* p)
|
|
|
81
81
|
for(SVFIR::CallSiteToFunPtrMap::const_iterator it = pag->getIndirectCallsites().begin(),
|
|
82
82
|
eit = pag->getIndirectCallsites().end(); it!=eit; ++it)
|
|
83
83
|
{
|
|
84
|
-
if (SVFUtil::getSVFCallSite(it->first
|
|
84
|
+
if (SVFUtil::getSVFCallSite(it->first).isVirtualCall())
|
|
85
85
|
{
|
|
86
|
-
const SVFValue* vtblPtr = SVFUtil::getSVFCallSite(it->first
|
|
86
|
+
const SVFValue* vtblPtr = SVFUtil::getSVFCallSite(it->first).getVtablePtr();
|
|
87
87
|
assert(pag->hasValueNode(vtblPtr) && "not a vtable pointer?");
|
|
88
88
|
NodeID vtblId = pag->getValueNode(vtblPtr);
|
|
89
89
|
addCandidate(vtblId);
|
|
@@ -51,7 +51,7 @@ void CallGraphEdge::addDirectCallSite(const CallICFGNode* call)
|
|
|
51
51
|
|
|
52
52
|
void CallGraphEdge::addInDirectCallSite(const CallICFGNode* call)
|
|
53
53
|
{
|
|
54
|
-
assert((nullptr == SVFUtil::getCallee(call->getCallSite()) || nullptr == SVFUtil::dyn_cast<SVFFunction> (SVFUtil::getForkedFun(call
|
|
54
|
+
assert((nullptr == SVFUtil::getCallee(call->getCallSite()) || nullptr == SVFUtil::dyn_cast<SVFFunction> (SVFUtil::getForkedFun(call))) && "not an indirect callsite??");
|
|
55
55
|
indirectCalls.insert(call);
|
|
56
56
|
}
|
|
57
57
|
//@}
|
|
@@ -273,13 +273,11 @@ struct DOTGraphTraits<IRGraph*> : public DefaultDOTGraphTraits
|
|
|
273
273
|
assert(edge && "No edge found!!");
|
|
274
274
|
if(const CallPE* calledge = SVFUtil::dyn_cast<CallPE>(edge))
|
|
275
275
|
{
|
|
276
|
-
|
|
277
|
-
return callInst->getSourceLoc();
|
|
276
|
+
return calledge->getCallSite()->getSourceLoc();
|
|
278
277
|
}
|
|
279
278
|
else if(const RetPE* retedge = SVFUtil::dyn_cast<RetPE>(edge))
|
|
280
279
|
{
|
|
281
|
-
|
|
282
|
-
return callInst->getSourceLoc();
|
|
280
|
+
return retedge->getCallSite()->getSourceLoc();
|
|
283
281
|
}
|
|
284
282
|
return "";
|
|
285
283
|
}
|
|
@@ -70,7 +70,7 @@ void ThreadCallGraph::updateCallGraph(PointerAnalysis* pta)
|
|
|
70
70
|
// Fork sites
|
|
71
71
|
for (CallSiteSet::const_iterator it = forksitesBegin(), eit = forksitesEnd(); it != eit; ++it)
|
|
72
72
|
{
|
|
73
|
-
const SVFValue* forkedval = tdAPI->getForkedFun(
|
|
73
|
+
const SVFValue* forkedval = tdAPI->getForkedFun(*it);
|
|
74
74
|
if(SVFUtil::dyn_cast<SVFFunction>(forkedval)==nullptr)
|
|
75
75
|
{
|
|
76
76
|
SVFIR* pag = pta->getPAG();
|
|
@@ -105,7 +105,7 @@ void ThreadCallGraph::updateJoinEdge(PointerAnalysis* pta)
|
|
|
105
105
|
CallSiteSet forkset;
|
|
106
106
|
for (CallSiteSet::const_iterator it = forksitesBegin(), eit = forksitesEnd(); it != eit; ++it)
|
|
107
107
|
{
|
|
108
|
-
const SVFValue* forkthread = tdAPI->getForkedThread(
|
|
108
|
+
const SVFValue* forkthread = tdAPI->getForkedThread(*it);
|
|
109
109
|
if (pta->alias(jointhread, forkthread))
|
|
110
110
|
{
|
|
111
111
|
forkset.insert(*it);
|
|
@@ -123,7 +123,7 @@ void ThreadCallGraph::addDirectForkEdge(const CallICFGNode* cs)
|
|
|
123
123
|
{
|
|
124
124
|
|
|
125
125
|
CallGraphNode* caller = getCallGraphNode(cs->getCaller());
|
|
126
|
-
const SVFFunction* forkee = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getForkedFun(cs
|
|
126
|
+
const SVFFunction* forkee = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getForkedFun(cs));
|
|
127
127
|
assert(forkee && "callee does not exist");
|
|
128
128
|
CallGraphNode* callee = getCallGraphNode(forkee->getDefFunForMultipleModule());
|
|
129
129
|
CallSiteID csId = addCallSite(cs, callee->getFunction());
|
|
@@ -176,7 +176,7 @@ void ThreadCallGraph::addDirectJoinEdge(const CallICFGNode* cs,const CallSiteSet
|
|
|
176
176
|
for (CallSiteSet::const_iterator it = forkset.begin(), eit = forkset.end(); it != eit; ++it)
|
|
177
177
|
{
|
|
178
178
|
|
|
179
|
-
const SVFFunction* threadRoutineFun = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getForkedFun(
|
|
179
|
+
const SVFFunction* threadRoutineFun = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getForkedFun(*it));
|
|
180
180
|
assert(threadRoutineFun && "thread routine function does not exist");
|
|
181
181
|
CallGraphNode* threadRoutineFunNode = getCallGraphNode(threadRoutineFun);
|
|
182
182
|
CallSiteID csId = addCallSite(cs, threadRoutineFun);
|
package/svf/lib/Graphs/VFG.cpp
CHANGED
|
@@ -979,7 +979,7 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const SVFFun
|
|
|
979
979
|
RetICFGNode* retBlockNode = icfg->getRetICFGNode(callBlockNode->getCallSite());
|
|
980
980
|
// connect actual and formal param
|
|
981
981
|
if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee) &&
|
|
982
|
-
matchArgs(callBlockNode
|
|
982
|
+
matchArgs(callBlockNode, callee))
|
|
983
983
|
{
|
|
984
984
|
const SVFIR::SVFVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
|
|
985
985
|
const SVFIR::SVFVarList& funArgList = pag->getFunArgsList(callee);
|
|
@@ -286,7 +286,7 @@ void LockAnalysis::collectCxtLock()
|
|
|
286
286
|
DBOUT(DMTA,
|
|
287
287
|
outs() << "\nCollecting CxtLocks: handling direct call:" << **cit << "\t" << cgEdge->getSrcNode()->getFunction()->getName()
|
|
288
288
|
<< "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n");
|
|
289
|
-
handleCallRelation(clp, cgEdge,
|
|
289
|
+
handleCallRelation(clp, cgEdge, *cit);
|
|
290
290
|
}
|
|
291
291
|
for (CallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(), eind = cgEdge->indirectCallsEnd();
|
|
292
292
|
ind != eind; ++ind)
|
|
@@ -295,7 +295,7 @@ void LockAnalysis::collectCxtLock()
|
|
|
295
295
|
outs() << "\nCollecting CxtLocks: handling indirect call:" << **ind << "\t"
|
|
296
296
|
<< cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName()
|
|
297
297
|
<< "\n");
|
|
298
|
-
handleCallRelation(clp, cgEdge,
|
|
298
|
+
handleCallRelation(clp, cgEdge, *ind);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
}
|
|
@@ -305,11 +305,11 @@ void LockAnalysis::collectCxtLock()
|
|
|
305
305
|
/*!
|
|
306
306
|
* Handling call relations when collecting context-sensitive locks
|
|
307
307
|
*/
|
|
308
|
-
void LockAnalysis::handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge,
|
|
308
|
+
void LockAnalysis::handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge, const CallICFGNode* cs)
|
|
309
309
|
{
|
|
310
310
|
|
|
311
311
|
CallStrCxt cxt(clp.getContext());
|
|
312
|
-
const ICFGNode* curNode =
|
|
312
|
+
const ICFGNode* curNode = cs;
|
|
313
313
|
if (isTDAcquire(curNode))
|
|
314
314
|
{
|
|
315
315
|
addCxtLock(cxt,curNode);
|
package/svf/lib/MTA/MHP.cpp
CHANGED
|
@@ -912,7 +912,7 @@ void ForkJoinAnalysis::handleRet(const CxtStmt& cts)
|
|
|
912
912
|
cit != ecit; ++cit)
|
|
913
913
|
{
|
|
914
914
|
CallStrCxt newCxt = curCxt;
|
|
915
|
-
const ICFGNode* curNode =
|
|
915
|
+
const ICFGNode* curNode = (*cit);
|
|
916
916
|
if (matchCxt(newCxt, SVFUtil::cast<CallICFGNode>(curNode), curFunNode->getFunction()))
|
|
917
917
|
{
|
|
918
918
|
for(const ICFGEdge* outEdge : curNode->getOutEdges())
|
|
@@ -930,7 +930,7 @@ void ForkJoinAnalysis::handleRet(const CxtStmt& cts)
|
|
|
930
930
|
cit != ecit; ++cit)
|
|
931
931
|
{
|
|
932
932
|
CallStrCxt newCxt = curCxt;
|
|
933
|
-
const ICFGNode* curNode =
|
|
933
|
+
const ICFGNode* curNode = (*cit);
|
|
934
934
|
|
|
935
935
|
if (matchCxt(newCxt, SVFUtil::cast<CallICFGNode>(curNode), curFunNode->getFunction()))
|
|
936
936
|
{
|
package/svf/lib/MTA/MTA.cpp
CHANGED
|
@@ -135,7 +135,6 @@ void MTA::detect(SVFModule* module)
|
|
|
135
135
|
SVFIR* pag = SVFIR::getPAG();
|
|
136
136
|
PointerAnalysis* pta = AndersenWaveDiff::createAndersenWaveDiff(pag);
|
|
137
137
|
|
|
138
|
-
Set<const SVFInstruction*> needcheckinst;
|
|
139
138
|
// Add symbols for all of the functions and the instructions in them.
|
|
140
139
|
for (const SVFFunction* F : module->getFunctionSet())
|
|
141
140
|
{
|
package/svf/lib/MTA/MTAStat.cpp
CHANGED
|
@@ -49,7 +49,7 @@ void MTAStat::performThreadCallGraphStat(ThreadCallGraph* tcg)
|
|
|
49
49
|
for (ThreadCallGraph::CallSiteSet::const_iterator it = tcg->forksitesBegin(), eit = tcg->forksitesEnd(); it != eit; ++it)
|
|
50
50
|
{
|
|
51
51
|
bool indirectfork = false;
|
|
52
|
-
const SVFFunction* spawnee = SVFUtil::dyn_cast<SVFFunction>(tcg->getThreadAPI()->getForkedFun(
|
|
52
|
+
const SVFFunction* spawnee = SVFUtil::dyn_cast<SVFFunction>(tcg->getThreadAPI()->getForkedFun(*it));
|
|
53
53
|
if(spawnee==nullptr)
|
|
54
54
|
{
|
|
55
55
|
numOfIndForksite++;
|
package/svf/lib/MTA/TCT.cpp
CHANGED
|
@@ -240,13 +240,13 @@ void TCT::collectMultiForkedThreads()
|
|
|
240
240
|
/*!
|
|
241
241
|
* Handle call relations
|
|
242
242
|
*/
|
|
243
|
-
void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge,
|
|
243
|
+
void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, const CallICFGNode* cs)
|
|
244
244
|
{
|
|
245
245
|
const SVFFunction* callee = cgEdge->getDstNode()->getFunction();
|
|
246
246
|
|
|
247
247
|
CallStrCxt cxt(ctp.getContext());
|
|
248
248
|
CallStrCxt oldCxt = cxt;
|
|
249
|
-
const CallICFGNode* callNode =
|
|
249
|
+
const CallICFGNode* callNode = cs;
|
|
250
250
|
pushCxt(cxt,callNode,callee);
|
|
251
251
|
|
|
252
252
|
if(cgEdge->getEdgeKind() == CallGraphEdge::CallRetEdge)
|
|
@@ -416,13 +416,13 @@ void TCT::build()
|
|
|
416
416
|
ecit = cgEdge->directCallsEnd(); cit!=ecit; ++cit)
|
|
417
417
|
{
|
|
418
418
|
DBOUT(DMTA,outs() << "\nTCT handling direct call:" << **cit << "\t" << cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n");
|
|
419
|
-
handleCallRelation(ctp,cgEdge
|
|
419
|
+
handleCallRelation(ctp,cgEdge,*cit);
|
|
420
420
|
}
|
|
421
421
|
for(CallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(),
|
|
422
422
|
eind = cgEdge->indirectCallsEnd(); ind!=eind; ++ind)
|
|
423
423
|
{
|
|
424
424
|
DBOUT(DMTA,outs() << "\nTCT handling indirect call:" << **ind << "\t" << cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n");
|
|
425
|
-
handleCallRelation(ctp,cgEdge
|
|
425
|
+
handleCallRelation(ctp,cgEdge,*ind);
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
}
|
|
@@ -404,7 +404,7 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta
|
|
|
404
404
|
const SVFFunction* calleefun = SVFUtil::cast<SVFFunction>(obj->getValue());
|
|
405
405
|
const SVFFunction* callee = calleefun->getDefFunForMultipleModule();
|
|
406
406
|
|
|
407
|
-
if(SVFUtil::matchArgs(cs
|
|
407
|
+
if(SVFUtil::matchArgs(cs, callee) == false)
|
|
408
408
|
continue;
|
|
409
409
|
|
|
410
410
|
if(0 == getIndCallMap()[cs].count(callee))
|
|
@@ -428,8 +428,8 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta
|
|
|
428
428
|
*/
|
|
429
429
|
void PointerAnalysis::getVFnsFromCHA(const CallICFGNode* cs, VFunSet &vfns)
|
|
430
430
|
{
|
|
431
|
-
if (chgraph->csHasVFnsBasedonCHA(SVFUtil::getSVFCallSite(cs
|
|
432
|
-
vfns = chgraph->getCSVFsBasedonCHA(SVFUtil::getSVFCallSite(cs
|
|
431
|
+
if (chgraph->csHasVFnsBasedonCHA(SVFUtil::getSVFCallSite(cs)))
|
|
432
|
+
vfns = chgraph->getCSVFsBasedonCHA(SVFUtil::getSVFCallSite(cs));
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/*
|
|
@@ -438,10 +438,10 @@ void PointerAnalysis::getVFnsFromCHA(const CallICFGNode* cs, VFunSet &vfns)
|
|
|
438
438
|
void PointerAnalysis::getVFnsFromPts(const CallICFGNode* cs, const PointsTo &target, VFunSet &vfns)
|
|
439
439
|
{
|
|
440
440
|
|
|
441
|
-
if (chgraph->csHasVtblsBasedonCHA(SVFUtil::getSVFCallSite(cs
|
|
441
|
+
if (chgraph->csHasVtblsBasedonCHA(SVFUtil::getSVFCallSite(cs)))
|
|
442
442
|
{
|
|
443
443
|
Set<const SVFGlobalValue*> vtbls;
|
|
444
|
-
const VTableSet &chaVtbls = chgraph->getCSVtblsBasedonCHA(SVFUtil::getSVFCallSite(cs
|
|
444
|
+
const VTableSet &chaVtbls = chgraph->getCSVtblsBasedonCHA(SVFUtil::getSVFCallSite(cs));
|
|
445
445
|
for (PointsTo::iterator it = target.begin(), eit = target.end(); it != eit; ++it)
|
|
446
446
|
{
|
|
447
447
|
const PAGNode *ptdnode = pag->getGNode(*it);
|
|
@@ -454,7 +454,7 @@ void PointerAnalysis::getVFnsFromPts(const CallICFGNode* cs, const PointsTo &tar
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
-
chgraph->getVFnsFromVtbls(SVFUtil::getSVFCallSite(cs
|
|
457
|
+
chgraph->getVFnsFromVtbls(SVFUtil::getSVFCallSite(cs), vtbls, vfns);
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
|
|
@@ -471,8 +471,8 @@ void PointerAnalysis::connectVCallToVFns(const CallICFGNode* cs, const VFunSet &
|
|
|
471
471
|
callee = callee->getDefFunForMultipleModule();
|
|
472
472
|
if (getIndCallMap()[cs].count(callee) > 0)
|
|
473
473
|
continue;
|
|
474
|
-
if(SVFUtil::getSVFCallSite(cs
|
|
475
|
-
(SVFUtil::getSVFCallSite(cs
|
|
474
|
+
if(SVFUtil::getSVFCallSite(cs).arg_size() == callee->arg_size() ||
|
|
475
|
+
(SVFUtil::getSVFCallSite(cs).isVarArg() && callee->isVarArg()))
|
|
476
476
|
{
|
|
477
477
|
newEdges[cs].insert(callee);
|
|
478
478
|
getIndCallMap()[cs].insert(callee);
|
|
@@ -485,7 +485,7 @@ void PointerAnalysis::connectVCallToVFns(const CallICFGNode* cs, const VFunSet &
|
|
|
485
485
|
/// Resolve cpp indirect call edges
|
|
486
486
|
void PointerAnalysis::resolveCPPIndCalls(const CallICFGNode* cs, const PointsTo& target, CallEdgeMap& newEdges)
|
|
487
487
|
{
|
|
488
|
-
assert(SVFUtil::getSVFCallSite(cs
|
|
488
|
+
assert(SVFUtil::getSVFCallSite(cs).isVirtualCall() && "not cpp virtual call");
|
|
489
489
|
|
|
490
490
|
VFunSet vfns;
|
|
491
491
|
if (Options::ConnectVCallOnCHA())
|
|
@@ -509,11 +509,9 @@ void PointerAnalysis::validateSuccessTests(std::string fun)
|
|
|
509
509
|
|
|
510
510
|
for(const CallICFGNode* callNode : pag->getCallSiteSet())
|
|
511
511
|
{
|
|
512
|
-
|
|
513
|
-
if (SVFUtil::getCallee(svfInst) == checkFun)
|
|
512
|
+
if (SVFUtil::getCallee(callNode) == checkFun)
|
|
514
513
|
{
|
|
515
|
-
|
|
516
|
-
CallSite cs(svfInst);
|
|
514
|
+
CallSite cs = SVFUtil::getSVFCallSite(callNode);
|
|
517
515
|
assert(cs.getNumArgOperands() == 2
|
|
518
516
|
&& "arguments should be two pointers!!");
|
|
519
517
|
const SVFValue* V1 = cs.getArgOperand(0);
|
|
@@ -551,12 +549,12 @@ void PointerAnalysis::validateSuccessTests(std::string fun)
|
|
|
551
549
|
|
|
552
550
|
if (checkSuccessful)
|
|
553
551
|
outs() << sucMsg("\t SUCCESS :") << fun << " check <id:" << id1 << ", id:" << id2 << "> at ("
|
|
554
|
-
<<
|
|
552
|
+
<< callNode->getSourceLoc() << ")\n";
|
|
555
553
|
else
|
|
556
554
|
{
|
|
557
555
|
SVFUtil::errs() << errMsg("\t FAILURE :") << fun
|
|
558
556
|
<< " check <id:" << id1 << ", id:" << id2
|
|
559
|
-
<< "> at (" <<
|
|
557
|
+
<< "> at (" << callNode->getSourceLoc() << ")\n";
|
|
560
558
|
assert(false && "test case failed!");
|
|
561
559
|
}
|
|
562
560
|
}
|
|
@@ -577,10 +575,9 @@ void PointerAnalysis::validateExpectedFailureTests(std::string fun)
|
|
|
577
575
|
|
|
578
576
|
for(const CallICFGNode* callNode : pag->getCallSiteSet())
|
|
579
577
|
{
|
|
580
|
-
|
|
581
|
-
if (SVFUtil::getCallee(svfInst) == checkFun)
|
|
578
|
+
if (SVFUtil::getCallee(callNode) == checkFun)
|
|
582
579
|
{
|
|
583
|
-
CallSite call = getSVFCallSite(
|
|
580
|
+
CallSite call = getSVFCallSite(callNode);
|
|
584
581
|
assert(call.arg_size() == 2
|
|
585
582
|
&& "arguments should be two pointers!!");
|
|
586
583
|
const SVFValue* V1 = call.getArgOperand(0);
|
|
@@ -495,9 +495,9 @@ void BVDataPTAImpl::onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites,
|
|
|
495
495
|
{
|
|
496
496
|
const CallICFGNode* cs = iter->first;
|
|
497
497
|
|
|
498
|
-
if (SVFUtil::getSVFCallSite(cs
|
|
498
|
+
if (SVFUtil::getSVFCallSite(cs).isVirtualCall())
|
|
499
499
|
{
|
|
500
|
-
const SVFValue* vtbl = SVFUtil::getSVFCallSite(cs
|
|
500
|
+
const SVFValue* vtbl = SVFUtil::getSVFCallSite(cs).getVtablePtr();
|
|
501
501
|
assert(pag->hasValueNode(vtbl));
|
|
502
502
|
NodeID vtblId = pag->getValueNode(vtbl);
|
|
503
503
|
resolveCPPIndCalls(cs, getPts(vtblId), newEdges);
|
|
@@ -42,7 +42,7 @@ void DoubleFreeChecker::reportBug(ProgSlice* slice)
|
|
|
42
42
|
GenericBug::EventStack eventStack;
|
|
43
43
|
slice->evalFinalCond2Event(eventStack);
|
|
44
44
|
eventStack.push_back(
|
|
45
|
-
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())
|
|
45
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())));
|
|
46
46
|
report.addSaberBug(GenericBug::DOUBLEFREE, eventStack);
|
|
47
47
|
}
|
|
48
48
|
if(Options::ValidateTests())
|
|
@@ -39,10 +39,7 @@ void FileChecker::reportBug(ProgSlice* slice)
|
|
|
39
39
|
if(isAllPathReachable() == false && isSomePathReachable() == false)
|
|
40
40
|
{
|
|
41
41
|
// full leakage
|
|
42
|
-
GenericBug::EventStack eventStack =
|
|
43
|
-
{
|
|
44
|
-
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())->getCallSite())
|
|
45
|
-
};
|
|
42
|
+
GenericBug::EventStack eventStack = { SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())) };
|
|
46
43
|
report.addSaberBug(GenericBug::FILENEVERCLOSE, eventStack);
|
|
47
44
|
}
|
|
48
45
|
else if (isAllPathReachable() == false && isSomePathReachable() == true)
|
|
@@ -50,7 +47,7 @@ void FileChecker::reportBug(ProgSlice* slice)
|
|
|
50
47
|
GenericBug::EventStack eventStack;
|
|
51
48
|
slice->evalFinalCond2Event(eventStack);
|
|
52
49
|
eventStack.push_back(
|
|
53
|
-
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())
|
|
50
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())));
|
|
54
51
|
report.addSaberBug(GenericBug::FILEPARTIALCLOSE, eventStack);
|
|
55
52
|
}
|
|
56
53
|
}
|
|
@@ -154,7 +154,7 @@ void LeakChecker::reportBug(ProgSlice* slice)
|
|
|
154
154
|
// full leakage
|
|
155
155
|
GenericBug::EventStack eventStack =
|
|
156
156
|
{
|
|
157
|
-
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())
|
|
157
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource()))
|
|
158
158
|
};
|
|
159
159
|
report.addSaberBug(GenericBug::NEVERFREE, eventStack);
|
|
160
160
|
}
|
|
@@ -164,7 +164,7 @@ void LeakChecker::reportBug(ProgSlice* slice)
|
|
|
164
164
|
GenericBug::EventStack eventStack;
|
|
165
165
|
slice->evalFinalCond2Event(eventStack);
|
|
166
166
|
eventStack.push_back(
|
|
167
|
-
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())
|
|
167
|
+
SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())));
|
|
168
168
|
report.addSaberBug(GenericBug::PARTIALLEAK, eventStack);
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -198,7 +198,7 @@ void ProgSlice::evalFinalCond2Event(GenericBug::EventStack &eventStack) const
|
|
|
198
198
|
NodeBS elems = pathAllocator->exactCondElem(finalCond);
|
|
199
199
|
for(NodeBS::iterator it = elems.begin(), eit = elems.end(); it!=eit; ++it)
|
|
200
200
|
{
|
|
201
|
-
const
|
|
201
|
+
const ICFGNode* tinst = pathAllocator->getCondInst(*it);
|
|
202
202
|
if(pathAllocator->isNegCond(*it))
|
|
203
203
|
eventStack.push_back(SVFBugEvent(
|
|
204
204
|
SVFBugEvent::Branch|((((u32_t)false) << 4) & BRANCHFLAGMASK), tinst));
|
|
@@ -226,7 +226,7 @@ std::string ProgSlice::evalFinalCond() const
|
|
|
226
226
|
|
|
227
227
|
for(NodeBS::iterator it = elems.begin(), eit = elems.end(); it!=eit; ++it)
|
|
228
228
|
{
|
|
229
|
-
const
|
|
229
|
+
const ICFGNode* tinst = pathAllocator->getCondInst(*it);
|
|
230
230
|
if(pathAllocator->isNegCond(*it))
|
|
231
231
|
locations.insert(tinst->getSourceLoc()+"|False");
|
|
232
232
|
else
|
|
@@ -99,7 +99,7 @@ void SaberCondAllocator::allocateForBB(const SVFBasicBlock &bb)
|
|
|
99
99
|
std::vector<Condition> condVec;
|
|
100
100
|
for (u32_t i = 0; i < bit_num; i++)
|
|
101
101
|
{
|
|
102
|
-
const
|
|
102
|
+
const IntraICFGNode* svfInst = cast<IntraICFGNode>(bb.back());
|
|
103
103
|
condVec.push_back(newCond(svfInst));
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -593,7 +593,7 @@ void SaberCondAllocator::printPathCond()
|
|
|
593
593
|
}
|
|
594
594
|
|
|
595
595
|
/// Allocate a new condition
|
|
596
|
-
SaberCondAllocator::Condition SaberCondAllocator::newCond(const
|
|
596
|
+
SaberCondAllocator::Condition SaberCondAllocator::newCond(const ICFGNode* inst)
|
|
597
597
|
{
|
|
598
598
|
u32_t condCountIdx = totalCondNum++;
|
|
599
599
|
Condition expr = Condition::getContext().bool_const(("c" + std::to_string(condCountIdx)).c_str());
|
|
@@ -84,7 +84,7 @@ CallGraph* ThreadCallGraphBuilder::buildThreadCallGraph(SVFModule* svfModule)
|
|
|
84
84
|
{
|
|
85
85
|
const CallICFGNode* cs = cast<CallICFGNode>(inst);
|
|
86
86
|
cg->addForksite(cs);
|
|
87
|
-
const SVFFunction* forkee = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getForkedFun(
|
|
87
|
+
const SVFFunction* forkee = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getForkedFun(cs));
|
|
88
88
|
if (forkee)
|
|
89
89
|
{
|
|
90
90
|
cg->addDirectForkEdge(cs);
|
|
@@ -276,7 +276,7 @@ void PartialNullPtrDereferenceBug::printBugToTerminal() const
|
|
|
276
276
|
|
|
277
277
|
const std::string SVFBugEvent::getFuncName() const
|
|
278
278
|
{
|
|
279
|
-
return eventInst->
|
|
279
|
+
return eventInst->getFun()->getName();
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
const std::string SVFBugEvent::getEventLoc() const
|
package/svf/lib/Util/SVFUtil.cpp
CHANGED
|
@@ -317,9 +317,10 @@ void SVFUtil::stopAnalysisLimitTimer(bool limitTimerSet)
|
|
|
317
317
|
/// unless the callee is a variadic function (the first parameter of variadic function is its parameter number)
|
|
318
318
|
/// e.g., void variadicFoo(int num, ...); variadicFoo(5, 1,2,3,4,5)
|
|
319
319
|
/// for variadic function, callsite arg size must be greater than or equal to callee arg size
|
|
320
|
-
bool SVFUtil::matchArgs(const
|
|
320
|
+
bool SVFUtil::matchArgs(const CallICFGNode* call, const SVFFunction* callee)
|
|
321
321
|
{
|
|
322
|
-
|
|
322
|
+
CallSite cs(call->getCallSite());
|
|
323
|
+
if (callee->isVarArg() || ThreadAPI::getThreadAPI()->isTDFork(call))
|
|
323
324
|
return cs.arg_size() >= callee->arg_size();
|
|
324
325
|
else
|
|
325
326
|
return cs.arg_size() == callee->arg_size();
|
|
@@ -330,6 +331,13 @@ bool SVFUtil::isCallSite(const ICFGNode* inst)
|
|
|
330
331
|
return SVFUtil::isa<CallICFGNode>(inst);
|
|
331
332
|
}
|
|
332
333
|
|
|
334
|
+
CallSite SVFUtil::getSVFCallSite(const ICFGNode* inst)
|
|
335
|
+
{
|
|
336
|
+
assert(isCallSite(inst) && "not a callsite?");
|
|
337
|
+
CallSite cs(cast<CallICFGNode>(inst)->getCallSite());
|
|
338
|
+
return cs;
|
|
339
|
+
}
|
|
340
|
+
|
|
333
341
|
bool SVFUtil::isIntrinsicInst(const ICFGNode* inst)
|
|
334
342
|
{
|
|
335
343
|
if (const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
|
|
@@ -140,15 +140,6 @@ const SVFFunction* ThreadAPI::getCallee(const ICFGNode *inst) const
|
|
|
140
140
|
return nullptr;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/*!
|
|
144
|
-
*
|
|
145
|
-
*/
|
|
146
|
-
const SVFFunction* ThreadAPI::getCallee(const SVFInstruction *inst) const
|
|
147
|
-
{
|
|
148
|
-
return SVFUtil::getCallee(inst);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
143
|
const CallSite ThreadAPI::getSVFCallSite(const ICFGNode *inst) const
|
|
153
144
|
{
|
|
154
145
|
assert(SVFUtil::isa<CallICFGNode>(inst) && "not a callsite?");
|
|
@@ -160,19 +151,11 @@ const SVFValue* ThreadAPI::getLockVal(const ICFGNode *inst) const
|
|
|
160
151
|
{
|
|
161
152
|
const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst);
|
|
162
153
|
assert(call && "not a call ICFGNode?");
|
|
163
|
-
assert((isTDAcquire(call
|
|
164
|
-
CallSite cs = getSVFCallSite(call
|
|
154
|
+
assert((isTDAcquire(call) || isTDRelease(call)) && "not a lock acquire or release function");
|
|
155
|
+
CallSite cs = getSVFCallSite(call);
|
|
165
156
|
return cs.getArgument(0);
|
|
166
157
|
}
|
|
167
158
|
|
|
168
|
-
/*!
|
|
169
|
-
*
|
|
170
|
-
*/
|
|
171
|
-
const CallSite ThreadAPI::getSVFCallSite(const SVFInstruction *inst) const
|
|
172
|
-
{
|
|
173
|
-
return SVFUtil::getSVFCallSite(inst);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
159
|
const SVFValue* ThreadAPI::getJoinedThread(const ICFGNode *inst) const
|
|
177
160
|
{
|
|
178
161
|
assert(isTDJoin(inst) && "not a thread join function!");
|
package/svf/lib/WPA/Andersen.cpp
CHANGED
|
@@ -661,7 +661,7 @@ bool Andersen::updateCallGraph(const CallSiteToFunPtrMap& callsites)
|
|
|
661
661
|
NodePairSet cpySrcNodes; /// nodes as a src of a generated new copy edge
|
|
662
662
|
for(CallEdgeMap::iterator it = newEdges.begin(), eit = newEdges.end(); it!=eit; ++it )
|
|
663
663
|
{
|
|
664
|
-
CallSite cs = SVFUtil::getSVFCallSite(it->first
|
|
664
|
+
CallSite cs = SVFUtil::getSVFCallSite(it->first);
|
|
665
665
|
for(FunctionSet::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
|
|
666
666
|
{
|
|
667
667
|
connectCaller2CalleeParams(cs,*cit,cpySrcNodes);
|
|
@@ -281,7 +281,7 @@ bool AndersenSCD::updateCallGraph(const PointerAnalysis::CallSiteToFunPtrMap& ca
|
|
|
281
281
|
NodePairSet cpySrcNodes; /// nodes as a src of a generated new copy edge
|
|
282
282
|
for(CallEdgeMap::iterator it = newEdges.begin(), eit = newEdges.end(); it!=eit; ++it )
|
|
283
283
|
{
|
|
284
|
-
CallSite cs = SVFUtil::getSVFCallSite(it->first
|
|
284
|
+
CallSite cs = SVFUtil::getSVFCallSite(it->first);
|
|
285
285
|
for(FunctionSet::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
|
|
286
286
|
{
|
|
287
287
|
connectCaller2CalleeParams(cs,*cit,cpySrcNodes);
|
|
@@ -135,7 +135,7 @@ bool Steensgaard::updateCallGraph(const CallSiteToFunPtrMap& callsites)
|
|
|
135
135
|
for (CallEdgeMap::iterator it = newEdges.begin(), eit = newEdges.end();
|
|
136
136
|
it != eit; ++it)
|
|
137
137
|
{
|
|
138
|
-
CallSite cs = SVFUtil::getSVFCallSite(it->first
|
|
138
|
+
CallSite cs = SVFUtil::getSVFCallSite(it->first);
|
|
139
139
|
for (FunctionSet::iterator cit = it->second.begin(),
|
|
140
140
|
ecit = it->second.end();
|
|
141
141
|
cit != ecit; ++cit)
|
|
@@ -77,7 +77,7 @@ void TypeAnalysis::callGraphSolveBasedOnCHA(const CallSiteToFunPtrMap& callsites
|
|
|
77
77
|
for(CallSiteToFunPtrMap::const_iterator iter = callsites.begin(), eiter = callsites.end(); iter!=eiter; ++iter)
|
|
78
78
|
{
|
|
79
79
|
const CallICFGNode* cbn = iter->first;
|
|
80
|
-
CallSite cs = SVFUtil::getSVFCallSite(cbn
|
|
80
|
+
CallSite cs = SVFUtil::getSVFCallSite(cbn);
|
|
81
81
|
if (cs.isVirtualCall())
|
|
82
82
|
{
|
|
83
83
|
const SVFValue* vtbl = cs.getVtablePtr();
|
|
@@ -679,7 +679,7 @@ void CHGBuilder::buildCSToCHAVtblsAndVfnsMap()
|
|
|
679
679
|
}
|
|
680
680
|
if (vtbls.size() > 0)
|
|
681
681
|
{
|
|
682
|
-
CallSite cs
|
|
682
|
+
CallSite cs(LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(callInst));
|
|
683
683
|
chg->csToCHAVtblsMap[cs] = vtbls;
|
|
684
684
|
VFunSet virtualFunctions;
|
|
685
685
|
chg->getVFnsFromVtbls(cs, vtbls, virtualFunctions);
|
|
@@ -125,6 +125,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
125
125
|
{
|
|
126
126
|
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(cs);
|
|
127
127
|
const SVFCallInst* svfCall = SVFUtil::cast<SVFCallInst>(svfInst);
|
|
128
|
+
const CallICFGNode *callICFGNode = pag->getICFG()->getCallICFGNode(svfInst);
|
|
128
129
|
|
|
129
130
|
if (isHeapAllocExtCallViaRet(svfCall))
|
|
130
131
|
{
|
|
@@ -253,12 +254,12 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
if (isThreadForkCall(
|
|
257
|
+
if (isThreadForkCall(callICFGNode))
|
|
257
258
|
{
|
|
258
|
-
if (const SVFFunction* forkedFun = SVFUtil::dyn_cast<SVFFunction>(getForkedFun(
|
|
259
|
+
if (const SVFFunction* forkedFun = SVFUtil::dyn_cast<SVFFunction>(getForkedFun(callICFGNode)))
|
|
259
260
|
{
|
|
260
261
|
forkedFun = forkedFun->getDefFunForMultipleModule();
|
|
261
|
-
const SVFValue* actualParm = getActualParmAtForkSite(
|
|
262
|
+
const SVFValue* actualParm = getActualParmAtForkSite(callICFGNode);
|
|
262
263
|
/// pthread_create has 1 arg.
|
|
263
264
|
/// apr_thread_create has 2 arg.
|
|
264
265
|
assert((forkedFun->arg_size() <= 2) && "Size of formal parameter of start routine should be one");
|
|
@@ -268,9 +269,8 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
268
269
|
/// Connect actual parameter to formal parameter of the start routine
|
|
269
270
|
if (actualParm->getType()->isPointerTy() && formalParm->getType()->isPointerTy())
|
|
270
271
|
{
|
|
271
|
-
CallICFGNode *icfgNode = pag->getICFG()->getCallICFGNode(svfInst);
|
|
272
272
|
FunEntryICFGNode *entry = pag->getICFG()->getFunEntryICFGNode(forkedFun);
|
|
273
|
-
addThreadForkEdge(pag->getValueNode(actualParm), pag->getValueNode(formalParm),
|
|
273
|
+
addThreadForkEdge(pag->getValueNode(actualParm), pag->getValueNode(formalParm), callICFGNode, entry);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -608,7 +608,7 @@ const Type* SymbolTableBuilder::inferTypeOfHeapObjOrStaticObj(const Instruction
|
|
|
608
608
|
else if(SVFUtil::isHeapAllocExtCallViaArg(svfinst))
|
|
609
609
|
{
|
|
610
610
|
const CallBase* cs = LLVMUtil::getLLVMCallSite(inst);
|
|
611
|
-
int arg_pos = SVFUtil::getHeapAllocHoldingArgPosition(
|
|
611
|
+
int arg_pos = SVFUtil::getHeapAllocHoldingArgPosition(getCallee(svfinst));
|
|
612
612
|
const Value* arg = cs->getArgOperand(arg_pos);
|
|
613
613
|
originalPType = SVFUtil::dyn_cast<PointerType>(arg->getType());
|
|
614
614
|
inferedType = inferObjType(startValue = arg);
|