-
Notifications
You must be signed in to change notification settings - Fork 1
/
ihpp.h
126 lines (89 loc) · 2.6 KB
/
ihpp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <assert.h>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include "pin.H"
#include "benchmark.h"
#include "forest.h"
#include "tracingObjects.h"
#include "threadContext.h"
#include "options.h"
#ifndef __IHPP_HEADER__
#define __IHPP_HEADER__
class specialAttrs {
public:
#if defined(_WIN32)
ADDRINT _NLG_Notify_addr;
ADDRINT _NLG_Notify1_addr;
ADDRINT __NLG_Dispatch_addr;
ADDRINT __tmainCRTStartup_addr;
ADDRINT wWinMain_addr;
ADDRINT unnamedImageEntryPoint_addr;
#endif
ADDRINT main_addr;
ADDRINT exit_addr;
ADDRINT text_addr;
specialAttrs() :
#if defined(_WIN32)
_NLG_Notify_addr(0), _NLG_Notify1_addr(0),
__NLG_Dispatch_addr(0), __tmainCRTStartup_addr(0),
wWinMain_addr(0), unnamedImageEntryPoint_addr(0),
#endif
main_addr(0), exit_addr(0), text_addr(0)
{ }
};
class GlobalContext {
TLS_KEY _tls_key;
unsigned int _K_CCF_VAL;
WorkingModeType _WorkingMode;
public:
std::ofstream OutFile;
std::set<std::string> funcsToTrace;
std::set<ADDRINT> funcAddrsToTrace;
BlocksMap allBlocks;
FuncsMap allFuncs;
std::vector<ThreadContext*> threadContexts;
bool exitPassed;
#if DEBUG
bool showDebug;
#endif
optionsClass options;
specialAttrs spAttrs;
ADDRINT startFuncAddr;
ADDRINT stopFuncAddr;
double timer;
GlobalContext(WorkingModeType wm, unsigned kval, optionsClass options);
~GlobalContext();
ThreadContext *getThreadCtx(PIN_THREAD_UID tid);
void createThreadContext(PIN_THREAD_UID tid);
void destroyThreadContext(PIN_THREAD_UID tid);
WorkingModeType WorkingMode() { return _WorkingMode; }
unsigned int kval() { return _K_CCF_VAL; }
bool hasToTraceByName(const std::string& funcName, ADDRINT funcAddr);
bool hasToTrace(ADDRINT funcAddr);
};
extern GlobalContext *globalSharedContext;
inline bool GlobalContext::hasToTraceByName(const std::string& funcName, ADDRINT funcAddr)
{
if (funcsToTrace.size())
return funcsToTrace.find(funcName) != funcsToTrace.end();
return allFuncs.find(funcAddr) != allFuncs.end();
}
inline bool GlobalContext::hasToTrace(ADDRINT funcAddr)
{
return funcAddrsToTrace.find(funcAddr) != funcAddrsToTrace.end();
}
template <typename keyT>
void kSlabForestKLevelCountersClear(forest<keyT>& f, keyT& rootKey, unsigned int k)
{
for (auto& tree : f) {
if (tree.getKey() != rootKey)
tree.clearLevelKCounters(k);
}
}
#include "specialfuncs.h"
#endif