Leaked source code of windows server 2003
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.

91 lines
2.7 KiB

  1. // REVIEW: This file has been "leveraged" off of \nt\private\shell\lib\debug.c and \nt\private\shell\inc\debug.h.
  2. // By no means it's complete but it gives an idea of the right direction. Ideally, we would share with shell
  3. // debugging closer.
  4. #ifndef _DEBUG_H_
  5. #define _DEBUG_H_
  6. #if (DBG == 1)
  7. #ifndef _DEBUG
  8. #define _DEBUG
  9. #endif
  10. #endif
  11. #ifdef _DEBUG
  12. #ifndef DEBUG_BREAK
  13. #ifdef _X86_
  14. #define DEBUG_BREAK \
  15. do { __try { __asm { int 3 } } __except(EXCEPTION_EXECUTE_HANDLER) {} } while (0)
  16. #else
  17. #define DEBUG_BREAK \
  18. DebugBreak()
  19. #endif
  20. #endif
  21. #ifndef ASSERT
  22. BOOL AssertFailedA(LPCSTR pszFile, int line, LPCSTR pszEval, BOOL fBreakInside);
  23. BOOL AssertFailedW(LPCWSTR pszFile, int line, LPCWSTR pszEval, BOOL fBreakInside);
  24. #ifdef _UNICODE
  25. #define AssertFailed AssertFailedW
  26. #else
  27. #define AssertFailed AssertFailedA
  28. #endif
  29. #define DEBUGTEXT(sz, msg) \
  30. static const TCHAR (sz)[] = (msg);
  31. #define ASSERT(f) \
  32. { \
  33. DEBUGTEXT(szFile, TEXT(__FILE__)); \
  34. if (!(f) && AssertFailed(szFile, __LINE__, TEXT(#f), FALSE)) \
  35. DEBUG_BREAK; \
  36. }
  37. #ifdef _UNICODE
  38. #define ASSERTA(f)
  39. #define ASSERTU(f) ASSERT(f)
  40. #else
  41. #define ASSERTA(f) ASSERT(f)
  42. #define ASSERTU(f)
  43. #endif
  44. #if defined(_ATL_NO_DEBUG_CRT) && !defined(_ASSERTE)
  45. #define _ASSERTE(f) ASSERT(f)
  46. // BUGBUG: (andrewgu) theoretically, this should be enough. _ASSERTE is really a CRT
  47. // thing, and we should not have to redefine it.
  48. // #define ATLASSERT(f) ASSERT(f)
  49. #endif
  50. #endif // ASSERT
  51. #ifndef DEBUG_CODE
  52. #define DEBUG_CODE(x) x;
  53. #endif
  54. #else // _DEBUG
  55. #ifndef DEBUG_BREAK
  56. #define DEBUG_BREAK
  57. #endif
  58. #ifndef ASSERT
  59. #define ASSERT(f)
  60. #define ASSERTA(f)
  61. #define ASSERTU(f)
  62. #endif
  63. #ifndef DEBUG_CODE
  64. #define DEBUG_CODE(x)
  65. #endif
  66. #if defined(_ATL_NO_DEBUG_CRT) && !defined(_ASSERTE)
  67. #define _ASSERTE
  68. // BUGBUG: (andrewgu) theoretically, this should be enough. _ASSERTE is really a CRT
  69. // thing, and we should not have to redefine it.
  70. // #define ATLASSERT
  71. #endif
  72. #endif // _DEBUG
  73. #endif // _DEBUG_H_