w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

debug.h
Go to the documentation of this file.
1 /* debug.h: runtime tracing.
2 
3  Copyright 1993, 1994, 1995, 1996, 2008 Karl Berry.
4  Copyright 1999, 2005 Olaf Weber.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this library; if not, see <http://www.gnu.org/licenses/>. */
18 
19 #ifndef KPATHSEA_DEBUG_H
20 #define KPATHSEA_DEBUG_H
21 
22 /* If NO_DEBUG is defined (not recommended), skip all this. */
23 #ifndef NO_DEBUG
24 
25 #include <kpathsea/c-proto.h>
26 #include <kpathsea/c-std.h>
27 #include <kpathsea/types.h>
28 
29 #if defined(WIN32)
30 #if defined(_DEBUG)
31 /* This was needed at some time for catching errors in pdftex. */
32 #include <crtdbg.h>
33 #define SET_CRT_DEBUG_FIELD(a) \
34  _CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
35 #define CLEAR_CRT_DEBUG_FIELD(a) \
36  _CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
37 #define SETUP_CRTDBG \
38  { _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); \
39  _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); \
40  _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); \
41  _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); \
42  _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); \
43  _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );\
44  }
45 #else /* ! _DEBUG */
46 #define SET_CRT_DEBUG_FIELD(a)
47 #define CLEAR_CRT_DEBUG_FIELD(a)
48 #define SETUP_CRTDBG
49 #endif /* _DEBUG */
50 #endif /* WIN32 */
51 
52 /* OK, we'll have tracing support. */
53 #define KPSE_DEBUG
54 
55 /* Test if a bit is on. */
56 #define KPATHSEA_DEBUG_P(bit) (kpse->debug & (1 << (bit)))
57 
58 #if defined (KPSE_COMPAT_API)
59 
60 /* Set a bit. */
61 #define KPSE_DEBUG_SET(bit) kpathsea_debug |= 1 << (bit)
62 
63 /* Test if a bit is on. */
64 #define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit)))
65 
66 #endif /* KPSE_COMPAT_API */
67 
68 #define KPSE_DEBUG_STAT 0 /* stat calls */
69 #define KPSE_DEBUG_HASH 1 /* hash lookups */
70 #define KPSE_DEBUG_FOPEN 2 /* fopen/fclose calls */
71 #define KPSE_DEBUG_PATHS 3 /* search path initializations */
72 #define KPSE_DEBUG_EXPAND 4 /* path element expansion */
73 #define KPSE_DEBUG_SEARCH 5 /* searches */
74 #define KPSE_DEBUG_VARS 6 /* variable values */
75 #define KPSE_LAST_DEBUG KPSE_DEBUG_VARS
76 
77 /* A printf for the debugging. */
78 #define DEBUGF_START() do { fputs ("kdebug:", stderr)
79 #define DEBUGF_END() fflush (stderr); } while (0)
80 
81 #define DEBUGF(str) \
82  DEBUGF_START (); fputs (str, stderr); DEBUGF_END ()
83 #define DEBUGF1(str, e1) \
84  DEBUGF_START (); fprintf (stderr, str, e1); DEBUGF_END ()
85 #define DEBUGF2(str, e1, e2) \
86  DEBUGF_START (); fprintf (stderr, str, e1, e2); DEBUGF_END ()
87 #define DEBUGF3(str, e1, e2, e3) \
88  DEBUGF_START (); fprintf (stderr, str, e1, e2, e3); DEBUGF_END ()
89 #define DEBUGF4(str, e1, e2, e3, e4) \
90  DEBUGF_START (); fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
91 
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95 
96 #undef fopen
97 #define fopen kpse_fopen_trace
98 extern KPSEDLL FILE *fopen (const char *filename, const char *mode);
99 #undef fclose
100 #define fclose kpse_fclose_trace
101 extern KPSEDLL int fclose (FILE *);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* not NO_DEBUG */
108 
109 #endif /* not KPATHSEA_DEBUG_H */
#define mode
Definition: aptex-macros.h:510
#define KPSEDLL
Definition: c-proto.h:33
#define fopen
Definition: debug.h:97
#define fclose
Definition: debug.h:100
char * filename[256]
Definition: pbmtopk.c:46
#define FILE
Definition: t1stdio.h:34