![]() |
ManaPlus
|
Go to the source code of this file.
Data Structures | |
| class | debug_new_recorder |
| class | debug_new_counter |
Macros | |
| #define | _DEBUG_NEW_REDEFINE_NEW 1 |
| #define | _DEBUG_NEW_TYPE 1 |
| #define | DEBUG_NEW NVWA::debug_new_recorder(__FILE__, __LINE__) ->* new |
| #define | new DEBUG_NEW |
Typedefs | |
| typedef void(* | stacktrace_print_callback_t) (FILE *fp, void **stacktrace) |
| typedef bool(* | leak_whitelist_callback_t) (char const *file, int line, void *addr, void **stacktrace) |
Functions | |
| void * | operator new (size_t size, const char *file, int line) |
| void * | operator new[] (size_t size, const char *file, int line) |
| void | operator delete (void *ptr, const char *file, int line) throw () |
| void | operator delete[] (void *ptr, const char *file, int line) throw () |
| int | check_leaks () |
| int | check_mem_corruption () |
Variables | |
| bool | new_autocheck_flag |
| bool | new_verbose_flag |
| FILE * | new_output_fp |
| const char * | new_progname |
| stacktrace_print_callback_t | stacktrace_print_callback |
| leak_whitelist_callback_t | leak_whitelist_callback |
| static debug_new_counter | __debug_new_count |
Header file for checking leaks caused by unmatched new/delete.
Definition in file debug_new.h.
| #define _DEBUG_NEW_REDEFINE_NEW 1 |
Macro to indicate whether redefinition of new is wanted. If one wants to define one's own operator new, or to call operator new directly, it should be defined to 0 to alter the default behaviour. Unless, of course, one is willing to take the trouble to write something like:
Definition at line 78 of file debug_new.h.
| #define _DEBUG_NEW_TYPE 1 |
Macro to indicate which variant of DEBUG_NEW is wanted. The default value 1 allows the use of placement new (like new(std::nothrow)), but the verbose output (when nvwa::new_verbose_flag is true) looks worse than some older versions (no file/line information for allocations). Define it to 2 to revert to the old behaviour that records file and line information directly on the call to operator new.
Definition at line 93 of file debug_new.h.
| #define DEBUG_NEW NVWA::debug_new_recorder(__FILE__, __LINE__) ->* new |
Macro to catch file/line information on allocation. If _DEBUG_NEW_REDEFINE_NEW is 0, one can use this macro directly; otherwise new will be defined to it, and one must use new instead.
Definition at line 141 of file debug_new.h.
| #define new DEBUG_NEW |
Definition at line 147 of file debug_new.h.
| typedef bool(* leak_whitelist_callback_t) (char const *file, int line, void *addr, void **stacktrace) |
Callback type for the leak whitelist function. file, address, and backtrace might be null depending on library configuration, platform, and amount of runtime information available. line can be 0 when line number info is not available at runtime.
| file | null-terminated string of the file name |
| line | line number |
| addr | address of code where leakage happens |
| stacktrace | pointer to the stack trace array (null-terminated) |
true if the leak should be whitelisted; false otherwise Definition at line 117 of file debug_new.h.
| typedef void(* stacktrace_print_callback_t) (FILE *fp, void **stacktrace) |
Callback type for stack trace printing.
| fp | pointer to the output stream |
| stacktrace | pointer to the stack trace array (null-terminated) |
Definition at line 102 of file debug_new.h.
| int check_leaks | ( | ) |
Checks for memory leaks.
Definition at line 769 of file debug_new.cpp.
References _NULLPTR, new_ptr_list_t::addr, ALIGNED_LIST_ITEM_SIZE, DEBUG_NEW_MAGIC, new_ptr_list_t::file, is_leak_whitelisted(), new_ptr_list_t::line, new_ptr_list_t::magic, new_output_fp, new_output_lock, new_ptr_list, new_ptr_lock, new_verbose_flag, new_ptr_list_t::next, print_position(), and new_ptr_list_t::size.
Referenced by debug_new_counter::~debug_new_counter().
| int check_mem_corruption | ( | ) |
Checks for heap corruption.
Definition at line 844 of file debug_new.cpp.
References _DEBUG_NEW_TAILCHECK, _NULLPTR, new_ptr_list_t::addr, ALIGNED_LIST_ITEM_SIZE, DEBUG_NEW_MAGIC, new_ptr_list_t::file, new_ptr_list_t::line, new_ptr_list_t::magic, new_output_fp, new_output_lock, new_ptr_list, new_ptr_lock, new_ptr_list_t::next, print_position(), and new_ptr_list_t::size.
Referenced by free_pointer().
| void operator delete | ( | void * | ptr, |
| const char * | file, | ||
| int | line | ||
| ) | |||
| throw | ( | ||
| ) | |||
Placement deallocation function. For details, please check Section 5.3.4 of the C++ 1998 or 2011 Standard.
| ptr | pointer to the previously allocated memory |
| file | null-terminated string of the file name |
| line | line number |
Definition at line 1134 of file debug_new.cpp.
References new_output_fp, new_output_lock, new_verbose_flag, and print_position().
| void operator delete[] | ( | void * | ptr, |
| const char * | file, | ||
| int | line | ||
| ) | |||
| throw | ( | ||
| ) | |||
Placement deallocation function. For details, please check Section 5.3.4 of the C++ 1998 or 2011 Standard.
| ptr | pointer to the previously allocated memory |
| file | null-terminated string of the file name |
| line | line number |
Definition at line 1156 of file debug_new.cpp.
References new_output_fp, new_output_lock, new_verbose_flag, and print_position().
| void* operator new | ( | size_t | size, |
| const char * | file, | ||
| int | line | ||
| ) |
Allocates memory with file/line information.
| size | size of the required memory block |
| file | null-terminated string of the file name |
| line | line number |
| bad_alloc | memory is insufficient (_DEBUG_NEW_STD_OPER_NEW is 1) |
Definition at line 1003 of file debug_new.cpp.
References alloc_mem(), and EmoteDB::size().
| void* operator new[] | ( | size_t | size, |
| const char * | file, | ||
| int | line | ||
| ) |
Allocates array memory with file/line information.
| size | size of the required memory block |
| file | null-terminated string of the file name |
| line | line number |
| bad_alloc | memory is insufficient (_DEBUG_NEW_STD_OPER_NEW is 1) |
Definition at line 1026 of file debug_new.cpp.
References alloc_mem(), and EmoteDB::size().
|
static |
Counting object for each file including debug_new.h.
Definition at line 203 of file debug_new.h.
|
extern |
Pointer to the callback used to filter out false positives from leak reports. A null value means the lack of filtering.
Definition at line 368 of file debug_new.cpp.
Referenced by is_leak_whitelisted().
|
extern |
Flag to control whether nvwa::check_leaks will be automatically called on program exit.
Definition at line 333 of file debug_new.cpp.
Referenced by debug_new_counter::~debug_new_counter().
|
extern |
Pointer to the output stream. The default output is stderr, and one may change it to a user stream if needed (say, new_verbose_flag is true and there are a lot of (de)allocations).
Definition at line 345 of file debug_new.cpp.
Referenced by debug_new_recorder::_M_process(), alloc_mem(), check_leaks(), check_mem_corruption(), free_pointer(), operator delete(), operator delete[](), print_position(), and debug_new_counter::~debug_new_counter().
|
extern |
Pointer to the program name. Its initial value is the macro _DEBUG_NEW_PROGNAME. You should try to assign the program path to it early in your application. Assigning argv[0] to it in main is one way. If you use bash or ksh (or similar), the following statement is probably what you want: ‘new_progname = getenv("_");’.
Definition at line 355 of file debug_new.cpp.
|
extern |
Flag to control whether verbose messages are output.
Definition at line 338 of file debug_new.cpp.
Referenced by debug_new_recorder::_M_process(), alloc_mem(), check_leaks(), free_pointer(), operator delete(), operator delete[](), and debug_new_counter::~debug_new_counter().
|
extern |
Pointer to the callback used to print the stack backtrace in case of a memory problem. A null value causes the default stack trace printing routine to be used.
Definition at line 362 of file debug_new.cpp.