How to read, understand, analyze, and debug a Linux kernel panic?

前端 未结 3 873
孤街浪徒
孤街浪徒 2020-12-22 17:58

Consider the following linux kernel dump stack trace, you can trigger a panic from the kernel source code by calling panic(\"debugging a linux kernel panic\");:

3条回答
  •  隐瞒了意图╮
    2020-12-22 18:42

    Here are two alternatives for addr2line. Assuming you have the proper target's toolchain, you can do one of the following:

    Use objdump:

    1. locate your vmlinux or the .ko file under the kernel root directory, then disassemble the object file :

      objdump -dS vmlinux > /tmp/kernel.s
      
    2. Open the generated assembly file, /tmp/kernel.s. with a text editor such as vim. Go to unwind_backtrace+0x0/0xf8, i.e. search for the address of unwind_backtrace + the offset. Finally, you have located the problematic part in your source code.

    Use gdb:

    IMO, an even more elegant option is to use the one and only gdb. Assuming you have the suitable toolchain on your host machine:

    1. Run gdb .
    2. Execute in gdb's prompt: list *(unwind_backtrace+0x10).

    For additional information, you may checkout the following resources:

    1. Kernel Debugging Tricks.
    2. Debugging The Linux Kernel Using Gdb

提交回复
热议问题