]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: debug: move ha_backtrace_to_stderr() declaration to bug.h
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Aug 2026 06:05:35 +0000 (08:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 15:43:30 +0000 (17:43 +0200)
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.

include/haproxy/bug.h
include/haproxy/debug.h

index 2f4c77543cc194db695ff4c53551c7d36d60e11b..dba36c12c233d1fa12068367b40d897847149377 100644 (file)
@@ -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)
 
 
index 7f6458c9c5775fc52808a85394c3357619b747c5..65947e8410eeb7dde3c06fddc362a09e29001a59 100644 (file)
@@ -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);