forked from dmoulding/vld
/
vldapi.cpp
156 lines (127 loc) · 4.08 KB
/
vldapi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
////////////////////////////////////////////////////////////////////////////////
//
// Visual Leak Detector - Exported APIs
// Copyright (c) 2005-2014 VLD Team
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
//
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#define VLDBUILD // Declares that we are building Visual Leak Detector.
#include "vldint.h" // Provides access to the Visual Leak Detector internals.
#include "vldheap.h" // Provides internal new and delete operators.
// Imported global variables.
extern VisualLeakDetector g_vld;
////////////////////////////////////////////////////////////////////////////////
//
// Visual Leak Detector APIs - see vldapi.h for each function's details.
//
extern "C" {
__declspec(dllexport) void VLDDisable ()
{
g_vld.DisableLeakDetection();
}
__declspec(dllexport) void VLDEnable ()
{
g_vld.EnableLeakDetection();
}
__declspec(dllexport) void VLDRestore ()
{
g_vld.RestoreLeakDetectionState();
}
__declspec(dllexport) void VLDGlobalDisable ()
{
g_vld.GlobalDisableLeakDetection();
}
__declspec(dllexport) void VLDGlobalEnable ()
{
g_vld.GlobalEnableLeakDetection();
}
__declspec(dllexport) UINT VLDReportLeaks ()
{
return (UINT)g_vld.ReportLeaks();
}
__declspec(dllexport) UINT VLDReportThreadLeaks (UINT threadId)
{
return (UINT)g_vld.ReportThreadLeaks(threadId);
}
__declspec(dllexport) UINT VLDGetLeaksCount ()
{
return (UINT)g_vld.GetLeaksCount();
}
__declspec(dllexport) UINT VLDGetThreadLeaksCount (UINT threadId)
{
return (UINT)g_vld.GetThreadLeaksCount(threadId);
}
__declspec(dllexport) void VLDMarkAllLeaksAsReported ()
{
g_vld.MarkAllLeaksAsReported();
}
__declspec(dllexport) void VLDMarkThreadLeaksAsReported (UINT threadId)
{
g_vld.MarkThreadLeaksAsReported(threadId);
}
__declspec(dllexport) void VLDRefreshModules()
{
g_vld.RefreshModules();
}
__declspec(dllexport) void VLDEnableModule(HMODULE module)
{
g_vld.EnableModule(module);
}
__declspec(dllexport) void VLDDisableModule(HMODULE module)
{
g_vld.DisableModule(module);
}
__declspec(dllexport) UINT VLDGetOptions()
{
return g_vld.GetOptions();
}
__declspec(dllexport) void VLDGetReportFilename(WCHAR *filename)
{
g_vld.GetReportFilename(filename);
}
__declspec(dllexport) void VLDSetOptions(UINT option_mask, SIZE_T maxDataDump, UINT maxTraceFrames)
{
g_vld.SetOptions(option_mask, maxDataDump, maxTraceFrames);
}
__declspec(dllexport) int VLDSetReportHook(int mode, VLD_REPORT_HOOK pfnNewHook)
{
return g_vld.SetReportHook(mode, pfnNewHook);
}
__declspec(dllexport) void VLDSetModulesList(CONST WCHAR *modules, BOOL includeModules)
{
g_vld.SetModulesList(modules, includeModules);
}
__declspec(dllexport) BOOL VLDGetModulesList(WCHAR *modules, UINT size)
{
return g_vld.GetModulesList(modules, size);
}
__declspec(dllexport) void VLDSetReportOptions(UINT option_mask, CONST WCHAR *filename)
{
g_vld.SetReportOptions(option_mask,filename);
}
__declspec(dllexport) int VLDResolveCallstacks()
{
return g_vld.ResolveCallstacks();
}
/// Internal function for tests. Not safe to use because Vld own returned string
__declspec(dllexport) const wchar_t* VldInternalGetAllocationCallstack(void* alloc, BOOL showInternalFrames)
{
return g_vld.GetAllocationResolveResults(alloc, showInternalFrames);
}
}