wip: track allocation locations in debug mode

This commit is contained in:
Daan Leijen 2020-02-11 12:19:22 -08:00
parent 4090561975
commit 21a95c7449
10 changed files with 257 additions and 141 deletions

View file

@ -274,10 +274,6 @@ typedef struct mi_segment_s {
// of the blocks to check for buffer overflows.
// ------------------------------------------------------
#if defined(MI_PADDING)
// compressed location:
// lsb=1: bit 63-32: relative file name char* (to `mi_fname_base`), bit 31-1: line number
// lsb=0: bit 63-01: return address
typedef int64_t mi_source_t;
typedef struct mi_padding_s {
uint32_t canary; // encoded block value to check validity of the padding (in case of heap block overflow)
uint32_t delta; // padding bytes before the block. (mi_usable_size(p) - delta == exact allocated bytes)
@ -285,15 +281,9 @@ typedef struct mi_padding_s {
} mi_padding_t;
#define MI_PADDING_SIZE (sizeof(mi_padding_t))
#define MI_PADDING_WSIZE ((MI_PADDING_SIZE + MI_INTPTR_SIZE - 1) / MI_INTPTR_SIZE)
#define MI_SOURCE_PARAM , mi_source_t source
#define MI_SOURCE_ARG , source
#define MI_SOURCE_RET , ((intptr_t)mi_return_address() << (intptr_t)1)
#else
#define MI_PADDING_SIZE 0
#define MI_PADDING_WSIZE 0
#define MI_SOURCE_PARAM
#define MI_SOURCE_ARG
#define MI_SOURCE_RET
#endif
// ------------------------------------------------------