How to include C backtrace in a kernel module code?

后端 未结 4 1791
遥遥无期
遥遥无期 2021-02-01 04:13

So I am trying to find out what kernel processes are calling some functions in a block driver. I thought including backtrace() in the C library would make it easy. But I am havi

4条回答
  •  遥遥无期
    2021-02-01 04:34

    I know this question is about Linux, but since it's the first result for "backtrace kernel", here's a few more solutions:


    DragonFly BSD

    It's print_backtrace(int count) from /sys/sys/systm.h. It's implemented in /sys/kern/kern_debug.c and/or /sys/platform/pc64/x86_64/db_trace.c. It can be found by searching for panic, which is implemented in /sys/kern/kern_shutdown.c, and calls print_backtrace(6) if DDB is defined and trace_on_panic is set, which are both defaults.


    FreeBSD

    It's kdb_backtrace(void) from /sys/sys/kdb.h. Likewise, it's easy to find by looking into what the panic implementation calls when trace_on_panic is true.


    OpenBSD

    Going the panic route, it appears to be db_stack_dump(), implemented in /sys/ddb/db_output.c. The only header mention is /sys/ddb/db_output.h.

提交回复
热议问题