|
Packit Service |
20376f |
/*
|
|
Packit Service |
20376f |
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
Packit Service |
20376f |
* a Linking Exception. For full terms see the included COPYING file.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
#ifndef INCLUDE_w32_crtdbg_stacktrace_h__
|
|
Packit Service |
20376f |
#define INCLUDE_w32_crtdbg_stacktrace_h__
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#if defined(GIT_MSVC_CRTDBG)
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Initialize our memory leak tracking and de-dup data structures.
|
|
Packit Service |
20376f |
* This should ONLY be called by git_libgit2_init().
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
void git_win32__crtdbg_stacktrace_init(void);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Shutdown our memory leak tracking and dump summary data.
|
|
Packit Service |
20376f |
* This should ONLY be called by git_libgit2_shutdown().
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* We explicitly call _CrtDumpMemoryLeaks() during here so
|
|
Packit Service |
20376f |
* that we can compute summary data for the leaks. We print
|
|
Packit Service |
20376f |
* the stacktrace of each unique leak.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This cleanup does not happen if the app calls exit()
|
|
Packit Service |
20376f |
* without calling the libgit2 shutdown code.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This info we print here is independent of any automatic
|
|
Packit Service |
20376f |
* reporting during exit() caused by _CRTDBG_LEAK_CHECK_DF.
|
|
Packit Service |
20376f |
* Set it in your app if you also want traditional reporting.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
void git_win32__crtdbg_stacktrace_cleanup(void);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Checkpoint options.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
typedef enum git_win32__crtdbg_stacktrace_options {
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Set checkpoint marker.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK = (1 << 0),
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Dump leaks since last checkpoint marker.
|
|
Packit Service |
20376f |
* May not be combined with __LEAKS_TOTAL.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* Note that this may generate false positives for global TLS
|
|
Packit Service |
20376f |
* error state and other global caches that aren't cleaned up
|
|
Packit Service |
20376f |
* until the thread/process terminates. So when using this
|
|
Packit Service |
20376f |
* around a region of interest, also check the final (at exit)
|
|
Packit Service |
20376f |
* dump before digging into leaks reported here.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK = (1 << 1),
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Dump leaks since init. May not be combined
|
|
Packit Service |
20376f |
* with __LEAKS_SINCE_MARK.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL = (1 << 2),
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Suppress printing during dumps.
|
|
Packit Service |
20376f |
* Just return leak count.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
GIT_WIN32__CRTDBG_STACKTRACE__QUIET = (1 << 3),
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
} git_win32__crtdbg_stacktrace_options;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Checkpoint memory state and/or dump unique stack traces of
|
|
Packit Service |
20376f |
* current memory leaks.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* @return number of unique leaks (relative to requested starting
|
|
Packit Service |
20376f |
* point) or error.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
GIT_EXTERN(int) git_win32__crtdbg_stacktrace__dump(
|
|
Packit Service |
20376f |
git_win32__crtdbg_stacktrace_options opt,
|
|
Packit Service |
20376f |
const char *label);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Construct stacktrace and append it to the global buffer.
|
|
Packit Service |
20376f |
* Return pointer to start of this string. On any error or
|
|
Packit Service |
20376f |
* lack of buffer space, just return the given file buffer
|
|
Packit Service |
20376f |
* so it will behave as usual.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This should ONLY be called by our internal memory allocations
|
|
Packit Service |
20376f |
* routines.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
const char *git_win32__crtdbg_stacktrace(int skip, const char *file);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#endif
|
|
Packit Service |
20376f |
#endif
|