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.

173 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name :
  4. irtldbg.h
  5. Abstract:
  6. Some simple debugging macros that look and behave a lot like their
  7. namesakes in MFC. These macros should work in both C and C++ and do
  8. something useful with almost any Win32 compiler.
  9. Author:
  10. George V. Reilly (GeorgeRe) 06-Jan-1998
  11. Environment:
  12. Win32 - User Mode
  13. Project:
  14. Internet Information Server RunTime Library
  15. Revision History:
  16. --*/
  17. #ifndef __IRTLDBG_H__
  18. #define __IRTLDBG_H__
  19. #ifndef __IRTLMISC_H__
  20. # include <irtlmisc.h>
  21. #endif
  22. /* Ensure that MessageBoxes can popup */
  23. # define RUNNING_AS_SERVICE 1
  24. #include <tchar.h>
  25. # ifndef _AFX
  26. /* Assure compatiblity with MFC */
  27. # ifdef _DEBUG
  28. # ifndef USE_DEBUG_CRTS
  29. /* IIS (and NT) do not ship msvcrtD.dll, per the VC license,
  30. * so we can't use the assertion code from <crtdbg.h>. Use similar
  31. * macros from <pudebug.h> instead. */
  32. # include <pudebug.h>
  33. # define IRTLASSERT(f) DBG_ASSERT(f)
  34. # elif defined(_MSC_VER) && (_MSC_VER >= 1000)
  35. /* Use the new debugging tools in Visual C++ 4.x */
  36. # include <crtdbg.h>
  37. /* _ASSERTE will give a more meaningful message, but the string takes
  38. * space. Use _ASSERT if this is an issue. */
  39. # define IRTLASSERT(f) _ASSERTE(f)
  40. # else
  41. # include <assert.h>
  42. # define IRTLASSERT(f) assert(f)
  43. # endif
  44. # define IRTLVERIFY(f) IRTLASSERT(f)
  45. # define DEBUG_ONLY(f) (f)
  46. # define TRACE IrtlTrace
  47. # define TRACE0(psz) IrtlTrace(_T("%s"), _T(psz))
  48. # define TRACE1(psz, p1) IrtlTrace(_T(psz), p1)
  49. # define TRACE2(psz, p1, p2) IrtlTrace(_T(psz), p1, p2)
  50. # define TRACE3(psz, p1, p2, p3) IrtlTrace(_T(psz), p1, p2, p3)
  51. # define ASSERT_VALID(pObj) \
  52. do {IRTLASSERT((pObj) != NULL); (pObj)->AssertValid();} while (0)
  53. # define DUMP(pObj) \
  54. do {IRTLASSERT((pObj) != NULL); (pObj)->Dump();} while (0)
  55. # else /* !_DEBUG */
  56. /* These macros should all compile away to nothing */
  57. # define IRTLASSERT(f) ((void)0)
  58. # define IRTLVERIFY(f) ((void)(f))
  59. # define DEBUG_ONLY(f) ((void)0)
  60. # define TRACE 1 ? (void)0 : IrtlTrace
  61. # define TRACE0(psz)
  62. # define TRACE1(psz, p1)
  63. # define TRACE2(psz, p1, p2)
  64. # define TRACE3(psz, p1, p2, p3)
  65. # define ASSERT_VALID(pObj) ((void)0)
  66. # define DUMP(pObj) ((void)0)
  67. # endif /* !_DEBUG */
  68. # define ASSERT_POINTER(p, type) \
  69. IRTLASSERT(((p) != NULL) && IsValidAddress((p), sizeof(type), FALSE))
  70. # define ASSERT_NULL_OR_POINTER(p, type) \
  71. IRTLASSERT(((p) == NULL) || IsValidAddress((p), sizeof(type), FALSE))
  72. #define ASSERT_STRING(s) \
  73. IRTLASSERT(((s) != NULL) && IsValidString((s), -1))
  74. #define ASSERT_NULL_OR_STRING(s) \
  75. IRTLASSERT(((s) == NULL) || IsValidString((s), -1))
  76. /* Declarations for non-Windows apps */
  77. # ifndef _WINDEF_
  78. typedef void* LPVOID;
  79. typedef const void* LPCVOID;
  80. typedef unsigned int UINT;
  81. typedef int BOOL;
  82. typedef const char* LPCTSTR;
  83. # endif /* _WINDEF_ */
  84. # ifndef TRUE
  85. # define FALSE 0
  86. # define TRUE 1
  87. # endif
  88. # ifdef __cplusplus
  89. extern "C" {
  90. /* Low-level sanity checks for memory blocks */
  91. IRTL_DLLEXP BOOL IsValidAddress(LPCVOID pv, UINT nBytes, BOOL fReadWrite = TRUE);
  92. IRTL_DLLEXP BOOL IsValidString(LPCTSTR ptsz, int nLength = -1);
  93. }
  94. # else /* !__cplusplus */
  95. /* Low-level sanity checks for memory blocks */
  96. IRTL_DLLEXP BOOL IsValidAddress(LPCVOID pv, UINT nBytes, BOOL fReadWrite);
  97. IRTL_DLLEXP BOOL IsValidString(LPCTSTR ptsz, int nLength);
  98. # endif /* !__cplusplus */
  99. #endif /* !_AFX */
  100. /* Writes trace messages to debug stream */
  101. extern
  102. #ifdef __cplusplus
  103. "C"
  104. #endif /* !__cplusplus */
  105. IRTL_DLLEXP
  106. void __cdecl
  107. IrtlTrace(
  108. LPCTSTR pszFormat,
  109. ...);
  110. #ifdef _DEBUG
  111. # define IRTL_DEBUG_INIT() IrtlDebugInit()
  112. # define IRTL_DEBUG_TERM() IrtlDebugTerm()
  113. #else /* !_DEBUG */
  114. # define IRTL_DEBUG_INIT() ((void)0)
  115. # define IRTL_DEBUG_TERM() ((void)0)
  116. #endif /* !_DEBUG */
  117. #ifdef __cplusplus
  118. extern "C" {
  119. #endif /* __cplusplus */
  120. /* should be called from main(), WinMain(), or DllMain() */
  121. IRTL_DLLEXP void
  122. IrtlDebugInit();
  123. IRTL_DLLEXP void
  124. IrtlDebugTerm();
  125. #ifdef __cplusplus
  126. }
  127. #endif /* __cplusplus */
  128. #endif /* __IRTLDBG_H__ */