mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-25 07:41:36 +02:00
MINOR: debug: also store the function name in struct mem_stats
The calling function name is now stored in the structure, and it's reported when the "all" argument is passed. The first column is significantly enlarged because some names are really wide :-(
This commit is contained in:
parent
55c950baa9
commit
17200dd1f3
@ -242,6 +242,7 @@ enum {
|
||||
struct mem_stats {
|
||||
size_t calls;
|
||||
size_t size;
|
||||
const char *func;
|
||||
const char *file;
|
||||
int line;
|
||||
int type;
|
||||
@ -254,6 +255,7 @@ struct mem_stats {
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_CALLOC, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
HA_WEAK("__stop_mem_stats"); \
|
||||
@ -271,6 +273,7 @@ struct mem_stats {
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_FREE, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
HA_WEAK("__stop_mem_stats"); \
|
||||
@ -285,6 +288,7 @@ struct mem_stats {
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_FREE, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
HA_WEAK("__stop_mem_stats"); \
|
||||
@ -303,6 +307,7 @@ struct mem_stats {
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_MALLOC, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
HA_WEAK("__stop_mem_stats"); \
|
||||
@ -317,6 +322,7 @@ struct mem_stats {
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_REALLOC, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
HA_WEAK("__stop_mem_stats"); \
|
||||
@ -331,6 +337,7 @@ struct mem_stats {
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_STRDUP, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
HA_WEAK("__stop_mem_stats"); \
|
||||
|
@ -258,6 +258,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool, const void *call
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_P_FREE, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
_.extra = __pool; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
@ -275,6 +276,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool, const void *call
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_P_ALLOC, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
_.extra = __pool; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
@ -290,6 +292,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool, const void *call
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_P_ALLOC, \
|
||||
.func = __func__, \
|
||||
}; \
|
||||
_.extra = __pool; \
|
||||
HA_WEAK("__start_mem_stats"); \
|
||||
|
18
src/debug.c
18
src/debug.c
@ -1279,8 +1279,6 @@ static int debug_iohandler_memstats(struct appctx *appctx)
|
||||
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
|
||||
goto end;
|
||||
|
||||
chunk_reset(&trash);
|
||||
|
||||
/* we have two inner loops here, one for the proxy, the other one for
|
||||
* the buffer.
|
||||
*/
|
||||
@ -1289,6 +1287,7 @@ static int debug_iohandler_memstats(struct appctx *appctx)
|
||||
const char *name;
|
||||
const char *p;
|
||||
const char *info = NULL;
|
||||
const char *func = NULL;
|
||||
|
||||
if (!ptr->size && !ptr->calls && !ctx->show_all)
|
||||
continue;
|
||||
@ -1299,6 +1298,8 @@ static int debug_iohandler_memstats(struct appctx *appctx)
|
||||
name = p + 1;
|
||||
}
|
||||
|
||||
func = ptr->func;
|
||||
|
||||
switch (ptr->type) {
|
||||
case MEM_STATS_TYPE_CALLOC: type = "CALLOC"; break;
|
||||
case MEM_STATS_TYPE_FREE: type = "FREE"; break;
|
||||
@ -1316,9 +1317,18 @@ static int debug_iohandler_memstats(struct appctx *appctx)
|
||||
// (unsigned long)ptr->size, (unsigned long)ptr->calls,
|
||||
// (unsigned long)(ptr->calls ? (ptr->size / ptr->calls) : 0));
|
||||
|
||||
chunk_printf(&trash, "%s:%d", name, ptr->line);
|
||||
while (trash.data < 25)
|
||||
chunk_reset(&trash);
|
||||
if (ctx->show_all)
|
||||
chunk_appendf(&trash, "%s(", func);
|
||||
|
||||
chunk_appendf(&trash, "%s:%d", name, ptr->line);
|
||||
|
||||
if (ctx->show_all)
|
||||
chunk_appendf(&trash, ")");
|
||||
|
||||
while (trash.data < (ctx->show_all ? 45 : 25))
|
||||
trash.area[trash.data++] = ' ';
|
||||
|
||||
chunk_appendf(&trash, "%7s size: %12lu calls: %9lu size/call: %6lu %s\n",
|
||||
type,
|
||||
(unsigned long)ptr->size, (unsigned long)ptr->calls,
|
||||
|
Loading…
x
Reference in New Issue
Block a user