ISC_LINK(debuglink_t) link;
const void *ptr;
size_t size;
+ const char *func;
const char *file;
unsigned int line;
};
typedef ISC_LIST(debuglink_t) debuglist_t;
-#define FLARG_PASS , file, line
-#define FLARG , const char *file, unsigned int line
+#define FLARG_PASS , func, file, line
+#define FLARG , const char *func, const char *file, unsigned int line
#else /* if ISC_MEM_TRACKLINES */
#define FLARG_PASS
#define FLARG
*/
#if !ISC_MEM_TRACKLINES
-#define ADD_TRACE(mctx, ptr, size, file, line)
-#define DELETE_TRACE(mctx, ptr, size, file, line)
+#define ADD_TRACE(mctx, ptr, size, func, file, line)
+#define DELETE_TRACE(mctx, ptr, size, func, file, line)
#define ISC_MEMFUNC_SCOPE
#else /* if !ISC_MEM_TRACKLINES */
#define TRACE_OR_RECORD (ISC_MEM_DEBUGTRACE | ISC_MEM_DEBUGRECORD)
#define SHOULD_TRACE_OR_RECORD(mctx, ptr) \
(((mctx)->debugging & TRACE_OR_RECORD) != 0 && ptr != NULL)
-#define ADD_TRACE(mctx, ptr, size, file, line) \
- if (SHOULD_TRACE_OR_RECORD(mctx, ptr)) { \
- add_trace_entry(mctx, ptr, size, file, line); \
+#define ADD_TRACE(mctx, ptr, size, func, file, line) \
+ if (SHOULD_TRACE_OR_RECORD(mctx, ptr)) { \
+ add_trace_entry(mctx, ptr, size, func, file, line); \
}
-#define DELETE_TRACE(mctx, ptr, size, file, line) \
- if (SHOULD_TRACE_OR_RECORD(mctx, ptr)) { \
- delete_trace_entry(mctx, ptr, size, file, line); \
+#define DELETE_TRACE(mctx, ptr, size, func, file, line) \
+ if (SHOULD_TRACE_OR_RECORD(mctx, ptr)) { \
+ delete_trace_entry(mctx, ptr, size, func, file, line); \
}
static void
MCTXLOCK(mctx);
if ((mctx->debugging & ISC_MEM_DEBUGTRACE) != 0) {
- fprintf(stderr, "add %p size %zu file %s line %u mctx %p\n",
- ptr, size, file, line, mctx);
+ fprintf(stderr,
+ "add %p size %zu func %s file %s line %u mctx %p\n",
+ ptr, size, func, file, line, mctx);
}
if (mctx->debuglist == NULL) {
ISC_LINK_INIT(dl, link);
dl->ptr = ptr;
dl->size = size;
+ dl->func = func;
dl->file = file;
dl->line = line;
}
static void
-delete_trace_entry(isc_mem_t *mctx, const void *ptr, size_t size,
- const char *file, unsigned int line) {
+delete_trace_entry(isc_mem_t *mctx, const void *ptr, size_t size FLARG) {
debuglink_t *dl = NULL;
uint32_t hash;
uint32_t idx;
MCTXLOCK(mctx);
if ((mctx->debugging & ISC_MEM_DEBUGTRACE) != 0) {
- fprintf(stderr, "del %p size %zu file %s line %u mctx %p\n",
- ptr, size, file, line, mctx);
+ fprintf(stderr,
+ "del %p size %zu func %s file %s line %u mctx %p\n",
+ ptr, size, func, file, line, mctx);
}
if (mctx->debuglist == NULL) {
isc__mem_put(ctx, ptr, size, flags FLARG_PASS);
#if ISC_MEM_TRACE
- isc_mem__detach(&ctx, __func__, file, line);
+ isc_mem__detach(&ctx, func, file, line);
#else
isc_mem_detach(&ctx);
#endif
ptr = mem_get(ctx, size, flags);
mem_getstats(ctx, size);
- ADD_TRACE(ctx, ptr, size, file, line);
+ ADD_TRACE(ctx, ptr, size, func, file, line);
return ptr;
}
isc__mem_put(isc_mem_t *ctx, void *ptr, size_t size, int flags FLARG) {
REQUIRE(VALID_CONTEXT(ctx));
- DELETE_TRACE(ctx, ptr, size, file, line);
+ DELETE_TRACE(ctx, ptr, size, func, file, line);
mem_putstats(ctx, size);
mem_put(ctx, ptr, size, flags);
size = sallocx(ptr, flags | ctx->jemalloc_flags);
mem_getstats(ctx, size);
- ADD_TRACE(ctx, ptr, size, file, line);
+ ADD_TRACE(ctx, ptr, size, func, file, line);
return ptr;
}
} else if (new_size == 0) {
isc__mem_put(ctx, old_ptr, old_size, flags FLARG_PASS);
} else {
- DELETE_TRACE(ctx, old_ptr, old_size, file, line);
+ DELETE_TRACE(ctx, old_ptr, old_size, func, file, line);
mem_putstats(ctx, old_size);
new_ptr = mem_realloc(ctx, old_ptr, old_size, new_size, flags);
mem_getstats(ctx, new_size);
- ADD_TRACE(ctx, new_ptr, new_size, file, line);
+ ADD_TRACE(ctx, new_ptr, new_size, func, file, line);
/*
* We want to postpone the call to water in edge case
} else {
size_t old_size = sallocx(old_ptr, flags | ctx->jemalloc_flags);
- DELETE_TRACE(ctx, old_ptr, old_size, file, line);
+ DELETE_TRACE(ctx, old_ptr, old_size, func, file, line);
mem_putstats(ctx, old_size);
new_ptr = mem_realloc(ctx, old_ptr, old_size, new_size, flags);
new_size = sallocx(new_ptr, flags | ctx->jemalloc_flags);
mem_getstats(ctx, new_size);
- ADD_TRACE(ctx, new_ptr, new_size, file, line);
+ ADD_TRACE(ctx, new_ptr, new_size, func, file, line);
/*
* We want to postpone the call to water in edge case
size = sallocx(ptr, flags | ctx->jemalloc_flags);
- DELETE_TRACE(ctx, ptr, size, file, line);
+ DELETE_TRACE(ctx, ptr, size, func, file, line);
mem_putstats(ctx, size);
mem_put(ctx, ptr, size, flags);
#if ISC_MEM_TRACKLINES
if ((mctx->debugging & ISC_MEM_DEBUGTRACE) != 0) {
- fprintf(stderr, "create pool %p file %s line %u mctx %p\n",
- mpctx, file, line, mctx);
+ fprintf(stderr,
+ "create pool %p func %s file %s line %u mctx %p\n",
+ mpctx, func, file, line, mctx);
}
#endif /* ISC_MEM_TRACKLINES */
#if ISC_MEM_TRACKLINES
if ((mctx->debugging & ISC_MEM_DEBUGTRACE) != 0) {
- fprintf(stderr, "destroy pool %p file %s line %u mctx %p\n",
- mpctx, file, line, mctx);
+ fprintf(stderr,
+ "destroy pool %p func %s file %s line %u mctx %p\n",
+ mpctx, func, file, line, mctx);
}
#endif
mpctx->freecount--;
mpctx->gets++;
- ADD_TRACE(mpctx->mctx, item, mpctx->size, file, line);
+ ADD_TRACE(mpctx->mctx, item, mpctx->size, func, file, line);
return item;
}
INSIST(mpctx->allocated > 0);
mpctx->allocated--;
- DELETE_TRACE(mctx, mem, mpctx->size, file, line);
+ DELETE_TRACE(mctx, mem, mpctx->size, func, file, line);
/*
* If our free list is full, return this to the mctx directly.
mem_create(mctxp, isc_mem_debugging, isc_mem_defaultflags, 0);
#if ISC_MEM_TRACKLINES
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
- fprintf(stderr, "create mctx %p file %s line %u\n", *mctxp,
- file, line);
+ fprintf(stderr, "create mctx %p func %s file %s line %u\n",
+ *mctxp, func, file, line);
}
#endif /* ISC_MEM_TRACKLINES */
}
#if ISC_MEM_TRACKLINES
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
fprintf(stderr,
- "create mctx %p file %s line %u for jemalloc arena "
- "%u\n",
- *mctxp, file, line, arena_no);
+ "create mctx %p func %s file %s line %u "
+ "for jemalloc arena %u\n",
+ *mctxp, func, file, line, arena_no);
}
#endif /* ISC_MEM_TRACKLINES */
}