1 /*$Id: io_trace.h 2016.08.11 $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis,
3 * 2015,16 Felix Salfelder
4 * Author: Albert Davis <aldavis@gnu.org>, Felix Salfelder
6 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 *------------------------------------------------------------------
23 * trace macros for model debugging
25 //testing=trivial 2006.07.17
28 /* allow multiple inclusions with different DO_TRACE */
44 /*--------------------------------------------------------------------------*/
48 #include <stdint.h> // intptr_t
54 p
= (intptr_t)x
%30011;
57 return static_cast<int>(p
);
62 /*--------------------------------------------------------------------------*/
67 #define trace_line() (std::cerr << "@@#\n@#@:" \
68 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
69 #define trace0(s) ( std::cerr << "@#@" << (s) << "\n")
70 #define trace1(s,x) ( \
71 std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
73 #define trace2(s,x,y) ( \
74 std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
75 << " " << #y << "=" << (y) \
77 #define trace3(s,x,y,z) ( \
78 std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
79 << " " << #y << "=" << (y) \
80 << " " << #z << "=" << (z) \
82 #define trace4(s,w,x,y,z) ( \
83 std::cerr << "@#@" << (s) << " " << #w << "=" << (w) \
84 << " " << #x << "=" << (x) \
85 << " " << #y << "=" << (y) \
86 << " " << #z << "=" << (z) \
88 #define trace5(s,v,w,x,y,z) ( \
89 std::cerr << "@#@" << (s) << " " << #v << "=" << (v) \
90 << " " << #w << "=" << (w) \
91 << " " << #x << "=" << (x) \
92 << " " << #y << "=" << (y) \
93 << " " << #z << "=" << (z) \
95 #define trace6(s,u,v,w,x,y,z) ( \
96 std::cerr << "@#@" << (s) \
97 << " " << #u << "=" << (u) \
98 << " " << #v << "=" << (v) \
99 << " " << #w << "=" << (w) \
100 << " " << #x << "=" << (x) \
101 << " " << #y << "=" << (y) \
102 << " " << #z << "=" << (z) \
104 #define trace7(s,t,u,v,w,x,y,z) ( \
105 std::cerr << "@#@" << (s) \
106 << " " << #t << "=" << (t) \
107 << " " << #u << "=" << (u) \
108 << " " << #v << "=" << (v) \
109 << " " << #w << "=" << (w) \
110 << " " << #x << "=" << (x) \
111 << " " << #y << "=" << (y) \
112 << " " << #z << "=" << (z) \
114 #define trace8(s,r,t,u,v,w,x,y,z) ( \
115 std::cerr << "@#@" << (s) \
116 << " " << #r << "=" << (r) \
117 << " " << #t << "=" << (t) \
118 << " " << #u << "=" << (u) \
119 << " " << #v << "=" << (v) \
120 << " " << #w << "=" << (w) \
121 << " " << #x << "=" << (x) \
122 << " " << #y << "=" << (y) \
123 << " " << #z << "=" << (z) \
126 #else // no __cplusplus
128 #define trace_line() (printf("@@#\n@#@:%s:%u:%s\n", \
129 __FILE__, __LINE__, __func__))
130 #define trace0(s) (printf("@#@%s\n", s))
131 #define trace1(s,x) (printf("@#@%s %s=%g\n", s, #x, (double)(x)))
132 #define trace2(s,x,y) (printf("@#@%s %s=%g %s=%g\n",\
133 s, #x, (double)(x), #y, (double)(y)))
134 #define trace3(s,x,y,z) (printf("@#@%s %s=%g %s=%g %s=%g\n",\
135 s, #x, (double)(x), #y, (double)(y), #z, (double)(z)))
136 #define trace4(s,w,x,y,z)(printf("@#@%s %s=%g %s=%g %s=%g %s=%g\n",\
137 s, #w, (double)(w), #x, (double)(x), #y, (double)(y), #z, (double)(z)))
138 #define trace5(s,v,w,x,y,z)\
139 (printf("@#@%s %s=%g %s=%g %s=%g %s=%g %s=%g\n",\
140 s, #v, (double)(v), #w, (double)(w), #x, (double)(x),\
141 #y, (double)(y), #z, (double)(z)))
143 #endif // __cplusplus
145 #define USE(x) (void)x
147 #define USE(x) (1)?(void)(0):(void)(x)
149 #define trace0(s) USE(s)
150 #define trace1(s,x) (USE(s),USE(x))
151 #define trace2(s,x,y) USE(s);USE(x);USE(y)
152 #define trace3(s,x,y,z) USE(s);USE(x);USE(y);USE(z)
153 #define trace4(s,w,x,y,z) USE(s);USE(w);USE(x);USE(y);USE(z)
154 #define trace5(s,v,w,x,y,z) USE(s);USE(v);USE(w);USE(x);USE(y);USE(z)
155 #define trace6(s,u,v,w,x,y,z) USE(s);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z)
156 #define trace7(s,t,u,v,w,x,y,z) USE(s);USE(t);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z)
157 #define trace8(r,s,t,u,v,w,x,y,z) USE(r);USE(s);USE(t);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z)
162 #define unreachable() ( \
163 std::cerr << "@@#\n@@@\nunreachable:" \
164 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
166 #define incomplete() ( \
167 std::cerr << "@@#\n@@@\nincomplete:" \
168 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
170 #else // no __cplusplus
172 #define unreachable() (fprintf(stderr,"@@#\n@@@unreachable:%s:%u:%s\n", \
173 __FILE__, __LINE__, __func__))
175 #define incomplete() (fprintf(stderr,"@@#\n@@@incomplete:%s:%u:%s\n", \
176 __FILE__, __LINE__, __func__))
178 #endif // __cplusplus
180 #ifdef TRACE_UNTESTED
184 #define untested() ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
185 <<":" << __func__ << "\n" )
186 #define untested1(s,x) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
187 <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << "\n" )
188 #define untested2(s,x,y) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
189 <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << ", "\
190 << #y << "=" << (y) << "\n" )
191 #define untested3(s,x,y,z) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
192 <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << ", "\
193 << #y << "=" << (y) << ", " \
194 << #z << "=" << (z) << "\n" )
196 #else // no __cplusplus
198 #define untested() (fprintf(stderr,"@@#\n@@@:%s:%u:%s\n", \
199 __FILE__, __LINE__, __func__))
201 #endif // __cplusplus
205 #define untested1(s,x)
206 #define untested2(s,x,y)
207 #define untested3(s,x,y,z)
214 #define itested() ( std::cerr << "@@#\n@@@:" \
215 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
217 #else // no __cplusplus
219 #define itested() (fprintf(stderr,"@@#\n@@@:%s:%u:%s\n", \
220 __FILE__, __LINE__, __func__))
221 #endif // __cplusplus
228 /*--------------------------------------------------------------------------*/
229 /*--------------------------------------------------------------------------*/
230 /*--------------------------------------------------------------------------*/
231 // vim:ts=8:sw=2:noet: