From 6e75da7a91215fd547cc5d2625c61e9a00576c33 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 6 Mar 2026 10:41:35 +0100 Subject: [PATCH] MINOR: tools: decode execution context TH_EX_CTX_INITCALL When the execution context is set to TH_EX_CTX_INITCALL, the pointer points to a valid initcall, and the decoder will show "kw registered at %s:%d" with file and line number of the initcall declaration. It's up to the caller to make the initcall pointer point to the one that was set during the initcall. The purpose here is to be able to preserve and pass that knowledge of an initcall down the chain so that future calls to functions registered via the initcall are still assigned to it. --- include/haproxy/tinfo-t.h | 2 ++ src/tools.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h index 9e0b950e1..e7f0c9e4b 100644 --- a/include/haproxy/tinfo-t.h +++ b/include/haproxy/tinfo-t.h @@ -79,6 +79,7 @@ enum { enum thread_exec_ctx_type { TH_EX_CTX_NONE = 0, /* context not filled */ TH_EX_CTX_OTHER, /* context only known by a generic pointer */ + TH_EX_CTX_INITCALL, /* the pointer is an initcall providing file:line */ }; struct thread_exec_ctx { @@ -86,6 +87,7 @@ struct thread_exec_ctx { /* 32-bit hole here on 64-bit platforms */ union { const void *pointer; /* generic pointer (for other) */ + const struct initcall *initcall; /* used with TH_EX_CTX_INITCALL */ }; }; diff --git a/src/tools.c b/src/tools.c index f6e1d273b..97532e2d7 100644 --- a/src/tools.c +++ b/src/tools.c @@ -7515,6 +7515,13 @@ void chunk_append_thread_ctx(struct buffer *output, const struct thread_exec_ctx chunk_appendf(output,"%s", pfx ? pfx : ""); switch (ctx->type) { + case TH_EX_CTX_INITCALL: { + const char *file = ctx->initcall->loc_file; + const char *slash = strrchr(file, '/'); + slash = slash ? slash + 1 : file; + chunk_appendf(output,"ctx registered at %s:%d", slash, ctx->initcall->loc_line); + break; + } default: chunk_appendf(output,"other ctx %p", ctx->pointer); break;