ReactOS 0.4.16-dev-1020-gf135cab
crtdbg.h
Go to the documentation of this file.
1//
2// crtdbg.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Public debugging facilities for the CRT
7//
8#pragma once
9#ifndef _INC_CRTDBG // include guard for 3rd party interop
10#define _INC_CRTDBG
11
12#include <corecrt.h>
13#include <vcruntime_new_debug.h>
14#include <intrin.h> // for __debugbreak() on GCC
15
16#pragma warning(push)
17#pragma warning(disable: _UCRT_DISABLED_WARNINGS)
19
21
22
23
24typedef void* _HFILE; // file handle pointer
25
26#define _CRT_WARN 0
27#define _CRT_ERROR 1
28#define _CRT_ASSERT 2
29#define _CRT_ERRCNT 3
30
31#define _CRTDBG_MODE_FILE 0x1
32#define _CRTDBG_MODE_DEBUG 0x2
33#define _CRTDBG_MODE_WNDW 0x4
34#define _CRTDBG_REPORT_MODE -1
35
36#define _CRTDBG_INVALID_HFILE ((_HFILE)(intptr_t)-1)
37#define _CRTDBG_HFILE_ERROR ((_HFILE)(intptr_t)-2)
38#define _CRTDBG_FILE_STDOUT ((_HFILE)(intptr_t)-4)
39#define _CRTDBG_FILE_STDERR ((_HFILE)(intptr_t)-5)
40#define _CRTDBG_REPORT_FILE ((_HFILE)(intptr_t)-6)
41
42
43
44//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45//
46// Client-defined reporting and allocation hooks
47//
48//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49
50typedef int (__CRTDECL* _CRT_REPORT_HOOK )(int, char*, int*);
51typedef int (__CRTDECL* _CRT_REPORT_HOOKW)(int, wchar_t*, int*);
52
53#define _CRT_RPTHOOK_INSTALL 0
54#define _CRT_RPTHOOK_REMOVE 1
55
56
57typedef int (__CRTDECL* _CRT_ALLOC_HOOK)(int, void*, size_t, int, long, unsigned char const*, int);
58
59#ifdef _M_CEE
60 typedef int (__clrcall* _CRT_ALLOC_HOOK_M)(int, void*, size_t, int, long, unsigned char const*, int);
61#endif
62
63#define _HOOK_ALLOC 1
64#define _HOOK_REALLOC 2
65#define _HOOK_FREE 3
66
67
68
69//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70//
71// Memory Management and State Tracking
72//
73//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74
75// Bit values for _crtDbgFlag flag. These bitflags control debug heap behavior.
76#define _CRTDBG_ALLOC_MEM_DF 0x01 // Turn on debug allocation
77#define _CRTDBG_DELAY_FREE_MEM_DF 0x02 // Don't actually free memory
78#define _CRTDBG_CHECK_ALWAYS_DF 0x04 // Check heap every alloc/dealloc
79#define _CRTDBG_RESERVED_DF 0x08 // Reserved - do not use
80#define _CRTDBG_CHECK_CRT_DF 0x10 // Leak check/diff CRT blocks
81#define _CRTDBG_LEAK_CHECK_DF 0x20 // Leak check at program exit
82
83// Some bit values for _crtDbgFlag which correspond to frequencies for checking
84// the heap.
85#define _CRTDBG_CHECK_EVERY_16_DF 0x00100000 // Check heap every 16 heap ops
86#define _CRTDBG_CHECK_EVERY_128_DF 0x00800000 // Check heap every 128 heap ops
87#define _CRTDBG_CHECK_EVERY_1024_DF 0x04000000 // Check heap every 1024 heap ops
88
89// We do not check the heap by default at this point because the cost was too
90// high for some applications. You can still turn this feature on manually.
91#define _CRTDBG_CHECK_DEFAULT_DF 0
92
93#define _CRTDBG_REPORT_FLAG -1 // Query bitflag status
94
95#define _BLOCK_TYPE(block) (block & 0xFFFF)
96#define _BLOCK_SUBTYPE(block) (block >> 16 & 0xFFFF)
97
98// Memory block identification
99#define _FREE_BLOCK 0
100#define _NORMAL_BLOCK 1
101#define _CRT_BLOCK 2
102#define _IGNORE_BLOCK 3
103#define _CLIENT_BLOCK 4
104#define _MAX_BLOCKS 5
105
106// _UNKNOWN_BLOCK is a sentinel value that may be passed to some functions that
107// expect a block type as an argument. If this value is passed, those functions
108// will use the block type specified in the block header instead. This is used
109// in cases where the heap lock cannot be acquired to compute the block type
110// before calling the function (e.g. when the caller is outside of the CoreCRT).
111#define _UNKNOWN_BLOCK (-1)
112
114
115#ifdef _M_CEE
116 typedef void (__clrcall* _CRT_DUMP_CLIENT_M)(void*, size_t);
117#endif
118
119struct _CrtMemBlockHeader;
120
121typedef struct _CrtMemState
122{
124 size_t lCounts[_MAX_BLOCKS];
125 size_t lSizes[_MAX_BLOCKS];
126 size_t lHighWaterCount;
127 size_t lTotalCount;
129
130#ifndef _DEBUG
131
132 #define _CrtGetAllocHook() ((_CRT_ALLOC_HOOK)0)
133 #define _CrtSetAllocHook(f) ((_CRT_ALLOC_HOOK)0)
134
135 #define _CrtGetDumpClient() ((_CRT_DUMP_CLIENT)0)
136 #define _CrtSetDumpClient(f) ((_CRT_DUMP_CLIENT)0)
137
138 #define _CrtCheckMemory() ((int)1)
139 #define _CrtDoForAllClientObjects(f, c) ((void)0)
140 #define _CrtDumpMemoryLeaks() ((int)0)
141 #define _CrtIsMemoryBlock(p, t, r, f, l) ((int)1)
142 #define _CrtIsValidHeapPointer(p) ((int)1)
143 #define _CrtIsValidPointer(p, n, r) ((int)1)
144 #define _CrtMemCheckpoint(s) ((void)0)
145 #define _CrtMemDifference(s1, s2, s3) ((int)0)
146 #define _CrtMemDumpAllObjectsSince(s) ((void)0)
147 #define _CrtMemDumpStatistics(s) ((void)0)
148 #define _CrtReportBlockType(p) ((int)-1)
149 #define _CrtSetBreakAlloc(a) ((long)0)
150 #define _CrtSetDbgFlag(f) ((int)0)
151
152
153#else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
154
155 #ifndef _M_CEE_PURE
156
159
160 #define _crtDbgFlag (*__p__crtDbgFlag())
161 #define _crtBreakAlloc (*__p__crtBreakAlloc())
162
164
166 _In_opt_ _CRT_ALLOC_HOOK _PfnNewHook
167 );
168
170
172 _In_opt_ _CRT_DUMP_CLIENT _PFnNewDump
173 );
174
175 #endif // _M_CEE_PURE
176
178
179 typedef void (__cdecl* _CrtDoForAllClientObjectsCallback)(void*, void*);
180
182 _In_ _CrtDoForAllClientObjectsCallback _Callback,
183 _In_ void* _Context
184 );
185
187
189 _In_opt_ void const* _Block,
190 _In_ unsigned int _Size,
191 _Out_opt_ long* _RequestNumber,
192 _Out_opt_ char** _FileName,
193 _Out_opt_ int* _LineNumber
194 );
195
198 _In_opt_ void const* _Pointer
199 );
200
203 _In_opt_ void const* _Pointer,
204 _In_ unsigned int _Size,
205 _In_ int _ReadWrite
206 );
207
209 _Out_ _CrtMemState* _State
210 );
211
213 _Out_ _CrtMemState* _State,
214 _In_ _CrtMemState const* _OldState,
215 _In_ _CrtMemState const* _NewState
216 );
217
219 _In_opt_ _CrtMemState const* _State
220 );
221
223 _In_ _CrtMemState const* _State
224 );
225
228 _In_opt_ void const* _Block
229 );
230
232 _In_ long _NewValue
233 );
234
236 _In_ int _NewFlag
237 );
238
239#endif // _DEBUG
240
241
242
243//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
244//
245// Debug Heap Routines
246//
247//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248#ifndef _DEBUG
249
250 #define _calloc_dbg(c, s, t, f, l) calloc(c, s)
251 #define _expand_dbg(p, s, t, f, l) _expand(p, s)
252 #define _free_dbg(p, t) free(p)
253 #define _malloc_dbg(s, t, f, l) malloc(s)
254 #define _msize_dbg(p, t) _msize(p)
255 #define _realloc_dbg(p, s, t, f, l) realloc(p, s)
256 #define _recalloc_dbg(p, c, s, t, f, l) _recalloc(p, c, s)
257
258 #define _aligned_free_dbg(p) _aligned_free(p)
259 #define _aligned_malloc_dbg(s, a, f, l) _aligned_malloc(s, a)
260 #define _aligned_msize_dbg(p, a, o) _aligned_msize(p, a, o)
261 #define _aligned_offset_malloc_dbg(s, a, o, f, l) _aligned_offset_malloc(s, a, o)
262 #define _aligned_offset_realloc_dbg(p, s, a, o, f, l) _aligned_offset_realloc(p, s, a, o)
263 #define _aligned_offset_recalloc_dbg(p, c, s, a, o, f, l) _aligned_offset_recalloc(p, c, s, a, o)
264 #define _aligned_realloc_dbg(p, s, a, f, l) _aligned_realloc(p, s, a)
265 #define _aligned_recalloc_dbg(p, c, s, a, f, l) _aligned_recalloc(p, c, s, a)
266
267 #define _freea_dbg(p, t) _freea(p)
268 #define _malloca_dbg(s, t, f, l) _malloca(s)
269
270 #define _dupenv_s_dbg(ps1, size, s2, t, f, l) _dupenv_s(ps1, size, s2)
271 #define _fullpath_dbg(s1, s2, le, t, f, l) _fullpath(s1, s2, le)
272 #define _getcwd_dbg(s, le, t, f, l) _getcwd(s, le)
273 #define _getdcwd_dbg(d, s, le, t, f, l) _getdcwd(d, s, le)
274 #define _getdcwd_lk_dbg(d, s, le, t, f, l) _getdcwd(d, s, le)
275 #define _mbsdup_dbg(s, t, f, l) _mbsdup(s)
276 #define _strdup_dbg(s, t, f, l) _strdup(s)
277 #define _tempnam_dbg(s1, s2, t, f, l) _tempnam(s1, s2)
278 #define _wcsdup_dbg(s, t, f, l) _wcsdup(s)
279 #define _wdupenv_s_dbg(ps1, size, s2, t, f, l) _wdupenv_s(ps1, size, s2)
280 #define _wfullpath_dbg(s1, s2, le, t, f, l) _wfullpath(s1, s2, le)
281 #define _wgetcwd_dbg(s, le, t, f, l) _wgetcwd(s, le)
282 #define _wgetdcwd_dbg(d, s, le, t, f, l) _wgetdcwd(d, s, le)
283 #define _wgetdcwd_lk_dbg(d, s, le, t, f, l) _wgetdcwd(d, s, le)
284 #define _wtempnam_dbg(s1, s2, t, f, l) _wtempnam(s1, s2)
285
286#else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
287
288 #ifdef _CRTDBG_MAP_ALLOC
289
290 #define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
291 #define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
292 #define free(p) _free_dbg(p, _NORMAL_BLOCK)
293 #define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
294 #define _msize(p) _msize_dbg(p, _NORMAL_BLOCK)
295 #define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
296 #define _recalloc(p, c, s) _recalloc_dbg(p, c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
297
298 #define _aligned_free(p) _aligned_free_dbg(p)
299 #define _aligned_malloc(s, a) _aligned_malloc_dbg(s, a, __FILE__, __LINE__)
300 #define _aligned_msize(p, a, o) _aligned_msize_dbg(p, a, o)
301 #define _aligned_offset_malloc(s, a, o) _aligned_offset_malloc_dbg(s, a, o, __FILE__, __LINE__)
302 #define _aligned_offset_realloc(p, s, a, o) _aligned_offset_realloc_dbg(p, s, a, o, __FILE__, __LINE__)
303 #define _aligned_offset_recalloc(p, c, s, a, o) _aligned_offset_recalloc_dbg(p, c, s, a, o, __FILE__, __LINE__)
304 #define _aligned_realloc(p, s, a) _aligned_realloc_dbg(p, s, a, __FILE__, __LINE__)
305 #define _aligned_recalloc(p, c, s, a) _aligned_recalloc_dbg(p, c, s, a, __FILE__, __LINE__)
306
307 #define _freea(p) _freea_dbg(p, _NORMAL_BLOCK)
308 #define _malloca(s) _malloca_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
309
310 #define _dupenv_s(ps1, size, s2) _dupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
311 #define _fullpath(s1, s2, le) _fullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__)
312 #define _getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
313 #define _getdcwd(d, s, le) _getdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
314 #define _mbsdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
315 #define _strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
316 #define _tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
317 #define _wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
318 #define _wdupenv_s(ps1, size, s2) _wdupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
319 #define _wfullpath(s1, s2, le) _wfullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__)
320 #define _wgetcwd(s, le) _wgetcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
321 #define _wgetdcwd(d, s, le) _wgetdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
322 #define _wtempnam(s1, s2) _wtempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
323
324 #if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES
325 #define strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
326 #define wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
327 #define tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
328 #define getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
329 #endif
330
331 #endif // _CRTDBG_MAP_ALLOC
332
335 );
336
339 _In_ size_t _Size,
340 _In_ size_t _Alignment,
341 _In_opt_z_ char const* _FileName,
342 _In_ int _LineNumber
343 );
344
346 _Pre_notnull_ void* _Block,
347 _In_ size_t _Alignment,
348 _In_ size_t _Offset
349 );
350
353 _In_ size_t _Size,
354 _In_ size_t _Alignment,
355 _In_ size_t _Offset,
356 _In_opt_z_ char const* _FileName,
357 _In_ int _LineNumber
358 );
359
362 _Pre_maybenull_ _Post_invalid_ void* _Block,
363 _In_ size_t _Size,
364 _In_ size_t _Alignment,
365 _In_ size_t _Offset,
367 _In_ int _LineNumber
368 );
369
372 _Pre_maybenull_ _Post_invalid_ void* _Block,
373 _In_ size_t _Count,
374 _In_ size_t _Size,
375 _In_ size_t _Alignment,
376 _In_ size_t _Offset,
378 _In_ int _LineNumber
379 );
380
383 _Pre_maybenull_ _Post_invalid_ void* _Block,
384 _In_ size_t _Size,
385 _In_ size_t _Alignment,
387 _In_ int _LineNumber
388 );
389
392 _Pre_maybenull_ _Post_invalid_ void* _Block,
393 _In_ size_t _Count,
394 _In_ size_t _Size,
395 _In_ size_t _Alignment,
397 _In_ int _LineNumber
398 );
399
402 _In_ size_t _Count,
403 _In_ size_t _Size,
404 _In_ int _BlockUse,
406 _In_ int _LineNumber
407 );
408
411 _Pre_notnull_ void* _Block,
412 _In_ size_t _Size,
413 _In_ int _BlockUse,
415 _In_ int _LineNumber
416 );
417
419 _Pre_maybenull_ _Post_invalid_ void* _Block,
420 _In_ int _BlockUse
421 );
422
425 _In_ size_t _Size,
426 _In_ int _BlockUse,
428 _In_ int _LineNumber
429 );
430
432 _Pre_notnull_ void* _Block,
433 _In_ int _BlockUse
434 );
435
438 _Pre_maybenull_ _Post_invalid_ void* _Block,
439 _In_ size_t _Size,
440 _In_ int _BlockUse,
442 _In_ int _LineNumber
443 );
444
447 _Pre_maybenull_ _Post_invalid_ void* _Block,
448 _In_ size_t _Count,
449 _In_ size_t _Size,
450 _In_ int _BlockUse,
452 _In_ int _LineNumber
453 );
454
455 _Success_(return == 0)
458 _Outptr_result_buffer_maybenull_(*_PBufferSizeInBytes) char** _PBuffer,
459 _Out_opt_ size_t* _PBufferSizeInBytes,
460 _In_z_ char const* _VarName,
461 _In_ int _BlockType,
463 _In_ int _LineNumber
464 );
465
466 _Success_(return != 0)
469 _Out_writes_opt_z_(_SizeInBytes) char* _FullPath,
470 _In_z_ char const* _Path,
471 _In_ size_t _SizeInBytes,
472 _In_ int _BlockType,
474 _In_ int _LineNumber
475 );
476
477 _Success_(return != 0)
480 _Out_writes_opt_z_(_SizeInBytes) char* _DstBuf,
481 _In_ int _SizeInBytes,
482 _In_ int _BlockType,
484 _In_ int _LineNumber
485 );
486
487
488 _Success_(return != 0)
491 _In_ int _Drive,
492 _Out_writes_opt_z_(_SizeInBytes) char* _DstBuf,
493 _In_ int _SizeInBytes,
494 _In_ int _BlockType,
496 _In_ int _LineNumber
497 );
498
502 _In_ int _BlockUse,
504 _In_ int _LineNumber
505 );
506
509 _In_opt_z_ char const* _DirName,
510 _In_opt_z_ char const* _FilePrefix,
511 _In_ int _BlockType,
513 _In_ int _LineNumber
514 );
515
516 _Success_(return != 0)
519 _In_opt_z_ wchar_t const* _String,
520 _In_ int _BlockUse,
522 _In_ int _LineNumber
523 );
524
525 _Success_(return == 0)
528 _Outptr_result_buffer_maybenull_(*_PBufferSizeInWords) wchar_t** _PBuffer,
529 _Out_opt_ size_t* _PBufferSizeInWords,
530 _In_z_ wchar_t const* _VarName,
531 _In_ int _BlockType,
533 _In_ int _LineNumber
534 );
535
536 _Success_(return != 0)
539 _Out_writes_opt_z_(_SizeInWords) wchar_t* _FullPath,
540 _In_z_ wchar_t const* _Path,
541 _In_ size_t _SizeInWords,
542 _In_ int _BlockType,
544 _In_ int _LineNumber
545 );
546
547 _Success_(return != 0)
550 _Out_writes_opt_z_(_SizeInWords) wchar_t* _DstBuf,
551 _In_ int _SizeInWords,
552 _In_ int _BlockType,
554 _In_ int _LineNumber
555 );
556
557 _Success_(return != 0)
560 _In_ int _Drive,
561 _Out_writes_opt_z_(_SizeInWords) wchar_t* _DstBuf,
562 _In_ int _SizeInWords,
563 _In_ int _BlockType,
565 _In_ int _LineNumber
566 );
567
570 _In_opt_z_ wchar_t const* _DirName,
571 _In_opt_z_ wchar_t const* _FilePrefix,
572 _In_ int _BlockType,
574 _In_ int _LineNumber
575 );
576
577 #define _malloca_dbg(s, t, f, l) _malloc_dbg(s, t, f, l)
578 #define _freea_dbg(p, t) _free_dbg(p, t)
579
580 #if defined __cplusplus && defined _CRTDBG_MAP_ALLOC
581 namespace std
582 {
583 using ::_calloc_dbg;
584 using ::_free_dbg;
585 using ::_malloc_dbg;
586 using ::_realloc_dbg;
587 }
588 #endif
589
590#endif // _DEBUG
591
592
593
594//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
595//
596// Debug Reporting
597//
598//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
599
600#ifndef _DEBUG
601
602 #define _CrtSetDebugFillThreshold(t) ((size_t)0)
603 #define _CrtSetReportFile(t, f) ((_HFILE)0)
604 #define _CrtSetReportMode(t, f) ((int)0)
605 #define _CrtGetReportHook() ((_CRT_REPORT_HOOK)0)
606 #define _CrtSetReportHook(f) ((_CRT_REPORT_HOOK)0)
607 #define _CrtSetReportHook2(t, f) ((int)0)
608 #define _CrtSetReportHookW2(t, f) ((int)0)
609
610#else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
611
613 _In_ int _ReportType,
614 _In_opt_z_ char const* _FileName,
615 _In_ int _Linenumber,
616 _In_opt_z_ char const* _ModuleName,
617 _In_opt_z_ char const* _Format,
618 ...);
619
621 _In_ int _ReportType,
622 _In_opt_z_ wchar_t const* _FileName,
623 _In_ int _LineNumber,
624 _In_opt_z_ wchar_t const* _ModuleName,
625 _In_opt_z_ wchar_t const* _Format,
626 ...);
627
628
630 _In_ int _ReportType,
632 _In_opt_z_ char const* _FileName,
633 _In_ int _LineNumber,
634 _In_opt_z_ char const* _ModuleName,
635 _In_opt_z_ char const* _Format,
637 );
638
640 _In_ int _ReportType,
642 _In_opt_z_ wchar_t const* _FileName,
643 _In_ int _LineNumber,
644 _In_opt_z_ wchar_t const* _ModuleName,
645 _In_opt_z_ wchar_t const* _Format,
647 );
648
650 _In_ size_t _NewDebugFillThreshold
651 );
652
654
656 _In_ int _ReportType,
657 _In_opt_ _HFILE _ReportFile
658 );
659
661 _In_ int _ReportType,
662 _In_ int _ReportMode
663 );
664
665 #ifndef _M_CEE_PURE
666
667 extern long _crtAssertBusy;
668
670
671 // _CrtSetReportHook[[W]2]:
672 // For IJW, we need two versions: one for clrcall and one for cdecl.
673 // For pure and native, we just need clrcall and cdecl, respectively.
675 _In_opt_ _CRT_REPORT_HOOK _PFnNewHook
676 );
677
679 _In_ int _Mode,
680 _In_opt_ _CRT_REPORT_HOOK _PFnNewHook
681 );
682
684 _In_ int _Mode,
685 _In_opt_ _CRT_REPORT_HOOKW _PFnNewHook
686 );
687
688 #endif // !_M_CEE_PURE
689
690#endif // _DEBUG
691
692
693
694
695//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
696//
697// Assertions and Error Reporting Macros
698//
699//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
700#ifndef _DEBUG
701
702 #define _CrtDbgBreak() ((void)0)
703
704 #ifndef _ASSERT_EXPR
705 #define _ASSERT_EXPR(expr, msg) ((void)0)
706 #endif
707
708 #ifndef _ASSERT
709 #define _ASSERT(expr) ((void)0)
710 #endif
711
712 #ifndef _ASSERTE
713 #define _ASSERTE(expr) ((void)0)
714 #endif
715
716 #define _RPT0(rptno, msg)
717 #define _RPTN(rptno, msg, ...)
718
719 #define _RPTW0(rptno, msg)
720 #define _RPTWN(rptno, msg, ...)
721
722 #define _RPTF0(rptno, msg)
723 #define _RPTFN(rptno, msg, ...)
724
725 #define _RPTFW0(rptno, msg)
726 #define _RPTFWN(rptno, msg, ...)
727
728#else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
729
730 #define _CrtDbgBreak() __debugbreak()
731
732 // !! is used to ensure that any overloaded operators used to evaluate expr
733 // do not end up at &&.
734 #ifndef _ASSERT_EXPR
735 #define _ASSERT_EXPR(expr, msg) \
736 (void)( \
737 (!!(expr)) || \
738 (1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", msg)) || \
739 (_CrtDbgBreak(), 0) \
740 )
741 #endif
742
743 #ifndef _ASSERT
744 #define _ASSERT(expr) _ASSERT_EXPR((expr), NULL)
745 #endif
746
747 #ifndef _ASSERTE
748 #define _ASSERTE(expr) _ASSERT_EXPR((expr), _CRT_WIDE(#expr))
749 #endif
750
751 #define _RPT_BASE(...) \
752 (void) ((1 != _CrtDbgReport(__VA_ARGS__)) || \
753 (_CrtDbgBreak(), 0))
754
755 #define _RPT_BASE_W(...) \
756 (void) ((1 != _CrtDbgReportW(__VA_ARGS__)) || \
757 (_CrtDbgBreak(), 0))
758
759 #define _RPT0(rptno, msg) _RPT_BASE(rptno, NULL, 0, NULL, "%s", msg)
760 #define _RPTN(rptno, msg, ...) _RPT_BASE(rptno, NULL, 0, NULL, msg, __VA_ARGS__)
761
762 #define _RPTW0(rptno, msg) _RPT_BASE_W(rptno, NULL, 0, NULL, L"%ls", msg)
763 #define _RPTWN(rptno, msg, ...) _RPT_BASE_W(rptno, NULL, 0, NULL, msg, __VA_ARGS__)
764
765 #define _RPTF0(rptno, msg) _RPT_BASE(rptno, __FILE__, __LINE__, NULL, "%s", msg)
766 #define _RPTFN(rptno, msg, ...) _RPT_BASE(rptno, __FILE__, __LINE__, NULL, msg, __VA_ARGS__)
767
768 #define _RPTFW0(rptno, msg) _RPT_BASE_W(rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", msg)
769 #define _RPTFWN(rptno, msg, ...) _RPT_BASE_W(rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, __VA_ARGS__)
770
771#endif // _DEBUG
772
773// Asserts in debug. Invokes Watson in both debug and release
774#define _ASSERT_AND_INVOKE_WATSON(expr) \
775 { \
776 _ASSERTE((expr)); \
777 if (!(expr)) \
778 { \
779 _invoke_watson(_CRT_WIDE(#expr), __FUNCTIONW__, __FILEW__, __LINE__, 0); \
780 } \
781 }
782
783// _ASSERT_BASE is provided only for backwards compatibility.
784#ifndef _ASSERT_BASE
785 #define _ASSERT_BASE _ASSERT_EXPR
786#endif
787
788#define _RPT1 _RPTN
789#define _RPT2 _RPTN
790#define _RPT3 _RPTN
791#define _RPT4 _RPTN
792#define _RPT5 _RPTN
793
794#define _RPTW1 _RPTWN
795#define _RPTW2 _RPTWN
796#define _RPTW3 _RPTWN
797#define _RPTW4 _RPTWN
798#define _RPTW5 _RPTWN
799
800#define _RPTF1 _RPTFN
801#define _RPTF2 _RPTFN
802#define _RPTF3 _RPTFN
803#define _RPTF4 _RPTFN
804#define _RPTF5 _RPTFN
805
806#define _RPTFW1 _RPTFWN
807#define _RPTFW2 _RPTFWN
808#define _RPTFW3 _RPTFWN
809#define _RPTFW4 _RPTFWN
810#define _RPTFW5 _RPTFWN
811
812
813
816#pragma warning(pop) // _UCRT_DISABLED_WARNINGS
817#endif // _INC_CRTDBG
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
return
Definition: dirsup.c:529
_Check_return_ _In_z_ wchar_t const _Inout_opt_ _Deref_prepost_opt_z_ wchar_t ** _Context
_String
struct _CrtMemState _CrtMemState
void(__cdecl * _CRT_DUMP_CLIENT)(void *, size_t)
Definition: crtdbg.h:73
#define _CrtSetReportMode(t, f)
Definition: crtdbg.h:130
int(__cdecl * _CRT_REPORT_HOOKW)(int, wchar_t *, int *)
Definition: crtdbg.h:37
void * _HFILE
Definition: crtdbg.h:18
int(__cdecl * _CRT_ALLOC_HOOK)(int, void *, size_t, int, long, const unsigned char *, int)
Definition: crtdbg.h:46
#define _CrtSetReportFile(t, f)
Definition: crtdbg.h:131
int(__cdecl * _CRT_REPORT_HOOK)(int, char *, int *)
Definition: crtdbg.h:36
_Check_return_ _Ret_maybenull_ _In_ size_t _Alignment
Definition: malloc.h:139
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
Definition: malloc.h:109
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Offset
Definition: malloc.h:140
_Check_return_ _Ret_maybenull_ _In_ size_t _Count
Definition: malloc.h:108
EXTERN_C int __cdecl _VCrtDbgReportA(int reportType, const char *filename, int linenumber, const char *moduleName, const char *format, va_list arglist)
Definition: dbgrpt.cpp:314
EXTERN_C int __cdecl _VCrtDbgReportW(int reportType, const wchar_t *filename, int linenumber, const wchar_t *moduleName, const wchar_t *format, va_list arglist)
Definition: dbgrpt.cpp:376
EXTERN_C int __cdecl _CrtDbgReportW(int reportType, const wchar_t *filename, int linenumber, const wchar_t *moduleName, const wchar_t *format,...)
Definition: dbgrpt.cpp:483
EXTERN_C int __cdecl _CrtDbgReport(int reportType, const char *filename, int linenumber, const char *moduleName, const char *format,...)
Definition: dbgrpt.cpp:464
long _crtAssertBusy
Definition: dbgrptt.cpp:49
size_t __cdecl _CrtGetDebugFillThreshold()
long * __p__crtBreakAlloc()
Definition: debug_heap.cpp:155
int * __p__crtDbgFlag()
Definition: debug_heap.cpp:150
_In_z_ _Printf_format_string_ char const *const _Format
Definition: printf.c:19
_In_z_ _Printf_format_string_ char const *const va_list _ArgList
Definition: printf.c:23
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_size_t size_t
Definition: linux.h:237
_Pre_notnull_ _In_opt_z_ char const _Drive
Definition: stdlib.h:1098
_In_z_ char const * _Path
Definition: stdlib.h:1070
#define _ReturnAddress()
Definition: intrin_arm.h:35
#define _Outptr_result_buffer_maybenull_(size)
Definition: ms_sal.h:464
Definition: features.h:417
#define _Out_opt_
Definition: no_sal2.h:214
#define _Ret_maybenull_
Definition: no_sal2.h:328
#define _Success_(c)
Definition: no_sal2.h:84
#define _In_z_
Definition: no_sal2.h:164
#define _Pre_maybenull_
Definition: no_sal2.h:514
#define _Check_return_
Definition: no_sal2.h:60
#define _In_opt_z_
Definition: no_sal2.h:218
#define _Post_writable_byte_size_(s)
Definition: no_sal2.h:542
#define _Pre_notnull_
Definition: no_sal2.h:516
#define _Post_invalid_
Definition: no_sal2.h:524
#define _Out_writes_opt_z_(s)
Definition: no_sal2.h:230
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _Ret_maybenull_z_
Definition: no_sal2.h:330
#define long
Definition: qsort.c:33
_In_ size_t _SizeInBytes
Definition: time.h:146
_In_ size_t _SizeInWords
Definition: time.h:309
size_t lHighWaterCount
Definition: crtdbg.h:81
size_t lTotalCount
Definition: crtdbg.h:82
struct _CrtMemBlockHeader * pBlockHeader
Definition: crtdbg.h:78
size_t lCounts[_MAX_BLOCKS]
Definition: crtdbg.h:79
size_t lSizes[_MAX_BLOCKS]
Definition: crtdbg.h:80
int errno_t
Definition: corecrt.h:615
#define _DCRTIMP
Definition: corecrt.h:154
#define _ACRTIMP
Definition: corecrt.h:138
#define _CRTALLOCATOR
Definition: corecrt.h:167
#define _UCRT_DISABLE_CLANG_WARNINGS
Definition: corecrt.h:109
#define _UCRT_RESTORE_CLANG_WARNINGS
Definition: corecrt.h:117
#define _Check_return_wat_
Definition: corecrt.h:230
#define _free_dbg(p, t)
Definition: crtdbg.h:252
#define _CrtSetAllocHook(f)
Definition: crtdbg.h:133
#define _CrtGetDumpClient()
Definition: crtdbg.h:135
#define _CrtMemDumpAllObjectsSince(s)
Definition: crtdbg.h:146
#define _realloc_dbg(p, s, t, f, l)
Definition: crtdbg.h:255
#define _aligned_offset_malloc_dbg(s, a, o, f, l)
Definition: crtdbg.h:261
#define _wgetdcwd_dbg(d, s, le, t, f, l)
Definition: crtdbg.h:282
#define _CrtSetReportHook2(t, f)
Definition: crtdbg.h:607
#define _wcsdup_dbg(s, t, f, l)
Definition: crtdbg.h:278
#define _CrtSetDebugFillThreshold(t)
Definition: crtdbg.h:602
#define _CrtIsValidHeapPointer(p)
Definition: crtdbg.h:142
#define _tempnam_dbg(s1, s2, t, f, l)
Definition: crtdbg.h:277
#define _wtempnam_dbg(s1, s2, t, f, l)
Definition: crtdbg.h:284
#define _aligned_recalloc_dbg(p, c, s, a, f, l)
Definition: crtdbg.h:265
#define _CrtCheckMemory()
Definition: crtdbg.h:138
#define _CrtIsValidPointer(p, n, r)
Definition: crtdbg.h:143
#define _CrtSetReportHookW2(t, f)
Definition: crtdbg.h:608
#define _wfullpath_dbg(s1, s2, le, t, f, l)
Definition: crtdbg.h:280
#define _getdcwd_dbg(d, s, le, t, f, l)
Definition: crtdbg.h:273
#define _CrtDoForAllClientObjects(f, c)
Definition: crtdbg.h:139
#define _CrtDumpMemoryLeaks()
Definition: crtdbg.h:140
#define _malloc_dbg(s, t, f, l)
Definition: crtdbg.h:253
#define _aligned_offset_realloc_dbg(p, s, a, o, f, l)
Definition: crtdbg.h:262
#define _aligned_realloc_dbg(p, s, a, f, l)
Definition: crtdbg.h:264
#define _aligned_malloc_dbg(s, a, f, l)
Definition: crtdbg.h:259
#define _recalloc_dbg(p, c, s, t, f, l)
Definition: crtdbg.h:256
#define _dupenv_s_dbg(ps1, size, s2, t, f, l)
Definition: crtdbg.h:270
#define _CrtGetAllocHook()
Definition: crtdbg.h:132
#define _CrtSetBreakAlloc(a)
Definition: crtdbg.h:149
#define _CrtMemDifference(s1, s2, s3)
Definition: crtdbg.h:145
#define _calloc_dbg(c, s, t, f, l)
Definition: crtdbg.h:250
#define _aligned_msize_dbg(p, a, o)
Definition: crtdbg.h:260
#define _aligned_free_dbg(p)
Definition: crtdbg.h:258
#define _MAX_BLOCKS
Definition: crtdbg.h:104
#define _aligned_offset_recalloc_dbg(p, c, s, a, o, f, l)
Definition: crtdbg.h:263
#define _CrtSetDbgFlag(f)
Definition: crtdbg.h:150
#define _wgetcwd_dbg(s, le, t, f, l)
Definition: crtdbg.h:281
#define _CrtSetDumpClient(f)
Definition: crtdbg.h:136
#define _CrtSetReportHook(f)
Definition: crtdbg.h:606
#define _expand_dbg(p, s, t, f, l)
Definition: crtdbg.h:251
#define _msize_dbg(p, t)
Definition: crtdbg.h:254
#define _wdupenv_s_dbg(ps1, size, s2, t, f, l)
Definition: crtdbg.h:279
#define _CrtIsMemoryBlock(p, t, r, f, l)
Definition: crtdbg.h:141
#define _fullpath_dbg(s1, s2, le, t, f, l)
Definition: crtdbg.h:271
#define _strdup_dbg(s, t, f, l)
Definition: crtdbg.h:276
#define _CrtMemDumpStatistics(s)
Definition: crtdbg.h:147
#define _CrtReportBlockType(p)
Definition: crtdbg.h:148
#define _CrtGetReportHook()
Definition: crtdbg.h:605
#define _getcwd_dbg(s, le, t, f, l)
Definition: crtdbg.h:272
#define _CrtMemCheckpoint(s)
Definition: crtdbg.h:144
#define _CRT_END_C_HEADER
Definition: vcruntime.h:42
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:40
#define __CRTDECL
Definition: yvals.h:17
#define const
Definition: zconf.h:233