svf-lib 1.0.1502 → 1.0.1503
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.
|
Binary file
|
|
Binary file
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
#include "Util/cJSON.h"
|
|
38
38
|
#include <set>
|
|
39
39
|
|
|
40
|
+
#define BRANCHFLAGMASK 0x00000010
|
|
41
|
+
#define EVENTTYPEMASK 0x0000000f
|
|
42
|
+
|
|
40
43
|
namespace SVF
|
|
41
44
|
{
|
|
42
45
|
|
|
@@ -45,102 +48,50 @@ namespace SVF
|
|
|
45
48
|
*/
|
|
46
49
|
|
|
47
50
|
|
|
48
|
-
class
|
|
49
|
-
{
|
|
50
|
-
public:
|
|
51
|
-
enum EventType {Branch, Caller, CallSite, Loop, SourceInst};
|
|
52
|
-
|
|
53
|
-
protected:
|
|
54
|
-
EventType eventType;
|
|
55
|
-
|
|
56
|
-
public:
|
|
57
|
-
GenericEvent(EventType eventType): eventType(eventType) { };
|
|
58
|
-
virtual ~GenericEvent() = default;
|
|
59
|
-
|
|
60
|
-
inline EventType getEventType() const
|
|
61
|
-
{
|
|
62
|
-
return eventType;
|
|
63
|
-
}
|
|
64
|
-
virtual const std::string getEventDescription() const = 0;
|
|
65
|
-
virtual const std::string getFuncName() const = 0;
|
|
66
|
-
virtual const std::string getEventLoc() const = 0;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
class BranchEvent: public GenericEvent
|
|
70
|
-
{
|
|
71
|
-
/// branch statement and branch condition true or false
|
|
72
|
-
protected:
|
|
73
|
-
const SVFInstruction *branchInst;
|
|
74
|
-
bool branchSuccessFlg;
|
|
75
|
-
|
|
76
|
-
public:
|
|
77
|
-
BranchEvent(const SVFInstruction *branchInst, bool branchSuccessFlg):
|
|
78
|
-
GenericEvent(GenericEvent::Branch), branchInst(branchInst), branchSuccessFlg(branchSuccessFlg) { }
|
|
79
|
-
|
|
80
|
-
const std::string getEventDescription() const;
|
|
81
|
-
const std::string getFuncName() const;
|
|
82
|
-
const std::string getEventLoc() const;
|
|
83
|
-
|
|
84
|
-
/// ClassOf
|
|
85
|
-
static inline bool classof(const GenericEvent* event)
|
|
86
|
-
{
|
|
87
|
-
return event->getEventType() == GenericEvent::Branch;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
class CallSiteEvent: public GenericEvent
|
|
51
|
+
class BugEvent
|
|
92
52
|
{
|
|
93
|
-
protected:
|
|
94
|
-
const CallICFGNode *callSite;
|
|
95
|
-
|
|
96
53
|
public:
|
|
97
|
-
|
|
98
|
-
const std::string getEventDescription() const;
|
|
99
|
-
const std::string getFuncName() const;
|
|
100
|
-
const std::string getEventLoc() const;
|
|
101
|
-
|
|
102
|
-
/// ClassOf
|
|
103
|
-
static inline bool classof(const GenericEvent* event)
|
|
54
|
+
enum EventType
|
|
104
55
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
56
|
+
Branch = 0x1,
|
|
57
|
+
Caller = 0x2,
|
|
58
|
+
CallSite = 0x3,
|
|
59
|
+
Loop = 0x4,
|
|
60
|
+
SourceInst = 0x5
|
|
61
|
+
};
|
|
108
62
|
|
|
109
|
-
class SourceInstEvent : public GenericEvent
|
|
110
|
-
{
|
|
111
63
|
protected:
|
|
112
|
-
|
|
64
|
+
u32_t typeAndInfoFlag;
|
|
65
|
+
const SVFInstruction *eventInst;
|
|
113
66
|
|
|
114
67
|
public:
|
|
115
|
-
|
|
116
|
-
|
|
68
|
+
BugEvent(u32_t typeAndInfoFlag, const SVFInstruction *eventInst): typeAndInfoFlag(typeAndInfoFlag), eventInst(eventInst) { };
|
|
69
|
+
virtual ~BugEvent() = default;
|
|
117
70
|
|
|
118
|
-
|
|
119
|
-
const std::string getFuncName() const;
|
|
120
|
-
const std::string getEventLoc() const;
|
|
121
|
-
|
|
122
|
-
/// ClassOf
|
|
123
|
-
static inline bool classof(const GenericEvent* event)
|
|
71
|
+
inline u32_t getEventType() const
|
|
124
72
|
{
|
|
125
|
-
return
|
|
73
|
+
return typeAndInfoFlag & EVENTTYPEMASK;
|
|
126
74
|
}
|
|
75
|
+
virtual const std::string getEventDescription() const;
|
|
76
|
+
virtual const std::string getFuncName() const;
|
|
77
|
+
virtual const std::string getEventLoc() const;
|
|
127
78
|
};
|
|
128
79
|
|
|
129
80
|
class GenericBug
|
|
130
81
|
{
|
|
131
82
|
public:
|
|
132
|
-
typedef std::vector<
|
|
83
|
+
typedef std::vector<BugEvent> EventStack;
|
|
133
84
|
|
|
134
85
|
public:
|
|
135
86
|
enum BugType {FULLBUFOVERFLOW, PARTIALBUFOVERFLOW, NEVERFREE, PARTIALLEAK, DOUBLEFREE, FILENEVERCLOSE, FILEPARTIALCLOSE};
|
|
136
87
|
|
|
137
88
|
protected:
|
|
138
89
|
BugType bugType;
|
|
139
|
-
EventStack bugEventStack;
|
|
90
|
+
const EventStack bugEventStack;
|
|
140
91
|
|
|
141
92
|
public:
|
|
142
93
|
/// note: should be initialized with a bugEventStack
|
|
143
|
-
GenericBug(BugType bugType, EventStack bugEventStack):
|
|
94
|
+
GenericBug(BugType bugType, const EventStack &bugEventStack):
|
|
144
95
|
bugType(bugType), bugEventStack(bugEventStack)
|
|
145
96
|
{
|
|
146
97
|
assert(bugEventStack.size() != 0 && "bugEventStack should NOT be empty!");
|
|
@@ -307,13 +258,12 @@ public:
|
|
|
307
258
|
SVFBugReport() = default;
|
|
308
259
|
~SVFBugReport();
|
|
309
260
|
typedef SVF::Set<const GenericBug *> BugSet;
|
|
310
|
-
typedef SVF::Set<const GenericEvent *> EventSet;
|
|
311
261
|
|
|
312
262
|
protected:
|
|
313
263
|
BugSet bugSet; // maintain bugs
|
|
314
|
-
EventSet eventSet;// maintain added events
|
|
315
264
|
|
|
316
265
|
public:
|
|
266
|
+
|
|
317
267
|
/*
|
|
318
268
|
* function: pass bug type (i.e., GenericBug::NEVERFREE) and eventStack as parameter,
|
|
319
269
|
* it will add the bug into bugQueue.
|
|
@@ -321,12 +271,6 @@ public:
|
|
|
321
271
|
*/
|
|
322
272
|
void addSaberBug(GenericBug::BugType bugType, const GenericBug::EventStack &eventStack)
|
|
323
273
|
{
|
|
324
|
-
/// resign added events
|
|
325
|
-
for(auto eventPtr : eventStack)
|
|
326
|
-
{
|
|
327
|
-
eventSet.insert(eventPtr);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
274
|
/// create and add the bug
|
|
331
275
|
GenericBug *newBug = nullptr;
|
|
332
276
|
switch(bugType)
|
|
@@ -380,12 +324,6 @@ public:
|
|
|
380
324
|
void addAbsExecBug(GenericBug::BugType bugType, const GenericBug::EventStack &eventStack,
|
|
381
325
|
s64_t allocLowerBound, s64_t allocUpperBound, s64_t accessLowerBound, s64_t accessUpperBound)
|
|
382
326
|
{
|
|
383
|
-
/// resign added events
|
|
384
|
-
for(auto eventPtr : eventStack)
|
|
385
|
-
{
|
|
386
|
-
eventSet.insert(eventPtr);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
327
|
/// add bugs
|
|
390
328
|
GenericBug *newBug = nullptr;
|
|
391
329
|
switch(bugType)
|