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.

84 lines
2.0 KiB

  1. /*****************************************************************************
  2. *
  3. * $Workfile: debug.h $
  4. *
  5. * Copyright (C) 1997 Hewlett-Packard Company.
  6. * Copyright (C) 1997 Microsoft Corporation.
  7. * All rights reserved.
  8. *
  9. * 11311 Chinden Blvd.
  10. * Boise, Idaho 83714
  11. *
  12. *****************************************************************************/
  13. #ifndef INC_DEBUG_H
  14. #define INC_DEBUG_H
  15. #include <crtdbg.h> // debug functions
  16. #define in
  17. #define out
  18. #define inout
  19. ///////////////////////////////////////////////////////////////////////////////
  20. // Global definitions/declerations
  21. extern HANDLE g_hDebugFile;
  22. ///////////////////////////////////////////////////////////////////////////////
  23. // function prototypes
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. void InitDebug( LPTSTR pszDebugFile );
  28. void DeInitDebug(void);
  29. void debugRPT(char *p, int i);
  30. void debugCSect(char *p, int i, char *fileName, int lineNum, LONG csrc);
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34. ///////////////////////////////////////////////////////////////////////////////
  35. // debug macros
  36. #define MON_DEBUG_FILE __TEXT("c:\\tmp\\DebugMon.out")
  37. #define MONUI_DEBUG_FILE __TEXT("c:\\tmp\\UIDbgMon.out")
  38. #ifdef IS_INTEL
  39. #define BREAK { if ( CreateFile((LPCTSTR)__TEXT("c:\\tmp\\breakmon.on"), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, \
  40. FILE_ATTRIBUTE_NORMAL, 0) == INVALID_HANDLE_VALUE) \
  41. { } \
  42. else { { _asm { int 3h } } } \
  43. }
  44. #else
  45. #define BREAK {}
  46. #endif
  47. #if defined NDEBUG
  48. #ifdef BREAK
  49. #undef BREAK
  50. #define BREAK
  51. #endif
  52. #endif
  53. ///////////////////////////////////////////////////////////////////////////////
  54. // memory watch routines
  55. class CMemoryDebug
  56. {
  57. public:
  58. CMemoryDebug();
  59. ~CMemoryDebug();
  60. // override new & delete to keep track of memory usage
  61. void* operator new(size_t s);
  62. void operator delete( void *p,
  63. size_t s ); // 2nd parameter optional
  64. private:
  65. static DWORD m_dwMemUsed;
  66. };
  67. #endif // INC_DEBUG_H