Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. // Copyright (C) 1996 Microsoft Corporation.
  3. //
  4. // File: debug.hxx
  5. //
  6. // Contents: Debugging macros
  7. //
  8. //----------------------------------------------------------------------------
  9. #pragma once
  10. #if DBG == 1
  11. #include <stdio.h>
  12. #include <stdarg.h>
  13. # define ISAssert(x) \
  14. (void)((x) || (ISAssertEx(__FILE__, __LINE__, #x),0))
  15. inline void ISAssertEx( char const * szFile,
  16. int iLine,
  17. char const * szMessage)
  18. {
  19. char acsString[200];
  20. sprintf( acsString, "%s, File: %s Line: %u\n", szMessage, szFile, iLine );
  21. OutputDebugStringA( acsString );
  22. DebugBreak();
  23. }
  24. #define DEB_ERROR 0x00000001 // exported error paths
  25. #define DEB_WARN 0x00000002 // exported warnings
  26. #define DEB_TRACE 0x00000004 // exported trace messages
  27. #define DEB_IERROR 0x00000100 // internal error paths
  28. #define DEB_IWARN 0x00000200 // internal warnings
  29. #define DEB_ITRACE 0x00000400 // internal trace messages
  30. #define DEB_FORCE 0x7fffffff // force message
  31. #define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
  32. #define DECLARE_INFOLEVEL(comp) \
  33. extern unsigned long comp##InfoLevel = DEF_INFOLEVEL;
  34. extern void isLogString( const char * pcString );
  35. //
  36. // The first form takes a mask and prints to the debugger.
  37. // The second form prints to the log file
  38. //
  39. #define DECLARE_DEBUG(comp) \
  40. extern unsigned long comp##InfoLevel; \
  41. _inline void \
  42. comp##InlineDebugOut(unsigned long fDebugMask, char *pszfmt, ...) \
  43. { \
  44. if (comp##InfoLevel & fDebugMask) \
  45. { \
  46. char acsString[1000];\
  47. va_list va; \
  48. va_start(va, pszfmt);\
  49. vsprintf(acsString, pszfmt, va); \
  50. va_end(va);\
  51. OutputDebugStringA(acsString);\
  52. } \
  53. }\
  54. _inline void \
  55. comp##InlineDebugOut( char *pszfmt, ...) \
  56. { \
  57. if ( TRUE ) \
  58. { \
  59. char acsString[1000];\
  60. va_list va; \
  61. va_start(va, pszfmt);\
  62. vsprintf(acsString, pszfmt, va); \
  63. va_end(va);\
  64. comp##LogString( acsString );\
  65. } \
  66. }
  67. #else // DBG == 0
  68. #define ISAssert(x)
  69. #define DECLARE_DEBUG(comp)
  70. #define DECLARE_INFOLEVEL(comp)
  71. #endif // DBG == 0