2 |
- |
1 |
/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: gdebug.h,v 1.6 2002/06/16 08:45:42 lpd Exp $ */
|
|
|
18 |
/* Debugging machinery definitions */
|
|
|
19 |
|
|
|
20 |
#ifndef gdebug_INCLUDED
|
|
|
21 |
# define gdebug_INCLUDED
|
|
|
22 |
|
|
|
23 |
/*
|
|
|
24 |
* The compile-time DEBUG symbol determines whether debugging/tracing
|
|
|
25 |
* code is included in the compiled code. DEBUG may be set or not set
|
|
|
26 |
* independently for every compilation; however, a small amount of support
|
|
|
27 |
* machinery in gsmisc.c is always included in the executable, just
|
|
|
28 |
* in case *some* file was compiled with DEBUG set.
|
|
|
29 |
*
|
|
|
30 |
* When DEBUG is set, it does not cause debugging/tracing printout to occur.
|
|
|
31 |
* Rather, it includes code that produces such printout *if* (a) given
|
|
|
32 |
* one(s) of 128 debugging flags is set. In this way, one can selectively
|
|
|
33 |
* turn printout on and off during debugging. (In fact, we even provide a
|
|
|
34 |
* PostScript operator, .setdebug, that does this.)
|
|
|
35 |
*
|
|
|
36 |
* The debugging flags are normally indexed by character code. This is more
|
|
|
37 |
* than a convention: gs_debug_c, which tests whether a given flag is set,
|
|
|
38 |
* considers that if a flag named by a given upper-case letter is set, the
|
|
|
39 |
* flag named by the corresponding lower-case letter is also set.
|
|
|
40 |
*
|
|
|
41 |
* If the output selected by a given flag can be printed by a single
|
|
|
42 |
* printf, the conventional way to produce the output is
|
|
|
43 |
* if_debugN('x', "...format...", v1, ..., vN);
|
|
|
44 |
* Usually the flag appears in the output explicitly:
|
|
|
45 |
* if_debugN('x', "[x]...format...", v1, ..., vN);
|
|
|
46 |
* If the output is more complex, the conventional way to produce the
|
|
|
47 |
* output is
|
|
|
48 |
* if ( gs_debug_c('x') ) {
|
|
|
49 |
* ... start each line with dlprintfN(...)
|
|
|
50 |
* ... produce additional output within a line with dprintfN(...)
|
|
|
51 |
* } */
|
|
|
52 |
|
|
|
53 |
/* Define the array of debugging flags, indexed by character code. */
|
|
|
54 |
extern char gs_debug[128];
|
|
|
55 |
bool gs_debug_c(int /*char */ );
|
|
|
56 |
|
|
|
57 |
/*
|
|
|
58 |
* Define an alias for a specialized debugging flag
|
|
|
59 |
* that used to be a separate variable.
|
|
|
60 |
*/
|
|
|
61 |
#define gs_log_errors gs_debug['#']
|
|
|
62 |
|
|
|
63 |
/* If debugging, direct all error output to gs_debug_out. */
|
|
|
64 |
extern FILE *gs_debug_out;
|
|
|
65 |
|
|
|
66 |
#ifdef DEBUG
|
|
|
67 |
#undef dstderr
|
|
|
68 |
#define dstderr gs_debug_out
|
|
|
69 |
#undef estderr
|
|
|
70 |
#define estderr gs_debug_out
|
|
|
71 |
#endif
|
|
|
72 |
|
|
|
73 |
/* Debugging printout macros. */
|
|
|
74 |
#ifdef DEBUG
|
|
|
75 |
# define if_debug0(c,s)\
|
|
|
76 |
BEGIN if (gs_debug_c(c)) dlprintf(s); END
|
|
|
77 |
# define if_debug1(c,s,a1)\
|
|
|
78 |
BEGIN if (gs_debug_c(c)) dlprintf1(s,a1); END
|
|
|
79 |
# define if_debug2(c,s,a1,a2)\
|
|
|
80 |
BEGIN if (gs_debug_c(c)) dlprintf2(s,a1,a2); END
|
|
|
81 |
# define if_debug3(c,s,a1,a2,a3)\
|
|
|
82 |
BEGIN if (gs_debug_c(c)) dlprintf3(s,a1,a2,a3); END
|
|
|
83 |
# define if_debug4(c,s,a1,a2,a3,a4)\
|
|
|
84 |
BEGIN if (gs_debug_c(c)) dlprintf4(s,a1,a2,a3,a4); END
|
|
|
85 |
# define if_debug5(c,s,a1,a2,a3,a4,a5)\
|
|
|
86 |
BEGIN if (gs_debug_c(c)) dlprintf5(s,a1,a2,a3,a4,a5); END
|
|
|
87 |
# define if_debug6(c,s,a1,a2,a3,a4,a5,a6)\
|
|
|
88 |
BEGIN if (gs_debug_c(c)) dlprintf6(s,a1,a2,a3,a4,a5,a6); END
|
|
|
89 |
# define if_debug7(c,s,a1,a2,a3,a4,a5,a6,a7)\
|
|
|
90 |
BEGIN if (gs_debug_c(c)) dlprintf7(s,a1,a2,a3,a4,a5,a6,a7); END
|
|
|
91 |
# define if_debug8(c,s,a1,a2,a3,a4,a5,a6,a7,a8)\
|
|
|
92 |
BEGIN if (gs_debug_c(c)) dlprintf8(s,a1,a2,a3,a4,a5,a6,a7,a8); END
|
|
|
93 |
# define if_debug9(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
|
|
|
94 |
BEGIN if (gs_debug_c(c)) dlprintf9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9); END
|
|
|
95 |
# define if_debug10(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)\
|
|
|
96 |
BEGIN if (gs_debug_c(c)) dlprintf10(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10); END
|
|
|
97 |
# define if_debug11(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)\
|
|
|
98 |
BEGIN if (gs_debug_c(c)) dlprintf11(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11); END
|
|
|
99 |
# define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)\
|
|
|
100 |
BEGIN if (gs_debug_c(c)) dlprintf12(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12); END
|
|
|
101 |
#else
|
|
|
102 |
# define if_debug0(c,s) DO_NOTHING
|
|
|
103 |
# define if_debug1(c,s,a1) DO_NOTHING
|
|
|
104 |
# define if_debug2(c,s,a1,a2) DO_NOTHING
|
|
|
105 |
# define if_debug3(c,s,a1,a2,a3) DO_NOTHING
|
|
|
106 |
# define if_debug4(c,s,a1,a2,a3,a4) DO_NOTHING
|
|
|
107 |
# define if_debug5(c,s,a1,a2,a3,a4,a5) DO_NOTHING
|
|
|
108 |
# define if_debug6(c,s,a1,a2,a3,a4,a5,a6) DO_NOTHING
|
|
|
109 |
# define if_debug7(c,s,a1,a2,a3,a4,a5,a6,a7) DO_NOTHING
|
|
|
110 |
# define if_debug8(c,s,a1,a2,a3,a4,a5,a6,a7,a8) DO_NOTHING
|
|
|
111 |
# define if_debug9(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9) DO_NOTHING
|
|
|
112 |
# define if_debug10(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) DO_NOTHING
|
|
|
113 |
# define if_debug11(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) DO_NOTHING
|
|
|
114 |
# define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) DO_NOTHING
|
|
|
115 |
#endif
|
|
|
116 |
|
|
|
117 |
/* Debugging support procedures in gsmisc.c */
|
|
|
118 |
void debug_dump_bytes(const byte * from, const byte * to,
|
|
|
119 |
const char *msg);
|
|
|
120 |
void debug_dump_bitmap(const byte * from, uint raster, uint height,
|
|
|
121 |
const char *msg);
|
|
|
122 |
void debug_print_string(const byte * str, uint len);
|
|
|
123 |
void debug_print_string_hex(const byte * str, uint len);
|
|
|
124 |
|
|
|
125 |
#endif /* gdebug_INCLUDED */
|