vld.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // $Id: vld.h,v 1.15.2.1 2005/08/03 23:13:47 dmouldin Exp $
  3. //
  4. // Visual Leak Detector (Version 1.0)
  5. // Copyright (c) 2005 Dan Moulding
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU Lesser General Public License as published by
  9. // the Free Software Foundation; either version 2.1 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU Lesser General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU Lesser General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. //
  21. // See COPYING.txt for the full terms of the GNU Lesser General Public License.
  22. //
  23. ////////////////////////////////////////////////////////////////////////////////
  24. #pragma once
  25. #ifdef _DEBUG
  26. ////////////////////////////////////////////////////////////////////////////////
  27. //
  28. // Configuration Options
  29. //
  30. // Configuration flags
  31. #define VLD_CONFIG_AGGREGATE_DUPLICATES 0x1
  32. #define VLD_CONFIG_SELF_TEST 0x2
  33. #define VLD_CONFIG_SHOW_USELESS_FRAMES 0x4
  34. #define VLD_CONFIG_START_DISABLED 0x8
  35. #ifndef VLDBUILD
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif // __cplusplus
  39. // If VLD_AGGREGATE_DUPLICATES is defined, then duplicated leaks (those that
  40. // have the same size and call stack as a previously identified leak) are not
  41. // shown in detail in the memory leak report. Instead, only a count of the
  42. // number of matching duplicate leaks is shown along with the detailed
  43. // information from the first such leak encountered.
  44. #ifdef VLD_AGGREGATE_DUPLICATES
  45. #define VLD_FLAG_AGGREGATE_DUPLICATES VLD_CONFIG_AGGREGATE_DUPLICATES
  46. #else
  47. #define VLD_FLAG_AGGREGATE_DUPLICATES 0x0
  48. #endif // VLD_AGGREGATE_DUPLICATES
  49. // If VLD_MAX_DATA_DUMP is defined, then the amount of data shown in user-data
  50. // memory dumps will be limited to the specified number of bytes.
  51. #ifdef VLD_MAX_DATA_DUMP
  52. unsigned long _VLD_maxdatadump = VLD_MAX_DATA_DUMP;
  53. #else
  54. unsigned long _VLD_maxdatadump = 0xffffffff;
  55. #endif // VLD_MAX_DATA_DUMP
  56. // If VLD_MAX_TRACE_FRAMES is defined, then the number of frames traced for each
  57. // allocated memory block when walking the stack will be limited to the
  58. // specified number of frames.
  59. #ifdef VLD_MAX_TRACE_FRAMES
  60. unsigned long _VLD_maxtraceframes = VLD_MAX_TRACE_FRAMES;
  61. #else
  62. unsigned long _VLD_maxtraceframes = 0xffffffff;
  63. #endif // VLD_MAX_TRACE_FRAMES
  64. // If VLD_SELF_TEST is defined, then Visual Leak Detector will perform a memory
  65. // leak self-test, by intentionally leaking memory, to ensure that it is able to
  66. // correctly detect memory leaks internal to Visual Leak Detector.
  67. #ifdef VLD_SELF_TEST
  68. #define VLD_FLAG_SELF_TEST VLD_CONFIG_SELF_TEST
  69. #else
  70. #define VLD_FLAG_SELF_TEST 0x0
  71. #endif // VLD_SELF_TEST
  72. // If VLD_SHOW_USELESS_FRAMES is defined, then all frames traced will be
  73. // displayed, even frames internal to the heap and Visual Leak Detector.
  74. #ifdef VLD_SHOW_USELESS_FRAMES
  75. #define VLD_FLAG_SHOW_USELESS_FRAMES VLD_CONFIG_SHOW_USELESS_FRAMES
  76. #else
  77. #define VLD_FLAG_SHOW_USELESS_FRAMES 0x0
  78. #endif // VLD_SHOW_USELESS_FRAMES
  79. // If VLD_START_DISABLED is defined, then Visual Leak Detector will initially
  80. // be disabled for all threads.
  81. #ifdef VLD_START_DISABLED
  82. #define VLD_FLAG_START_DISABLED VLD_CONFIG_START_DISABLED
  83. #else
  84. #define VLD_FLAG_START_DISABLED 0x0
  85. #endif // VLD_START_DISABLED
  86. // Initialize the configuration flags based on defined preprocessor macros.
  87. unsigned _VLD_configflags = VLD_FLAG_AGGREGATE_DUPLICATES | VLD_FLAG_SELF_TEST |
  88. VLD_FLAG_SHOW_USELESS_FRAMES | VLD_FLAG_START_DISABLED;
  89. #ifdef __cplusplus
  90. }
  91. #endif // __cplusplus
  92. ////////////////////////////////////////////////////////////////////////////////
  93. //
  94. // Linker Directives
  95. //
  96. // Link with the appropriate Visual Leak Detector library. One of: multithreaded
  97. // DLL, multithreaded static, or single threaded. All three link with debug
  98. // versions of the CRT.
  99. #ifdef _DLL
  100. #pragma comment (lib, "vldmtdll.lib")
  101. #else
  102. #ifdef _MT
  103. #pragma comment (lib, "vldmt.lib")
  104. #else
  105. #pragma comment (lib, "vld.lib")
  106. #endif // _MT
  107. #endif // _DLL
  108. // Force a symbolic reference to the global VisualLeakDetector class object from
  109. // the library. This enusres that the object is linked with the program, even
  110. // though nobody directly references it outside of the library.
  111. #pragma comment(linker, "/include:?visualleakdetector@@3VVisualLeakDetector@@A")
  112. #endif // VLDBUILD
  113. #endif // _DEBUG