struct mem_stats {
size_t calls;
size_t size;
+ const char *func;
const char *file;
int line;
int type;
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"); \
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"); \
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"); \
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"); \
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"); \
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"); \
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"); \
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"); \
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"); \
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.
*/
const char *name;
const char *p;
const char *info = NULL;
+ const char *func = NULL;
if (!ptr->size && !ptr->calls && !ctx->show_all)
continue;
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;
// (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,