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.

82 lines
2.1 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1993-1995
  4. * TITLE: DEBUG.H
  5. * VERSION: 1.0
  6. * AUTHOR: jsenior
  7. * DATE: 10/28/1998
  8. *
  9. ********************************************************************************
  10. *
  11. * CHANGE LOG:
  12. *
  13. * DATE REV DESCRIPTION
  14. * ---------- ------- ----------------------------------------------------------
  15. * 10/28/1998 jsenior Original implementation.
  16. *
  17. *******************************************************************************/
  18. #ifndef _USBDEBUG_H
  19. #define _USBDEBUG_H
  20. void TRACE(LPCTSTR Format, ...);
  21. void AddMemoryChunk(PVOID Mem, PTCHAR File, ULONG Line);
  22. void RemoveMemoryChunk(PVOID Mem, PTCHAR File, ULONG Line);
  23. void DumpOrphans();
  24. HLOCAL
  25. UsbAllocPrivate(const TCHAR *File, ULONG Line, ULONG Flags, DWORD dwBytes);
  26. HLOCAL
  27. UsbReAllocPrivate(const TCHAR *File, ULONG Line, HLOCAL hMem, DWORD dwBytes, ULONG Flags);
  28. HLOCAL
  29. UsbFreePrivate(HLOCAL hMem);
  30. VOID
  31. UsbCheckForLeaksPrivate(VOID);
  32. #if DBG
  33. #define LERROR 1
  34. #define LWARN 2
  35. #define LTRACE 3
  36. #define LINFO 4
  37. extern ULONG USBUI_Debug_Trace_Level;
  38. #define USBUI_Print(l, _x_) if ((l) <= USBUI_Debug_Trace_Level) \
  39. { TRACE (_T("USBUI: ")); \
  40. TRACE _x_; }
  41. #define USBWARN(_x_) USBUI_Print(LWARN, _x_)
  42. #define USBERROR(_x_) USBUI_Print(LERROR, _x_)
  43. #define USBTRACE(_x_) USBUI_Print(LTRACE, _x_)
  44. #define USBINFO(_x_) USBUI_Print(LINFO, _x_)
  45. //
  46. // New and Delete memory tracking
  47. //
  48. #define AddChunk(mem) AddMemoryChunk((PVOID) mem, TEXT(__FILE__), __LINE__)
  49. #define DeleteChunk(mem) RemoveMemoryChunk((PVOID) mem, TEXT(__FILE__), __LINE__)
  50. #define CheckMemory() DumpOrphans()
  51. //
  52. // LocalAlloc memory tracking
  53. #define LocalAlloc(flags, dwBytes) UsbAllocPrivate(TEXT(__FILE__), __LINE__, flags, (dwBytes))
  54. #define LocalFree(hMem) UsbFreePrivate((hMem))
  55. #else // DBG
  56. #define USBUI_Print(l, _x_)
  57. #define USBWARN(_x_)
  58. #define USBERROR(_x_)
  59. #define USBTRACE(_x_)
  60. #define USBINFO(_x_)
  61. //
  62. // New and delete memory tracking
  63. #define AddChunk(mem)
  64. #define DeleteChunk(mem)
  65. #define CheckMemory()
  66. #endif
  67. #endif // _USBDEBUG_H