]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: pools: store the pool registration file name and line number
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Aug 2025 07:43:39 +0000 (09:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Aug 2025 17:20:32 +0000 (19:20 +0200)
When pools are declared using DECLARE_POOL(), REGISTER_POOL etc, we
know where they are and it's trivial to retrieve the file name and line
number, so let's store them in the pool_registration, and display them
when known in "show pools detailed".

include/haproxy/pool-t.h
include/haproxy/pool.h
src/pool.c

index 4a8752ad6d72ceb6b59e0c4c46cdea40ef6fab8f..52765a62747f1d50f013b8bd51b985dabe7e2c22 100644 (file)
@@ -71,6 +71,8 @@ struct pool_cache_head {
 struct pool_registration {
        struct list list;    /* link element */
        const char *name;    /* name of the pool */
+       const char *file;    /* where the pool is declared */
+       unsigned int line;   /* line in the file where the pool is declared, 0 if none */
        unsigned int size;   /* expected object size */
        unsigned int flags;  /* MEM_F_* */
        unsigned int align;  /* expected alignment; 0=unspecified */
index 2c9e2e75b4c0407efc50f25679a285a140cb2fa8..108e00e5f4b2caebc6cac5fcc806d0e278814320 100644 (file)
@@ -36,6 +36,8 @@
 #define __REGISTER_POOL(_line, _ptr, _name, _size)            \
        static struct pool_registration __pool_reg_##_line = { \
                .name = _name,                                 \
+               .file = __FILE__,                              \
+               .line = __LINE__,                              \
                .size = _size,                                 \
                .flags = MEM_F_STATREG,                        \
                .align = 0,                                    \
index 67ce7060f324d47597c5267f56b3b833e6a55f2b..c3eb98189243ea7018ee288f7b2a060255b5f9c5 100644 (file)
@@ -1321,8 +1321,12 @@ void dump_pools_to_trash(int how, int max, const char *pfx)
 
                if (detailed) {
                        struct pool_registration *reg;
-                       list_for_each_entry(reg, &pool_info[i].entry->regs, list)
-                               chunk_appendf(&trash, "      >  %-12s: size=%u flags=%#x align=%u\n", reg->name, reg->size, reg->flags, reg->align);
+                       list_for_each_entry(reg, &pool_info[i].entry->regs, list) {
+                               chunk_appendf(&trash, "      >  %-12s: size=%u flags=%#x align=%u", reg->name, reg->size, reg->flags, reg->align);
+                               if (reg->file && reg->line)
+                                       chunk_appendf(&trash, " [%s:%u]", reg->file, reg->line);
+                               chunk_appendf(&trash, "\n");
+                       }
                }
        }