]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: tools: decode execution context TH_EX_CTX_INITCALL
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Mar 2026 09:41:35 +0000 (10:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Mar 2026 17:06:38 +0000 (18:06 +0100)
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
src/tools.c

index 9e0b950e17c436d6b8083bdf0d63a32c67630104..e7f0c9e4be4822eeb45795884d623b0625574158 100644 (file)
@@ -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 */
        };
 };
 
index f6e1d273b601a8d98cf910198eb76d681470f468..97532e2d762dd55e2a75efd26e3c4468302e0d59 100644 (file)
@@ -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;