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.

96 lines
4.3 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: CritsecTracking.h
  6. * Content: Debug critical section tracking for detecting leaks, nesting, etc.
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 1/10/2002 masonb Created
  12. *
  13. ***************************************************************************/
  14. #ifndef __CRITSECTRACKING_H__
  15. #define __CRITSECTRACKING_H__
  16. #include "callstack.h"
  17. #include "classbilink.h"
  18. #ifdef DPNBUILD_ONLYONETHREAD
  19. #define DNEnterCriticalSection( arg )
  20. #define DNLeaveCriticalSection( arg )
  21. #define DNInitializeCriticalSection( pCriticalSection ) TRUE
  22. #define DNDeleteCriticalSection( pCriticalSection )
  23. #define DebugSetCriticalSectionRecursionCount( pCS, Count )
  24. #define DebugSetCriticalSectionGroup( pCS, pblGroup )
  25. #define DebugSetCriticalSectionLockOrder( pCS, dwLockOrder )
  26. #define AssertCriticalSectionIsTakenByThisThread( pCS, Flag )
  27. #define AssertNoCriticalSectionsTakenByThisThread()
  28. #define AssertNoCriticalSectionsFromGroupTakenByThisThread( pblGroup )
  29. #else // !DPNBUILD_ONLYONETHREAD
  30. #ifdef DBG
  31. struct DNCRITICAL_SECTION
  32. {
  33. CRITICAL_SECTION CriticalSection;
  34. UINT_PTR OwningThreadID;
  35. UINT_PTR MaxLockCount;
  36. UINT_PTR LockCount;
  37. CCallStack CallStack;
  38. CCallStack AllocCallStack;
  39. CBilink blAllCritSecs;
  40. CBilink blCritSecsHeld;
  41. CBilink * pblCritSecsHeldGroup;
  42. DWORD dwLockOrder;
  43. };
  44. BOOL DNCSTrackInitialize();
  45. void DNCSTrackDeinitialize();
  46. BOOL DNCSTrackDumpLeaks();
  47. BOOL DNCSTrackInitializeCriticalSection( DNCRITICAL_SECTION *const pCriticalSection );
  48. void DNCSTrackDeleteCriticalSection( DNCRITICAL_SECTION *const pCriticalSection );
  49. void DNCSTrackEnterCriticalSection( DNCRITICAL_SECTION *const pCriticalSection );
  50. void DNCSTrackLeaveCriticalSection( DNCRITICAL_SECTION *const pCriticalSection );
  51. void DNCSTrackSetCriticalSectionRecursionCount( DNCRITICAL_SECTION *const pCriticalSection, const UINT_PTR RecursionCount );
  52. void DNCSTrackSetCriticalSectionGroup( DNCRITICAL_SECTION *const pCriticalSection, CBilink * const pblGroup );
  53. void DNCSTrackSetCriticalSectionLockOrder( DNCRITICAL_SECTION *const pCriticalSection, const DWORD dwLockOrder );
  54. void DNCSTrackCriticalSectionIsTakenByThisThread( const DNCRITICAL_SECTION *const pCriticalSection, const BOOL fFlag );
  55. void DNCSTrackNoCriticalSectionsTakenByThisThread( CBilink * pblGroup );
  56. #define DNInitializeCriticalSection( arg ) DNCSTrackInitializeCriticalSection( arg )
  57. #define DNDeleteCriticalSection( arg ) DNCSTrackDeleteCriticalSection( arg )
  58. #define DNEnterCriticalSection( arg ) DNCSTrackEnterCriticalSection( arg )
  59. #define DNLeaveCriticalSection( arg ) DNCSTrackLeaveCriticalSection( arg )
  60. #define DebugSetCriticalSectionRecursionCount( pCS, Count ) DNCSTrackSetCriticalSectionRecursionCount( pCS, Count )
  61. #define DebugSetCriticalSectionGroup( pCS, pblGroup ) DNCSTrackSetCriticalSectionGroup( pCS, pblGroup )
  62. #define DebugSetCriticalSectionLockOrder( pCS, dwLockOrder ) DNCSTrackSetCriticalSectionLockOrder( pCS, dwLockOrder )
  63. #define AssertCriticalSectionIsTakenByThisThread( pCS, Flag ) DNCSTrackCriticalSectionIsTakenByThisThread( pCS, Flag )
  64. #define AssertNoCriticalSectionsTakenByThisThread() DNCSTrackNoCriticalSectionsTakenByThisThread( NULL )
  65. #define AssertNoCriticalSectionsFromGroupTakenByThisThread( pblGroup ) DNCSTrackNoCriticalSectionsTakenByThisThread( pblGroup )
  66. #else // !DBG
  67. #define DNCRITICAL_SECTION CRITICAL_SECTION
  68. #define DNInitializeCriticalSection( arg ) DNOSInitializeCriticalSection( arg )
  69. #define DNDeleteCriticalSection( arg ) DeleteCriticalSection( arg )
  70. #define DNEnterCriticalSection( arg ) EnterCriticalSection( arg )
  71. #define DNLeaveCriticalSection( arg ) LeaveCriticalSection( arg )
  72. #define DebugSetCriticalSectionRecursionCount( pCS, Count )
  73. #define DebugSetCriticalSectionGroup( pCS, pblGroup )
  74. #define DebugSetCriticalSectionLockOrder( pCS, dwLockOrder )
  75. #define AssertCriticalSectionIsTakenByThisThread( pCS, Flag )
  76. #define AssertNoCriticalSectionsTakenByThisThread()
  77. #define AssertNoCriticalSectionsFromGroupTakenByThisThread( pblGroup )
  78. #endif // DBG
  79. #endif // DPNBUILD_ONLYONETHREAD
  80. #endif // __CRITSECTRACKING_H__