From: Willy Tarreau Date: Tue, 6 Sep 2022 05:55:44 +0000 (+0200) Subject: MINOR: debug: add struct ha_caller to describe a calling location X-Git-Tag: v2.7-dev6~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f2f1f294c073302df30de4f08fe1bd6be472936;p=thirdparty%2Fhaproxy.git MINOR: debug: add struct ha_caller to describe a calling location The purpose of this structure is to assemble all constant parts of a generic calling point for a specific event. These ones are created by the compiler as a static const element outside of the code path, so they cost nothing in terms of CPU, and a pointer to that descriptor can be passed to the place that needs it. This is very similar to what is being done for the mem_stat stuff. This will be useful to simplify and improve DEBUG_TASK. --- diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index 60b2467936..45570027c4 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -193,6 +193,23 @@ static inline __attribute((always_inline)) void ha_crash_now(void) *__x = NULL; \ } while (0) +/* describes a call place in the code, for example for tracing memory + * allocations or task wakeups. These must be declared static const. + */ +struct ha_caller { + const char *func; // function name + const char *file; // file name + uint16_t line; // line number + uint8_t what; // description of the call, usage specific + uint8_t arg8; // optional argument, usage specific + uint32_t arg32; // optional argument, usage specific +}; + +#define MK_CALLER(_what, _arg8, _arg32) \ + ({ static const struct ha_caller _ = { \ + .func = __func__, .file = __FILE__, .line = __LINE__, \ + .what = _what, .arg8 = _arg8, .arg32 = _arg32 }; \ + &_; }) /* handle 'tainted' status */ enum tainted_flags {