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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
#ifndef XDVI_DEBUG_H_
#define XDVI_DEBUG_H_
/*
* Copyright (c) 2002-2004 the xdvik development team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
/* debugging flags and macros */
#include "xdvi-config.h"
#include "xdvi.h"
#include "version.h"
#if HAVE_STRINGIZE
#ifdef NDEBUG
/* for production code, a failed ASSERT(x) just prints out a warning;
else it aborts and dumps core.
*/
#define ASSERT(x, y) do { \
if(!(x)) { \
fprintf(stderr, \
"************************************************************\n" \
"XDvi %s: Failed assertion:\n%s:%d: \"%s\": %s\n" \
"Please report this as a bug to:\n" \
"http://sourceforge.net/tracker/?group_id=23164&atid=377580\n" \
"************************************************************\n", \
XDVI_VERSION_INFO, __FILE__, __LINE__, #x, y); \
} } while (0)
#else /* NDEBUG */
#define ASSERT(x, y) do { \
if(!(x)) { \
fprintf(stderr, \
"\n************************************************************\n" \
"XDvi %s: Failed assertion:\n%s:%d: \"%s\": %s\n" \
"Aborting now. Please report this as a bug to:\n" \
"http://sourceforge.net/tracker/?group_id=23164&atid=377580\n" \
"If a core dump has been produced, please invoke:\n" \
"gdb %s core\nThen type \"bt\", " \
"and include the resulting output in your bug report.\n" \
"************************************************************\n", \
XDVI_VERSION_INFO, __FILE__, __LINE__, #x, y, globals.program_name); \
do_abort(); \
} } while (0)
#endif /* NDEBUG */
#else /* HAVE_STRINGIZE */
#define ASSERT(x, y) /* as nothing */
#endif
/* for temporary debugging statements */
/* #define MYDEBUG 1 */
#ifdef MYDEBUG
# define MYTRACE(X) do { \
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} while(0)
#else
# define MYTRACE(X)
#endif
/* NOTE: keep these in sync with the debug_string_options array in util.c! */
#define DBG_BITMAP 1
#define DBG_DVI 2
#define DBG_PK 4
#define DBG_BATCH 8
#define DBG_EVENT 16
#define DBG_PS 32
/* start of kpathsea debugging options */
#define DBG_STAT 64
#define DBG_HASH 128
#define DBG_OPEN 256
#define DBG_PATHS 512
#define DBG_EXPAND 1024
#define DBG_SEARCH 2048
#define DBG_KPATHSEA 4032 /* handy abbrev */
/* end of kpathsea debugging options */
#define DBG_HTEX 4096
#define DBG_SRC_SPECIALS 8192
#define DBG_CLIENT 16384
#define DBG_T1 32768
#define DBG_T1_VERBOSE 65536
#define DBG_GUI 131072
#define DBG_FIND 262144
#define DBG_FILES 524288
#define DBG_ALL (~DBG_BATCH)
/* a mapping of numerical options to descriptive strings, defined in util.c */
struct debug_string_options {
int bitmap;
const char *description;
const char *help_formatting;
};
/*
*/
#if 0
/* we don't want this defined for NDEBUG, since the tracing macros
are pretty useful also for users reporting bugs etc.; so we
enable them always.
*/
#define TRACE_HTEX(X)
#define TRACE_SRC(X)
#define TRACE_CLIENT(X)
#define TRACE_T1(X)
#define TRACE_T1_VERBOSE(X)
#define TRACE_GUI(X)
#define TRACE_EVENTS(X)
#define TRACE_FIND(X)
#define TRACE_FILES(X)
#else /* 0 */
/*
* Note that the argument to these macros is always ((stderr, "...")).
* We could also have
* TRACE_SRC(("..."));
* and invoke a function, but then gcc (3.1) won't be able to check
* inconsistencies between conversion specifiers and arguments any
* more, and that's a real killer IMHO.
*/
#define TRACE_HTEX(X) \
do { \
if (globals.debug & DBG_HTEX) { \
fprintf(stderr, "%s:%d: HTEX: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_SRC(X) \
do { \
if (globals.debug & DBG_SRC_SPECIALS) { \
fprintf(stderr, "%s:%d: SRC: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_CLIENT(X) \
do { \
if (globals.debug & DBG_CLIENT) { \
fprintf(stderr, "%s:%d: CLIENT: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_T1(X) \
do { \
if (globals.debug & DBG_T1) { \
fprintf(stderr, "%s:%d: T1: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_T1_VERBOSE(X) \
do { \
if (globals.debug & DBG_T1_VERBOSE) { \
fprintf(stderr, "%s:%d: T1_VERBOSE: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_GUI(X) \
do { \
if (globals.debug & DBG_GUI) { \
fprintf(stderr, "%s:%d: GUI: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_EVENTS(X) \
do { \
if (globals.debug & DBG_EVENT) { \
fprintf(stderr, "%s:%d: EVENT: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_FIND(X) \
do { \
if (globals.debug & DBG_FIND) { \
fprintf(stderr, "%s:%d: FIND: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#define TRACE_FILES(X) \
do { \
if (globals.debug & DBG_FILES) { \
fprintf(stderr, "%s:%d: FILES: ", __FILE__, __LINE__); \
fprintf X; \
fprintf(stderr, "\n"); \
} \
} while(0)
#endif /* 0 */
#endif /* XDVI_DEBUG_H_ */
|