home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / kpathsea / debug.h < prev    next >
C/C++ Source or Header  |  2000-01-15  |  3KB  |  98 lines

  1. /* debug.h: Runtime tracing.
  2.  
  3. Copyright (C) 1993, 94, 95, 96 Karl Berry.
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  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. /* Bit vector defining what we should trace.  */
  56. extern DllImport unsigned kpathsea_debug;
  57.  
  58. /* Set a bit.  */
  59. #define KPSE_DEBUG_SET(bit) kpathsea_debug |= 1 << (bit)
  60.  
  61. /* Test if a bit is on.  */
  62. #define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit)))
  63.  
  64. #define KPSE_DEBUG_STAT 0        /* stat calls */
  65. #define KPSE_DEBUG_HASH 1        /* hash lookups */
  66. #define KPSE_DEBUG_FOPEN 2        /* fopen/fclose calls */
  67. #define KPSE_DEBUG_PATHS 3        /* search path initializations */
  68. #define KPSE_DEBUG_EXPAND 4        /* path element expansion */
  69. #define KPSE_DEBUG_SEARCH 5        /* searches */
  70. #define KPSE_DEBUG_VARS 6        /* variable values */
  71. #define KPSE_LAST_DEBUG KPSE_DEBUG_VARS
  72.  
  73. /* A printf for the debugging.  */
  74. #define DEBUGF_START() do { fputs ("kdebug:", stderr)
  75. #define DEBUGF_END()        fflush (stderr); } while (0)
  76.  
  77. #define DEBUGF(str)                            \
  78.   DEBUGF_START (); fputs (str, stderr); DEBUGF_END ()
  79. #define DEBUGF1(str, e1)                        \
  80.   DEBUGF_START (); fprintf (stderr, str, e1); DEBUGF_END ()
  81. #define DEBUGF2(str, e1, e2)                        \
  82.   DEBUGF_START (); fprintf (stderr, str, e1, e2); DEBUGF_END ()
  83. #define DEBUGF3(str, e1, e2, e3)                    \
  84.   DEBUGF_START (); fprintf (stderr, str, e1, e2, e3); DEBUGF_END ()
  85. #define DEBUGF4(str, e1, e2, e3, e4)                    \
  86.   DEBUGF_START (); fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
  87.  
  88. #undef fopen
  89. #define fopen kpse_fopen_trace
  90. extern FILE *fopen P2H(const_string filename, const_string mode);
  91. #undef fclose
  92. #define fclose kpse_fclose_trace
  93. extern int fclose P1H(FILE *);
  94.  
  95. #endif /* not NO_DEBUG */
  96.  
  97. #endif /* not KPATHSEA_DEBUG_H */
  98.