内核Oops的几种定位方法

反汇编

报错信息

[    1.826455] ------------[ cut here ]------------
[    1.831091] Kernel BUG at c011fef0 [verbose debug info unavailable]
[    1.837344] Internal error: Oops - BUG: 0 [#1] PREEMPT THUMB2
[    1.843108] Modules linked in:
[    1.846158] CPU: 0 PID: 1 Comm: swapper Not tainted 3.10.33 #42
[    1.852075] task: c2058000 ti: c205a000 task.ti: c205a000
[    1.857473] PC is at spifb_probe+0xc/0x34c
[    1.861591] LR is at driver_probe_device+0x75/0x15c
[    1.866440] pc : []    lr : []    psr: a0000133
[    1.866440] sp : c205bd58  ip : 00000000  fp : c2256b44
[    1.877908] r10: 00000000  r9 : c2256800  r8 : c04caea8
[    1.883124] r7 : 00000000  r6 : c2258600  r5 : 00000000  r4 : c2258600
[    1.889651] r3 : c058f4d8  r2 : 00000000  r1 : c225b8b0  r0 : c2258600
[    1.896178] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment kernel
[    1.903650] Control: 50c53c7d  Table: 00004059  DAC: 00000015
......
[    3.077561] current proc: 1 swapper
[    3.081038] -----------------------------------------------------------------------------------
[    3.089700]       pid     uTime    sTime    exec(ns)    stat   cpu   task_struct
[    3.097111] -----------------------------------------------------------------------------------
[    3.105804]        1        0      168       1826120108 R(0)    0    c2058000 swapper
[    3.113612] [] (unwind_backtrace+0x1/0x88) from [] (show_stack+0xb/0xc)
[    3.121969] [] (show_stack+0xb/0xc) from [] (dump_task_info+0xad/0xe8)
[    3.130265] [] (dump_task_info+0xad/0xe8) from [] (panic_flush+0x101/0x1c8)
[    3.138957] [] (panic_flush+0x101/0x1c8) from [] (crash_kexec+0xb/0x64)
[    3.147314] [] (crash_kexec+0xb/0x64) from [] (die+0x18b/0x27c)
[    3.154969] [] (die+0x18b/0x27c) from [] (do_undefinstr+0x63/0x100)
[    3.162960] [] (do_undefinstr+0x63/0x100) from [] (__und_svc_finish+0x1/0x40)
[    3.199835] [] (__und_svc_finish+0x1/0x40) from [] (spifb_probe+0xc/0x34c)
[    3.208466] [] (spifb_probe+0xc/0x34c) from [] (driver_probe_device+0x75/0x15c)
[    3.217525] [] (driver_probe_device+0x75/0x15c) from [] (bus_for_each_drv+0x3f/0x4a)
[    3.227010] [] (bus_for_each_drv+0x3f/0x4a) from [] (device_attach+0x3b/0x54)
[    3.235855] [] (device_attach+0x3b/0x54) from [] (bus_probe_device+0x17/0x60)
[    3.244731] [] (bus_probe_device+0x17/0x60) from [] (device_add+0x2c9/0x374)
[    3.253545] [] (device_add+0x2c9/0x374) from [] (spi_add_device+0x95/0xd0)
[    3.262146] [] (spi_add_device+0x95/0xd0) from [] (spi_register_master+0x3cf/0x40c)
[    3.271540] [] (spi_register_master+0x3cf/0x40c) from [] (asr_spi_probe+0x2a1/0x440)
[    3.281026] [] (asr_spi_probe+0x2a1/0x440) from [] (driver_probe_device+0x75/0x15c)
[    3.290450] [] (driver_probe_device+0x75/0x15c) from [] (__driver_attach+0x35/0x48)
[    3.299844] [] (__driver_attach+0x35/0x48) from [] (bus_for_each_dev+0x3b/0x46)
[    3.308872] [] (bus_for_each_dev+0x3b/0x46) from [] (bus_add_driver+0x89/0x148)
[    3.317930] [] (bus_add_driver+0x89/0x148) from [] (driver_register+0x4b/0x98)
[    3.326897] [] (driver_register+0x4b/0x98) from [] (do_one_initcall+0x69/0xe8)
[    3.335864] [] (do_one_initcall+0x69/0xe8) from [] (kernel_init_freeable+0xab/0x140)
[    3.345350] [] (kernel_init_freeable+0xab/0x140) from [] (kernel_init+0x7/0xa0)
[    3.354408] [] (kernel_init+0x7/0xa0) from [] (ret_from_fork+0x11/0x34)
[    3.362735]       53        0        0       1826120108 R(0)    0    c222e900 kworker/u2:1
[    3.371000] -----------------------------------------------------------------------------------

gdb定位

./owtoolchain/linux64/bin/arm-openwrt-linux-uclibcgnueabi-gdb ./marvell/linux/vmlinux.o
disassemble /m spifb_probe

867     static int spifb_probe (struct spi_device *spi)
868     {
   0x0012e374 <+0>:     stmdb   sp!, {r0, r1, r2, r3, r4, r5, r6, r7, r8, lr}
   0x0012e378 <+4>:     mov     r6, r0

869             struct device_node *np = spi->dev.of_node;
870             struct fb_info *info;
871             struct spifb_par *par;
872             int retval = -ENOMEM;
   0x0012e45a <+230>:   mvn.w   r7, #11
   0x0012e5d0 <+604>:   mvn.w   r0, #11
   0x0012e5d4 <+608>:   b.n     0x12e622 

873             struct pinctrl *pinctrl;
874             BUG_ON(np != NULL);
   0x0012e37a <+6>:     ldr.w   r3, [r0, #324]  ; 0x144
   0x0012e37e <+10>:    cbz     r3, 0x12e382 
   0x0012e380 <+12>:    stmiami r9!, {r1, r9, r10, r11, r12, lr, pc}

875             pr_err("enter spifb_probe.\n");

addr2line

报错信息

[KR] Oops at 0xc0laf9fa in kworker/u2:2

addr2line定位

./owtoolchain/linux64/bin/arm-openwrt-linux-uclibcgnueabi-addr2line -C -f -e ./marvell/linux/arch/arm/boot/compressed/vmlinux 0xc0laf9fa
restart
/openwrt/marvell/linux/arch/arm/boot/compressed/head.S:207

函数基地址+偏移

报错信息

PC is at pl031_probe+0x120/0x1e8

addr2line定位

前置条件,内核打开CONFIG_DEBUG_INFO选项,保存
1)根据System.map找到函数基地址,示例中,pl031_probe基地址c0363878 t pl031_probe。
2)需要查询的地址为基地址+偏移地址。示例中崩溃代码虚拟地址为0xc0363878 + 0x120 = 0xc0363998
./owtoolchain/linux64/bin/arm-openwrt-linux-uclibcgnueabi-addr2line -C -f -e ./marvell/linux/arch/arm/boot/compressed/vmlinux 0xc0363998

你可能感兴趣的:(Linux内核之驱动,linux,服务器,算法)