Kernel Panic的debug方法小结

经常在debug kernel的时候,会遇到空指针或者其他导致内核崩溃的情况,如下所列。

这时候dvi1_set_stream+0x274/0x3d4指出了内核崩溃的位置,但是这个偏移量无法直接确定准确的文件中的行数,今天在交叉编译工具里发现了两个很有用的工具,objdump和addr2line,在Makefile文件中加入-g选项,增加调试信息,然后用objdump来得到相应的函数地址,如这里的dvi1_set_stream的首地址(如0x70c),然后用$(CROSS_COMPILE)-addr2line -e gcisp_dv1.o -a 70c,得到208,就可以得到dvi1_set_stream这个函数所在文件的偏离行数,即准确定位到引起空指针的位置,有助于快速准确地找到bug所在。


[   61.702682] Unable to handle kernel NULL pointer dereference at virtual address 00000024

[   61.710866] pgd = c0004000
[   61.713673] [00000024] *pgd=00000000
[   61.717419] Internal error: Oops: 17 [#1] ARM
[   61.721858] Modules linked in: rtl8189es_wlan mt5931_wlan mwifiex_sdio mwifiex ath6kl_sdio ath6kl_core cfg80211
[   61.732444] CPU: 0 PID: 511 Comm: kworker/0:2 Not tainted 3.10.12 #213
[   61.739200] Workqueue: events isp_err_work_struct_handler
[   61.744754] task: c263b180 ti: c273e000 task.ti: c273e000
[   61.750313] PC is at dvi1_set_stream+0x274/0x3d4
[   61.755066] LR is at dvi1_set_stream+0x248/0x3d4
[   61.759843] pc : [<c02d9340>]    lr : [<c02d9314>]    psr: 60000093
[   61.759843] sp : c273feb0  ip : 00000001  fp : 00000009
[   61.771447] r10: 00000000  r9 : 00000000  r8 : 60000013
[   61.776790] r7 : c1414928  r6 : 00000000  r5 : 00000001  r4 : c2658b70
[   61.783431] r3 : 00000000  r2 : 000000d3  r1 : c04218f8  r0 : c04ebe68
[   61.790081] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[   61.797595] Control: 10c53c7d  Table: 02c30059  DAC: 00000015
[   61.803458] Process kworker/0:2 (pid: 511, stack limit = 0xc273e230)
[   61.809921] Stack: (0xc273feb0 to 0xc2740000)
[   61.814459] fea0:                                     00000001 00001000 00001000 2030302d
[   61.822852] fec0: 303a3030 30303a30 c263b180 c2658304 00000000 c26586e8 c2659338 c2658b70
[   61.831244] fee0: c26586e8 c2658304 c16d3100 c02d346c c02d3328 c2685340 c2659338 c140ce98
[   61.839637] ff00: c273e000 c002ec10 c273ff3c c03fc768 c03feacc c2644800 c2685358 c2685340
[   61.848028] ff20: c140ce98 c140cea8 c273e000 c2685358 c142fc13 00000001 00000009 c002f20c
[   61.856414] ff40: c002f0dc c2644b00 00000000 c3837eac 00000000 c2685340 c002f0dc 00000000
[   61.864797] ff60: 00000000 00000000 00000000 c0034194 b6fe4000 00000000 00000000 c2685340
[   61.873187] ff80: 00000000 c273ff84 c273ff84 00000000 c273ff90 c273ff90 c273ffac c3837eac
[   61.881568] ffa0: c00340e0 00000000 00000000 c000e158 00000000 00000000 00000000 00000000
[   61.889941] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   61.898322] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 15830000
[   61.906838] [<c02d9340>] (dvi1_set_stream+0x274/0x3d4) from [<c02d346c>] (isp_err_work_struct_handler+0x144/0x160)
[   61.917476] [<c02d346c>] (isp_err_work_struct_handler+0x144/0x160) from [<c002ec10>] (process_one_work+0xf0/0x334)
[   61.928070] [<c002ec10>] (process_one_work+0xf0/0x334) from [<c002f20c>] (worker_thread+0x130/0x35c)
[   61.937478] [<c002f20c>] (worker_thread+0x130/0x35c) from [<c0034194>] (kthread+0xb4/0xb8)
[   61.946035] [<c0034194>] (kthread+0xb4/0xb8) from [<c000e158>] (ret_from_fork+0x14/0x3c)
[   61.954322] Code: e3a020d3 e59f1160 e30b0e68 e34c004e (e5937024)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值