Kernel_panic

2021-01-24, updated 2021-09-12

需要打开以下项,保证有足够的调试信息

CONFIG_DEBUG_KERNEL=y
CONFIG_DEBUG_INFO=y
CONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y
CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_STACKTRACE=y

panic 信息

[  201.500000] hello,world
[  201.510000] Kernel bug detected[#1]:
[  201.510000] CPU: 0 PID: 2491 Comm: insmod Not tainted 3.10.90 #10
[  201.510000] task: 871732a0 ti: 84248000 task.ti: 84248000
[  201.510000] $ 0   : 00000000 80840000 00000001 000052a0
[  201.510000] $ 4   : c013c260 c013c260 ffffd988 00100000
[  201.510000] $ 8   : 00000064 00000003 00000000 00000000
[  201.510000] $12   : 00000187 00000000 00000000 00000000
[  201.510000] $16   : c013c260 8002f34c 00000000 c0144000
[  201.510000] $20   : 00000000 806c0000 00000001 840dbe80
[  201.510000] $24   : 00000002 8000183c                  
[  201.510000] $28   : 84248000 8424bdc8 00000001 c0144084
[  201.510000] Hi    : 00000000
[  201.510000] Lo    : 364ea000
[  201.510000] epc   : 8002f354 add_timer+0x8/0x14
[  201.510000]     Not tainted
[  201.510000] ra    : c0144084 init_module+0x84/0x9c [timer_test]
[  201.510000] Status: 1000f403 KERNEL EXL IE 
[  201.510000] Cause : 10800034
[  201.510000] PrId  : 00019385 (MIPS 24Kc)
[  201.510000] Modules linked in: timer_test(+) GobiNet [last unloaded: timer_test]
[  201.510000] Process insmod (pid: 2491, threadinfo=84248000, task=871732a0, tls=77e0be50)
[  201.510000] Stack : 00000001 00000001 c013c120 ffffffff c013c12c c013c12c 80840000 8000043c
          00000000 8080007f 00000001 8428fe00 8424bed8 c013c12c c013c120 80046e04
          8424bed8 c013c12c c013c120 8424bed8 806c0000 00000000 806c0000 80061c48
          c013c120 771f8e54 00000001 8008f920 c013c12c 00007fff 8005f290 8424be88
          fff94000 00000000 00000000 00000000 00000000 00000000 00000000 00464008
          ...
[  201.510000] Call Trace:
[  201.510000] [<8002f354>] add_timer+0x8/0x14
[  201.510000] [<c0144084>] init_module+0x84/0x9c [timer_test]
[  201.510000] [<8000043c>] do_one_initcall+0x3c/0x1b4
[  201.510000] [<80061c48>] load_module+0xf84/0x14c4
[  201.510000] [<8006225c>] SyS_init_module+0xd4/0xec
[  201.510000] [<8000b244>] stack_done+0x20/0x40
[  201.510000] 
[  201.510000] 
Code: 00402021  8c820000  0002102b <00020336> 0800bc71  8c850008  27bdffd8  afbf0024  afb30020 
[  201.510000] c0_compare_interrupt 64

可以使用gdb来查看错误位置

$ gdb vmlinux 
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from vmlinux...done.
(gdb) l *add_timer+0x8
0x8002f3e8 is in add_timer (/home/bmduser10/develop/realtek/R810/rtl819x/linux-3.10/arch/mips-ori/include/asm/bug.h:29).
24                      if (condition)
25                              BUG();
26                      else
27                              return;
28              }
29              __asm__ __volatile__("tne $0, %0, %1"
30                                   : : "r" (condition), "i" (BRK_BUG));
31      }
32
33      #define BUG_ON(C) __BUG_ON((unsigned long)(C))

需要有Reading symbols from vmlinux…done.才能调试,如果没有会显示Reading symbols from vmlinux…(no debugging symbols found)…done.

words: 490 tags: