内核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 : [<c011fef0>] lr : [<c013fd45>] 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] [<c00198e9>] (unwind_backtrace+0x1/0x88) from [<c0017e5f>] (show_stack+0xb/0xc)
[ 3.121969] [<c0017e5f>] (show_stack+0xb/0xc) from [<c01ed7d5>] (dump_task_info+0xad/0xe8)
[ 3.130265] [<c01ed7d5>] (dump_task_info+0xad/0xe8) from [<c0049f39>] (panic_flush+0x101/0x1c8)
[ 3.138957] [<c0049f39>] (panic_flush+0x101/0x1c8) from [<c004a223>] (crash_kexec+0xb/0x64)
[ 3.147314] [<c004a223>] (crash_kexec+0xb/0x64) from [<c0017feb>] (die+0x18b/0x27c)
[ 3.154969] [<c0017feb>] (die+0x18b/0x27c) from [<c0008267>] (do_undefinstr+0x63/0x100)
[ 3.162960] [<c0008267>] (do_undefinstr+0x63/0x100) from [<c0008ca1>] (__und_svc_finish+0x1/0x40)
[ 3.199835] [<c0008ca1>] (__und_svc_finish+0x1/0x40) from [<c011fef0>] (spifb_probe+0xc/0x34c)
[ 3.208466] [<c011fef0>] (spifb_probe+0xc/0x34c) from [<c013fd45>] (driver_probe_device+0x75/0x15c)
[ 3.217525] [<c013fd45>] (driver_probe_device+0x75/0x15c) from [<c013ee9f>] (bus_for_each_drv+0x3f/0x4a)
[ 3.227010] [<c013ee9f>] (bus_for_each_drv+0x3f/0x4a) from [<c013fca3>] (device_attach+0x3b/0x54)
[ 3.235855] [<c013fca3>] (device_attach+0x3b/0x54) from [<c013f6b3>] (bus_probe_device+0x17/0x60)
[ 3.244731] [<c013f6b3>] (bus_probe_device+0x17/0x60) from [<c013e8a9>] (device_add+0x2c9/0x374)
[ 3.253545] [<c013e8a9>] (device_add+0x2c9/0x374) from [<c016d665>] (spi_add_device+0x95/0xd0)
[ 3.262146] [<c016d665>] (spi_add_device+0x95/0xd0) from [<c016e063>] (spi_register_master+0x3cf/0x40c)
[ 3.271540] [<c016e063>] (spi_register_master+0x3cf/0x40c) from [<c016f4bd>] (asr_spi_probe+0x2a1/0x440)
[ 3.281026] [<c016f4bd>] (asr_spi_probe+0x2a1/0x440) from [<c013fd45>] (driver_probe_device+0x75/0x15c)
[ 3.290450] [<c013fd45>] (driver_probe_device+0x75/0x15c) from [<c013fe85>] (__driver_attach+0x35/0x48)
[ 3.299844] [<c013fe85>] (__driver_attach+0x35/0x48) from [<c013ee45>] (bus_for_each_dev+0x3b/0x46)
[ 3.308872] [<c013ee45>] (bus_for_each_dev+0x3b/0x46) from [<c013f80d>] (bus_add_driver+0x89/0x148)
[ 3.317930] [<c013f80d>] (bus_add_driver+0x89/0x148) from [<c01401af>] (driver_register+0x4b/0x98)
[ 3.326897] [<c01401af>] (driver_register+0x4b/0x98) from [<c0012bb9>] (do_one_initcall+0x69/0xe8)
[ 3.335864] [<c0012bb9>] (do_one_initcall+0x69/0xe8) from [<c047985b>] (kernel_init_freeable+0xab/0x140)
[ 3.345350] [<c047985b>] (kernel_init_freeable+0xab/0x140) from [<c000edd3>] (kernel_init+0x7/0xa0)
[ 3.354408] [<c000edd3>] (kernel_init+0x7/0xa0) from [<c000913d>] (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_probe867 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, r0869 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, #110x0012e5d0 <+604>: mvn.w r0, #110x0012e5d4 <+608>: b.n 0x12e622 <spifb_probe+686>873 struct pinctrl *pinctrl;
874 BUG_ON(np != NULL);0x0012e37a <+6>: ldr.w r3, [r0, #324] ; 0x1440x0012e37e <+10>: cbz r3, 0x12e382 <spifb_probe+14>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