5
* Copyright (c) 2002-2004 the xdvik development team
7
* Permission is hereby granted, free of charge, to any person obtaining a copy
8
* of this software and associated documentation files (the "Software"), to
9
* deal in the Software without restriction, including without limitation the
10
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
* sell copies of the Software, and to permit persons to whom the Software is
12
* furnished to do so, subject to the following conditions:
14
* The above copyright notice and this permission notice shall be included in
15
* all copies or substantial portions of the Software.
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
* PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM,
21
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
* OTHER DEALINGS IN THE SOFTWARE.
27
/* debugging flags and macros */
29
#include "xdvi-config.h"
35
/* for production code, a failed ASSERT(x) just prints out a warning;
36
else it aborts and dumps core.
38
#define ASSERT(x, y) do { \
41
"************************************************************\n" \
42
"XDvi %s: Failed assertion:\n%s:%d: \"%s\": %s\n" \
43
"Please report this as a bug to:\n" \
44
"http://sourceforge.net/tracker/?group_id=23164&atid=377580\n" \
45
"************************************************************\n", \
46
XDVI_VERSION_INFO, __FILE__, __LINE__, #x, y); \
49
#define ASSERT(x, y) do { \
52
"\n************************************************************\n" \
53
"XDvi %s: Failed assertion:\n%s:%d: \"%s\": %s\n" \
54
"Aborting now. Please report this as a bug to:\n" \
55
"http://sourceforge.net/tracker/?group_id=23164&atid=377580\n" \
56
"If a core dump has been produced, please invoke:\n" \
57
"gdb %s core\nThen type \"bt\", " \
58
"and include the resulting output in your bug report.\n" \
59
"************************************************************\n", \
60
XDVI_VERSION_INFO, __FILE__, __LINE__, #x, y, globals.program_name); \
64
#else /* HAVE_STRINGIZE */
65
#define ASSERT(x, y) /* as nothing */
68
/* for temporary debugging statements */
69
/* #define MYDEBUG 1 */
71
# define MYTRACE(X) do { \
72
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
74
fprintf(stderr, "\n"); \
80
/* NOTE: keep these in sync with the debug_string_options array in util.c! */
87
/* start of kpathsea debugging options */
92
#define DBG_EXPAND 1024
93
#define DBG_SEARCH 2048
94
#define DBG_KPATHSEA 4032 /* handy abbrev */
95
/* end of kpathsea debugging options */
97
#define DBG_SRC_SPECIALS 8192
98
#define DBG_CLIENT 16384
100
#define DBG_T1_VERBOSE 65536
101
#define DBG_GUI 131072
102
#define DBG_FIND 262144
103
#define DBG_FILES 524288
104
#define DBG_ALL (~DBG_BATCH)
106
/* a mapping of numerical options to descriptive strings, defined in util.c */
107
struct debug_string_options {
109
const char *description;
110
const char *help_formatting;
117
/* we don't want this defined for NDEBUG, since the tracing macros
118
are pretty useful also for users reporting bugs etc.; so we
121
#define TRACE_HTEX(X)
123
#define TRACE_CLIENT(X)
125
#define TRACE_T1_VERBOSE(X)
127
#define TRACE_EVENTS(X)
128
#define TRACE_FIND(X)
129
#define TRACE_FILES(X)
134
* Note that the argument to these macros is always ((stderr, "...")).
136
* TRACE_SRC(("..."));
137
* and invoke a function, but then gcc (3.1) won't be able to check
138
* inconsistencies between conversion specifiers and arguments any
139
* more, and that's a real killer IMHO.
142
#define TRACE_HTEX(X) \
144
if (globals.debug & DBG_HTEX) { \
145
fprintf(stderr, "%s:%d: HTEX: ", __FILE__, __LINE__); \
147
fprintf(stderr, "\n"); \
150
#define TRACE_SRC(X) \
152
if (globals.debug & DBG_SRC_SPECIALS) { \
153
fprintf(stderr, "%s:%d: SRC: ", __FILE__, __LINE__); \
155
fprintf(stderr, "\n"); \
158
#define TRACE_CLIENT(X) \
160
if (globals.debug & DBG_CLIENT) { \
161
fprintf(stderr, "%s:%d: CLIENT: ", __FILE__, __LINE__); \
163
fprintf(stderr, "\n"); \
166
#define TRACE_T1(X) \
168
if (globals.debug & DBG_T1) { \
169
fprintf(stderr, "%s:%d: T1: ", __FILE__, __LINE__); \
171
fprintf(stderr, "\n"); \
174
#define TRACE_T1_VERBOSE(X) \
176
if (globals.debug & DBG_T1_VERBOSE) { \
177
fprintf(stderr, "%s:%d: T1_VERBOSE: ", __FILE__, __LINE__); \
179
fprintf(stderr, "\n"); \
182
#define TRACE_GUI(X) \
184
if (globals.debug & DBG_GUI) { \
185
fprintf(stderr, "%s:%d: GUI: ", __FILE__, __LINE__); \
187
fprintf(stderr, "\n"); \
190
#define TRACE_EVENTS(X) \
192
if (globals.debug & DBG_EVENT) { \
193
fprintf(stderr, "%s:%d: EVENT: ", __FILE__, __LINE__); \
195
fprintf(stderr, "\n"); \
198
#define TRACE_FIND(X) \
200
if (globals.debug & DBG_FIND) { \
201
fprintf(stderr, "%s:%d: FIND: ", __FILE__, __LINE__); \
203
fprintf(stderr, "\n"); \
207
#define TRACE_FILES(X) \
209
if (globals.debug & DBG_FILES) { \
210
fprintf(stderr, "%s:%d: FILES: ", __FILE__, __LINE__); \
212
fprintf(stderr, "\n"); \
218
#endif /* XDVI_DEBUG_H_ */