Data structure of heap block for debugging heap. More...
Public Types | |
enum | { E_HEAP_INVALID_PTR = 0x0U, E_HEAP_MALLOC = 0x1U, E_HEAP_NEW = 0x2U, E_HEAP_NEW_ARRAY = 0x4U, E_HEAP_SPECIAL = 0x8U, SENSITIVE_STORE = 0x10U, SPARSE_BLOCK = 0x20U, E_HEAP_INVALID_S_PTR = E_HEAP_INVALID_PTR | SENSITIVE_STORE, E_HEAP_S_MALLOC = E_HEAP_MALLOC | SENSITIVE_STORE, E_HEAP_S_NEW = E_HEAP_NEW | SENSITIVE_STORE, E_HEAP_S_NEW_ARRAY = E_HEAP_NEW_ARRAY | SENSITIVE_STORE, E_HEAP_S_SPECIAL = E_HEAP_SPECIAL | SENSITIVE_STORE, E_HEAP_MALLOC_SPARSE = E_HEAP_S_MALLOC | SPARSE_BLOCK } |
typedef unsigned | e_type |
Public Member Functions | |
MY_FORCE_INLINE | c_heap_block (e_type type, void *p, size_t size, const char *fn, int ln) |
Initializes heap block. | |
Static Public Member Functions | |
static MY_WISH_INLINE const char * | check (e_type &type, void *p, const char *&fn, int &ln) |
Checks heap block before deallocation on deallocation request; and removes this entry from map (even if in case of error). | |
static void | dump (string &log) |
Dumps allocated heap blocks. | |
static void | get_stats (MY_U_LONG_LONG &tran_cnt, MY_U_LONG_LONG &recreation_period, MY_U_LONG_LONG &errors, std::size_t &largest, std::size_t &total_bytes, MY_U_LONG_LONG &blocks_cnt, MY_U_LONG_LONG &recreation_cnt) |
Retrieves statistics. | |
static MY_WISH_INLINE void * | realloc (void *p, size_t size, const char *fn, int ln) |
Reallocates heap block of type 'E_HEAP_MALLOC' (my_realloc() helper). | |
static const char * | type2str (e_type type) |
Returrns string for human from type of block. | |
Private Member Functions | |
MY_FORCE_INLINE | c_heap_block (void *p, size_t size, c_heap_block *old) |
Initializes re-allocated heap block (for internal use only). | |
Static Private Member Functions | |
static MY_FORCE_INLINE void | next_tran (bool force=false) |
Increments transaction count and recreates map if maximum transaction number has been reached (to allow better heap defragmentation) (for internal use only). | |
static void | report (const char *c_fn, int c_ln, const char *msg, const char *a_fn, int a_ln, my_time_t alloc_time) |
Reports error and stores it in to the log. | |
static void | report (const char *c_fn, int c_ln, const char *msg) |
Reports error and stores it in to the log. | |
Private Attributes | |
const char * | m_fn |
Filename of allocation request. | |
int | m_ln |
Line number of allocation request. | |
bool | m_sensitive_store |
'true' for sensitive store | |
size_t | m_size |
Size of the user's block. | |
size_t | m_sparse_size |
Sparse size of block, or '0' for no sparse. | |
my_time_t | m_time |
Timestamp of allocation. | |
e_type | m_type |
Type of block. | |
Static Private Attributes | |
static map< void *, c_heap_block * > * | s_blocks = ::new map<void*,c_heap_block*> |
List of blocks. | |
static MY_U_LONG_LONG | s_cnt = 0 |
Number of transactions (re/alloc + dealloc) that recreation is to go. | |
static MY_U_LONG_LONG | s_errors = 0 |
Number of heap errors (resource mismatch, or invalid pointer deallocation). | |
static size_t | s_largest = 0 |
The largest allocated block in history. | |
static const char * | s_largest_fn = NULL |
The largest allocated block filename. | |
static int | s_largest_ln = 0 |
The largest allocated block line. | |
static string | s_log |
Log of heap errors (for dump). | |
static c_mutex * | s_mutex = NULL |
Locking object. | |
static MY_U_LONG_LONG | s_recreation_cnt = 0 |
Number of recreation events. | |
static size_t | s_total_bytes = 0 |
Current total allocated bytes. | |
static MY_U_LONG_LONG | s_tran_cnt = 0 |
Number of transactions (re/alloc + dealloc). | |
Friends | |
class | c_heap_map_recreation_impossible |
void | heap_debug_done (string &log) |
Deinitialization of heap debugger, also dumps memory leaks. | |
void | heap_debug_init () |
Initialization of heap debugger. |
Data structure of heap block for debugging heap.
Definition at line 89 of file heap_debug.cpp.