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.

166 lines
2.7 KiB

  1. /*++
  2. Microsoft Windows NT RPC Name Service
  3. Copyright (C) Microsoft Corporation, 1995 - 1999
  4. Module Name:
  5. debug.hxx
  6. Abstract:
  7. This module contains
  8. 1. a definition of the CDebugStream class which is used to
  9. produce debugging output.
  10. 2. an ASSERT macro.
  11. 3. definitions of new and delete
  12. Author:
  13. Satish Thatte (SatishT) 08/16/95 Created all the code below except where
  14. otherwise indicated.
  15. --*/
  16. #ifndef _DEBUG_HXX_
  17. #define _DEBUG_HXX_
  18. #include <stdio.h>
  19. #include <objbase.h>
  20. #if DBG
  21. #else
  22. #include <malloc.h>
  23. #endif
  24. #define API 1
  25. #define OBJECT 2
  26. #define BROADCAST 4
  27. #define SEM 8
  28. #define UTIL 16
  29. #define MEM1 32
  30. #define MEM2 64
  31. #define REFCOUNT 128
  32. #define SEM1 256
  33. #define TRACE 512
  34. #define DIRSVC 1024
  35. #define MEM (MEM1 | MEM2)
  36. #define debugLevel (DIRSVC)
  37. #if DBG
  38. #define DBGOUT(LEVEL,MESSAGE) if ((debugLevel | LEVEL) == debugLevel) debugOut << "Locator:: " << MESSAGE
  39. #undef ASSERT
  40. #define ASSERT(ptr,msg) \
  41. if (!(ptr)) { \
  42. debugOut << msg; \
  43. DebugBreak(); \
  44. }
  45. /*++
  46. Class Definition:
  47. CDebugStream
  48. Abstract:
  49. This is similar to the standard ostream class, except that the
  50. output goes to the debugger.
  51. --*/
  52. class CDebugStream {
  53. public:
  54. CDebugStream& operator<<(ULONG ul) {
  55. WCHAR buffer[20];
  56. swprintf(buffer, TEXT(" %d "), ul);
  57. OutputDebugString(buffer);
  58. return *this;
  59. }
  60. CDebugStream& operator<<(char *sz) {
  61. if (!sz) return *this;
  62. WCHAR buffer[200];
  63. swprintf(buffer, TEXT(" %S "), sz);
  64. OutputDebugString(buffer);
  65. return *this;
  66. }
  67. CDebugStream& operator<<(WCHAR * sz) {
  68. if (!sz) return *this;
  69. OutputDebugString(sz);
  70. return *this;
  71. }
  72. CDebugStream& operator<<(NSI_SERVER_BINDING_VECTOR_T * pbvt);
  73. CDebugStream& operator<<(NSI_UUID_T * pUUID);
  74. CDebugStream& operator<<(NSI_SYNTAX_ID_T * pIF_ID);
  75. CDebugStream& operator<<(NSI_UUID_VECTOR_T * pObjVect);
  76. };
  77. extern CDebugStream debugOut; // this carries no state
  78. #else
  79. #define DBGOUT(LEVEL,MESSAGE) {}
  80. #undef ASSERT
  81. #define ASSERT(ptr,msg)
  82. #endif
  83. inline void *
  84. __cdecl
  85. operator new (size_t len)
  86. {
  87. //#if DBG
  88. // void* pResult = CoTaskMemAlloc(len);
  89. // void* pResult = malloc(len);
  90. //#else
  91. void* pResult = malloc(len);
  92. //#endif
  93. if (pResult) return pResult;
  94. else RaiseException(
  95. NSI_S_OUT_OF_MEMORY,
  96. EXCEPTION_NONCONTINUABLE,
  97. 0,
  98. NULL
  99. );
  100. // the following just keeps the compiler happy
  101. return NULL;
  102. }
  103. inline void
  104. __cdecl
  105. operator delete(void * ptr)
  106. {
  107. //#if DBG
  108. // CoTaskMemFree(ptr);
  109. // free(ptr);
  110. //#else
  111. free(ptr);
  112. //#endif
  113. }
  114. #endif _DEBUG_HXX_