From: Willy Tarreau Date: Tue, 11 Aug 2026 06:05:35 +0000 (+0200) Subject: CLEANUP: debug: move ha_backtrace_to_stderr() declaration to bug.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b5f8f9730a2000c7401e7053972b4dba6b8870c;p=thirdparty%2Fhaproxy.git CLEANUP: debug: move ha_backtrace_to_stderr() declaration to bug.h The DUMP_TRACE() macro was made just to manually reference the external ha_backtrace_to_stderr() function that is defined in debug.h, but this makes the code even harder to follow. In fact, the current rule that bug.h contains all mandatory declarations and that debug.h contains the optional ones is not respected here, so let's just move the declaration there and get rid of the macro. --- diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index 2f4c77543..dba36c12c 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -40,6 +40,8 @@ #define DPRINTF(x...) #endif +void ha_backtrace_to_stderr(void); + /* Let's make DEBUG_STRESS equal to zero if not set or not valid, or to * 1 if set. This way it is always set and should be easy to use in "if ()" * statements without requiring ifdefs, while remaining compatible with @@ -57,8 +59,6 @@ # define DEBUG_STRICT_ACTION 3 // enable crash on match #endif -#define DUMP_TRACE() do { extern void ha_backtrace_to_stderr(void); ha_backtrace_to_stderr(); } while (0) - /* First, let's try to handle some arch-specific crashing methods. We prefer * the macro to the function because when opening the core, the debugger will * directly show the calling point (e.g. the BUG_ON() condition) based on the @@ -146,7 +146,7 @@ static __attribute__((noinline,noreturn,unused)) void abort_with_line(uint line) const char *msg; \ if (sizeof("" __VA_ARGS__) > 1) \ complain(NULL, "\nABORT at " file ":" #line ": " __VA_ARGS__ "\n", 1); \ - DUMP_TRACE(); \ + ha_backtrace_to_stderr(); \ msg = "\n" \ "Hint: when reporting this bug to developers, please check if a core file was\n" \ " produced, open it with 'gdb', issue 'bt' to produce a backtrace for the\n" \ @@ -164,7 +164,7 @@ static __attribute__((noinline,noreturn,unused)) void abort_with_line(uint line) const char *msg; \ if (sizeof("" __VA_ARGS__) > 1) \ complain(NULL, "\nABORT at " file ":" #line ": " __VA_ARGS__ "\n", 1); \ - DUMP_TRACE(); \ + ha_backtrace_to_stderr(); \ msg = "\n" \ "Hint: when reporting this bug to developers, please check if a core file was\n" \ " produced, open it with 'gdb', issue 'bt' to produce a backtrace for the\n" \ @@ -312,7 +312,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S if (crash & 1) \ ABORT_NOW(); \ else \ - DUMP_TRACE(); \ + ha_backtrace_to_stderr(); \ } while (0) /* This one is equivalent except that it only emits the message once by @@ -340,7 +340,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S if (crash & 1) \ ABORT_NOW(); \ else \ - DUMP_TRACE(); \ + ha_backtrace_to_stderr(); \ } while (0) diff --git a/include/haproxy/debug.h b/include/haproxy/debug.h index 7f6458c9c..65947e841 100644 --- a/include/haproxy/debug.h +++ b/include/haproxy/debug.h @@ -30,7 +30,6 @@ extern unsigned int warn_blocked_issued; void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx); void ha_thread_dump_one(struct buffer *buf, int is_caller); void ha_dump_backtrace(struct buffer *buf, const char *prefix, int dump); -void ha_backtrace_to_stderr(void); void ha_panic(void); void ha_stuck_warning(void);