We can make complain_with_dbg() and complain() disappear from the
backtrace by forcing tail call elimination on these functions, since
ha_backtrace_to_stderr() is called last and with a compatible return
code.
Thanks to this, backtraces are clean again:
WARNING: check condition "one > zero" matched at src/debug.c:1170 (please report to developers)
This was triggered on purpose from the CLI 'debug dev check' command.
call trace(13):
| 0x6ea2c0 <09 9a 00 e8 b0 ef ff ff]: debug_parse_cli_check+0x40/0x42 > complain_with_dbg
| 0x69724a <bd a8 fd ff ff 41 ff d0]: main+0x25154a
| 0x69863c <00 00 00 e8 44 e9 ff ff]: cli_io_handler+0x54c/0xdee > main+0x251280
| 0x710830 <00 0f 29 45 c0 ff 52 18]: task_process_applet+0x340/0xd84
| 0x7b595b <00 00 4c 89 d7 41 ff d1]: run_tasks_from_lists+0x43b/0xbdb
| 0x7b651a <8d 7d b0 e8 06 f0 ff ff]: process_runnable_tasks+0x41a/0xaae > run_tasks_from_lists
| 0x70344e <01 00 00 e8 b2 2c 0b 00]: run_poll_loop+0xae/0x522 > process_runnable_tasks
| 0x703b4f <00 00 00 e8 51 f8 ff ff]: run_thread_poll_loop+0x27f/0x4ba > run_poll_loop
| 0x44703f <46 b2 00 e8 91 c8 2b 00]: main+0x133f/0x1d75 > run_thread_poll_loop
}
/* the exported function */
-void complain(uint details, const char *msg)
+eliminate_tail_calls void complain(uint details, const char *msg)
{
_complain(details, msg, NULL);
}
/* the same, for use with a debug_count struct */
-void complain_with_dbg(struct debug_count *dbg)
+eliminate_tail_calls void complain_with_dbg(struct debug_count *dbg)
{
if (_HA_ATOMIC_FETCH_ADD(&dbg->count, 1) && dbg->type == DBG_BUG_ONCE)
return;