How to make good use of stack trace (from kernel or core dump)?

后端 未结 2 1015
青春惊慌失措
青春惊慌失措 2020-12-29 06:28

If you are lucky when your kernel module crashes, you would get an oops with a log with a lot of information, such as values in the registers etc. One such information is th

相关标签:
2条回答
  • 2020-12-29 07:14

    For Emacs users, here's is a major mode to easily jump around within the stack trace (uses addr2line internally).

    Disclaimer: I wrote it :)

    0 讨论(0)
  • 2020-12-29 07:16
    skink_free_devices+0x32/0xb0
    

    This means the offending instruction is 0x32 bytes from the start of the function skink_free_devices() which is 0xB0 bytes long in total.

    If you compile your kernel with -g enabled, then you can get the line number inside functions where the control jumped using the tool addr2line or our good old gdb

    Something like this

    $ addr2line -e ./vmlinux 0xc01cf0d1
    /mnt/linux-2.5.26/include/asm/bitops.h:244
    or
    $ gdb ./vmlinux
    ...
    (gdb) l *0xc01cf0d1
    0xc01cf0d1 is in read_chan (include/asm/bitops.h:244).
    (...)
    244     return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
    (...)
    

    So just give the address you want to inspect to addr2line or gdb and they shall tell you the line number in the source file where the offending function is present See this article for full details

    EDIT: vmlinux is the uncompressed version of the kernel used for debugging and is generally found @ /lib/modules/$(uname -r)/build/vmlinux provided you have built your kernel from sources. vmlinuz that you find at /boot is the compressed kernel and may not be that useful in debugging

    0 讨论(0)
提交回复
热议问题