1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
13
/* $Id: gdebug.h 8415 2007-11-29 01:42:16Z lpd $ */
14
/* Debugging machinery definitions */
16
#ifndef gdebug_INCLUDED
17
# define gdebug_INCLUDED
20
* The compile-time DEBUG symbol determines whether debugging/tracing
21
* code is included in the compiled code. DEBUG may be set or not set
22
* independently for every compilation; however, a small amount of support
23
* machinery in gsmisc.c is always included in the executable, just
24
* in case *some* file was compiled with DEBUG set.
26
* When DEBUG is set, it does not cause debugging/tracing printout to occur.
27
* Rather, it includes code that produces such printout *if* (a) given
28
* one(s) of 128 debugging flags is set. In this way, one can selectively
29
* turn printout on and off during debugging. (In fact, we even provide a
30
* PostScript operator, .setdebug, that does this.)
32
* The debugging flags are normally indexed by character code. This is more
33
* than a convention: gs_debug_c, which tests whether a given flag is set,
34
* considers that if a flag named by a given upper-case letter is set, the
35
* flag named by the corresponding lower-case letter is also set.
37
* If the output selected by a given flag can be printed by a single
38
* printf, the conventional way to produce the output is
39
* if_debugN('x', "...format...", v1, ..., vN);
40
* Usually the flag appears in the output explicitly:
41
* if_debugN('x', "[x]...format...", v1, ..., vN);
42
* If the output is more complex, the conventional way to produce the
44
* if ( gs_debug_c('x') ) {
45
* ... start each line with dlprintfN(...)
46
* ... produce additional output within a line with dprintfN(...)
49
/* Define the array of debugging flags, indexed by character code. */
50
extern char gs_debug[128];
51
bool gs_debug_c(int /*char */ );
54
* Define an alias for a specialized debugging flag
55
* that used to be a separate variable.
57
#define gs_log_errors gs_debug['#']
59
/* If debugging, direct all error output to gs_debug_out. */
60
extern FILE *gs_debug_out;
62
/* Debugging printout macros. */
64
# define if_debug0(c,s)\
65
BEGIN if (gs_debug_c(c)) dlprintf(s); END
66
# define if_debug1(c,s,a1)\
67
BEGIN if (gs_debug_c(c)) dlprintf1(s,a1); END
68
# define if_debug2(c,s,a1,a2)\
69
BEGIN if (gs_debug_c(c)) dlprintf2(s,a1,a2); END
70
# define if_debug3(c,s,a1,a2,a3)\
71
BEGIN if (gs_debug_c(c)) dlprintf3(s,a1,a2,a3); END
72
# define if_debug4(c,s,a1,a2,a3,a4)\
73
BEGIN if (gs_debug_c(c)) dlprintf4(s,a1,a2,a3,a4); END
74
# define if_debug5(c,s,a1,a2,a3,a4,a5)\
75
BEGIN if (gs_debug_c(c)) dlprintf5(s,a1,a2,a3,a4,a5); END
76
# define if_debug6(c,s,a1,a2,a3,a4,a5,a6)\
77
BEGIN if (gs_debug_c(c)) dlprintf6(s,a1,a2,a3,a4,a5,a6); END
78
# define if_debug7(c,s,a1,a2,a3,a4,a5,a6,a7)\
79
BEGIN if (gs_debug_c(c)) dlprintf7(s,a1,a2,a3,a4,a5,a6,a7); END
80
# define if_debug8(c,s,a1,a2,a3,a4,a5,a6,a7,a8)\
81
BEGIN if (gs_debug_c(c)) dlprintf8(s,a1,a2,a3,a4,a5,a6,a7,a8); END
82
# define if_debug9(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
83
BEGIN if (gs_debug_c(c)) dlprintf9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9); END
84
# define if_debug10(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)\
85
BEGIN if (gs_debug_c(c)) dlprintf10(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10); END
86
# define if_debug11(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)\
87
BEGIN if (gs_debug_c(c)) dlprintf11(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11); END
88
# define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)\
89
BEGIN if (gs_debug_c(c)) dlprintf12(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12); END
91
# define if_debug0(c,s) DO_NOTHING
92
# define if_debug1(c,s,a1) DO_NOTHING
93
# define if_debug2(c,s,a1,a2) DO_NOTHING
94
# define if_debug3(c,s,a1,a2,a3) DO_NOTHING
95
# define if_debug4(c,s,a1,a2,a3,a4) DO_NOTHING
96
# define if_debug5(c,s,a1,a2,a3,a4,a5) DO_NOTHING
97
# define if_debug6(c,s,a1,a2,a3,a4,a5,a6) DO_NOTHING
98
# define if_debug7(c,s,a1,a2,a3,a4,a5,a6,a7) DO_NOTHING
99
# define if_debug8(c,s,a1,a2,a3,a4,a5,a6,a7,a8) DO_NOTHING
100
# define if_debug9(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9) DO_NOTHING
101
# define if_debug10(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) DO_NOTHING
102
# define if_debug11(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) DO_NOTHING
103
# define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) DO_NOTHING
106
/* Debugging support procedures in gsmisc.c */
107
void debug_dump_bytes(const byte * from, const byte * to,
109
void debug_dump_bitmap(const byte * from, uint raster, uint height,
111
void debug_print_string(const byte * str, uint len);
112
void debug_print_string_hex(const byte * str, uint len);
114
#endif /* gdebug_INCLUDED */