From: Willy Tarreau Date: Mon, 10 Aug 2026 14:29:44 +0000 (+0200) Subject: DEBUG: cli: add a "debug dev abort" debugging command X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52698abae98e1d210d326c431d6cf1ef56c9e57a;p=thirdparty%2Fhaproxy.git DEBUG: cli: add a "debug dev abort" debugging command We had "debug dev bug/check/warn" to test the various BUG_ON() macros but we didn't have a way to test ABORT_NOW(). So let's introduce "debug dev abort" for this. --- diff --git a/src/debug.c b/src/debug.c index 6e85ab3d5..26b442a14 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1022,6 +1022,19 @@ int debug_parse_cli_check(char **args, char *payload, struct appctx *appctx, voi return 1; } +/* parse a "debug dev abort" command. It always returns 1. + * Note: we make sure not to make the function static so that it appears in the trace. + */ +int debug_parse_cli_abort(char **args, char *payload, struct appctx *appctx, void *private) +{ + if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) + return 1; + + _HA_ATOMIC_INC(&debug_commands_issued); + ABORT_NOW("This was triggered on purpose from the CLI 'debug dev abort' command."); + return 1; +} + /* parse a "debug dev close" command. It always returns 1. */ static int debug_parse_cli_close(char **args, char *payload, struct appctx *appctx, void *private) { @@ -3081,6 +3094,7 @@ static struct cli_kw_list cli_kws = {{ },{ #if !defined(USE_OBSOLETE_LINKER) {{ "debug", "counters", NULL }, "debug counters [?|all|bug|cnt|chk|glt]* : dump/reset rare event counters", debug_parse_cli_counters, debug_iohandler_counters, NULL, NULL, 0 }, #endif + {{ "debug", "dev", "abort", NULL }, "debug dev abort : call ABORT_NOW() and possibly crash", debug_parse_cli_abort, NULL, NULL, NULL, ACCESS_EXPERT }, {{ "debug", "dev", "bug", NULL }, "debug dev bug : call BUG_ON() and crash", debug_parse_cli_bug, NULL, NULL, NULL, ACCESS_EXPERT }, {{ "debug", "dev", "check", NULL }, "debug dev check : call CHECK_IF() and possibly crash", debug_parse_cli_check, NULL, NULL, NULL, ACCESS_EXPERT }, {{ "debug", "dev", "close", NULL }, "debug dev close [hard] : close this file descriptor", debug_parse_cli_close, NULL, NULL, NULL, ACCESS_EXPERT },