MINOR: debug: report the task handler's pointer relative to main

Often in crash dumps we see unknown function pointers. Let's display
them relative to main, that helps quite a lot figure the function
from an executable, for example:

  (gdb) x/a main+645360
  0x4c56a0 <h1_timeout_task>:     0x2e6666666666feeb

This could be backported to 2.0.
This commit is contained in:
Willy Tarreau 2020-03-03 07:04:42 +01:00
parent 7d9421deca
commit 516853f1cc

View File

@ -101,6 +101,7 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx)
const struct stream *s = NULL; const struct stream *s = NULL;
const struct appctx __maybe_unused *appctx = NULL; const struct appctx __maybe_unused *appctx = NULL;
struct hlua __maybe_unused *hlua = NULL; struct hlua __maybe_unused *hlua = NULL;
extern int main(int, char **);
if (!task) { if (!task) {
chunk_appendf(buf, "0\n"); chunk_appendf(buf, "0\n");
@ -121,9 +122,11 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx)
task->call_date ? " ns ago" : ""); task->call_date ? " ns ago" : "");
chunk_appendf(buf, "%s" chunk_appendf(buf, "%s"
" fct=%p (%s) ctx=%p", " fct=%p=main%s%ld (%s) ctx=%p",
pfx, pfx,
task->process, task->process,
((void *)task->process - (void *)main) < 0 ? "" : "+",
(long)((void *)task->process - (void *)main),
task->process == process_stream ? "process_stream" : task->process == process_stream ? "process_stream" :
task->process == task_run_applet ? "task_run_applet" : task->process == task_run_applet ? "task_run_applet" :
task->process == si_cs_io_cb ? "si_cs_io_cb" : task->process == si_cs_io_cb ? "si_cs_io_cb" :