-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrace.h
More file actions
147 lines (137 loc) · 4 KB
/
trace.h
File metadata and controls
147 lines (137 loc) · 4 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Felix Salfelder 2016
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, 51 Franklin Street - Suite 500, Boston, MA 02110-1335, USA.
//
//
// basig tracing. inspired by gnucap and incomplete.
//
// define
// TRACE_UNTESTED to trace untested calls
// TRACE_ITESTED to trace interactively tested calls
// DO_TRACE to trace program flow
//
//
#include <vector>
#ifndef HP_hp
#define HP_hp
class hp{
intptr_t p;
public:
hp(const void* x){ //
p = (intptr_t)x %30011;
}
operator int(){ //
return static_cast<int>(p);
}
};
#endif
#ifndef incomplete
#define incomplete() \
std::cout << "incomplete " << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n"
#endif
#ifndef unreachable
#define unreachable() \
std::cerr << "unreachable " << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n"
#endif
// interactively tested
#undef itested
#ifdef TRACE_ITESTED
#include <iostream>
#define itested() ( std::cerr << "@@#\n@@@:" \
<< __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
#else
#define itested()
#endif
#undef untested
#ifdef TRACE_UNTESTED
#include <iostream>
#define untested() ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
<<":" << __func__ << "\n" )
#else
#define untested()
#endif
#ifndef USE
#define USE(x) (1)?(void)(0):(void)(x)
#endif
#undef trace0
#undef trace1
#undef trace2
#undef trace3
#undef trace4
#undef trace5
#undef trace6
#ifdef DO_TRACE
#define trace0(s) ( std::cerr << "@#@" << (s) << "\n")
#define trace1(s,x) ( \
std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
<< std::endl )
#define trace2(s,x,y) ( \
std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
<< " " << #y << "=" << (y) \
<< std::endl )
#define trace3(s,x,y,z) ( \
std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
<< " " << #y << "=" << (y) \
<< " " << #z << "=" << (z) \
<< std::endl )
#define trace4(s,x,y,z,w) ( \
std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
<< " " << #y << "=" << (y) \
<< " " << #z << "=" << (z) \
<< " " << #w << "=" << (w) \
<< std::endl )
#define trace5(s,x,y,z,w,u) ( \
std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
<< " " << #y << "=" << (y) \
<< " " << #z << "=" << (z) \
<< " " << #w << "=" << (w) \
<< " " << #u << "=" << (u) \
<< std::endl )
#define trace6(s,x,y,z,w,u,t) ( \
std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
<< " " << #y << "=" << (y) \
<< " " << #z << "=" << (z) \
<< " " << #w << "=" << (w) \
<< " " << #u << "=" << (u) \
<< " " << #t << "=" << (t) \
<< std::endl )
#else
#define trace0(s) (USE(s))
#define trace1(s,x) (USE(s),USE(x))
#define trace2(s,x,y) USE(s);USE(x);USE(y)
#define trace3(s,x,y,z) USE(s);USE(x);USE(y);USE(z)
#define trace4(s,x,y,z,w) USE(s);USE(x);USE(y);USE(z);USE(w)
#define trace5(s,x,y,z,w,u) USE(s);USE(x);USE(y);USE(z);USE(w);USE(u)
#define trace6(s,x,y,z,w,u,t) USE(s);USE(x);USE(y);USE(z);USE(w);USE(u);USE(t)
#endif
#ifndef TRACE_H
#define TRACE_H
# ifndef NDEBUG
template <class C>
inline bool contains(C const& c, typename C::value_type const& v)
{ untested();
return(c.find(v) != c.end());
}
template <class X>
inline bool contains(std::vector<X> const& c, X const& v)
{
typedef typename std::vector<X>::const_iterator it;
for(it i=c.begin(); i!=c.end(); ++i){
if(v == *i) return true;
}
return false;
}
# endif
#endif