DEBUG: pools: also retrieve file and line for direct callers of create_pool()

Just like previous patch, we want to retrieve the location of the caller.
For this we turn create_pool() into a macro that collects __FILE__ and
__LINE__ and passes them to the now renamed function create_pool_with_loc().

Now the remaining ~30 pools also have their location stored.
This commit is contained in:
Willy Tarreau 2025-08-06 09:50:42 +02:00
parent efa856a8b0
commit ac23b873f5
2 changed files with 10 additions and 2 deletions

View File

@ -143,7 +143,7 @@ unsigned long long pool_total_allocated(void);
unsigned long long pool_total_used(void);
void pool_flush(struct pool_head *pool);
void pool_gc(struct pool_head *pool_ctx);
struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags);
struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int flags, const char *file, unsigned int line);
struct pool_head *create_pool_from_reg(const char *name, struct pool_registration *reg);
void create_pool_callback(struct pool_head **ptr, char *name, struct pool_registration *reg);
void *pool_destroy(struct pool_head *pool);
@ -152,6 +152,9 @@ void *__pool_alloc(struct pool_head *pool, unsigned int flags);
void __pool_free(struct pool_head *pool, void *ptr);
void pool_inspect_item(const char *msg, struct pool_head *pool, const void *item, const void *caller, ssize_t ofs);
#define create_pool(name, size, flags) \
create_pool_with_loc(name, size, flags, __FILE__, __LINE__)
/****************** Thread-local cache management ******************/

View File

@ -291,8 +291,11 @@ static int mem_should_fail(const struct pool_head *pool)
* - MEM_F_SHARED to indicate that the pool may be shared with other users
* - MEM_F_EXACT to indicate that the size must not be rounded up
* The name must be a stable pointer during all the program's life time.
* The file and line are passed to store the registration location in the
* registration struct. Use create_pool() instead which does it for free.
*/
struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags)
struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int flags,
const char *file, unsigned int line)
{
struct pool_registration *reg;
struct pool_head *pool;
@ -302,6 +305,8 @@ struct pool_head *create_pool(const char *name, unsigned int size, unsigned int
return NULL;
reg->name = name;
reg->file = file;
reg->line = line;
reg->size = size;
reg->flags = flags;
reg->align = 0;