从oops信息查找出错代码行

本文介绍了如何通过Linux内核的Oops信息来查找和分析出错代码行。首先,需要重新编译内核包含调试信息,然后根据Oops信息中的PC和LR地址,结合system_map找到对应的代码位置。通过GDB调试器,可以进一步定位到出错的具体代码行,例如在`free_block`函数中。同时,文章还推荐了一个有关oops分析的博客资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

1)从oops crash的地方开始查起,首先找到指针访问错误的代码行

a)重新编译内核时,选上kernel hacking--->compile the kernel with debug info

                                                                     ---->kernel debugging

使得内核包含调试信息,

b)然后从Oops信息中找到“PC is at free_block+0x8c/0x168

##########################################################

Unable to handle kernel paging request at virtual address 000c0604 //非法指针地址

pgd = 40004000

[000c0604] *pgd=00000000

Internal error: Oops: 817 [#1]

Modules linked in:

CPU: 0    Not tainted  (2.6.27.18 #221)

PC is at free_block+0x78/0x168                                   //当前指令地址

LR is at release_console_sem+0x19c/0x1b8           //函数返回地址

##########################################################

system_map中查到free_block地址0x40097ac0+0x78得到0x40097B38

c)在内核根目录运行arm-wrs-linux-gnueabi-armv6jel_vfp-uclibc_small-gdb vmlinux

就可以得到出错行

 

 

[root@kqyang-hikvision linux-2.6.27_svn_quyong]# arm-wrs-linux-gnueabi-armv6jel_vfp-uclibc_small-gdb vmlinux

GNU gdb (Wind River Linux Sourcery G++ 4.3-85) 6.8.50.20080821-cvs

Copyright (C) 2008 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 "--host=i686-pc-linux-gnu --target=arm-wrs-linux-gnueabi".

For bug reporting instructions, please see:

<support@windriver.com>...

(gdb) l *0x40097B38

0x40097b38 is in free_block (include/linux/list.h:93).

88       * the prev/next entries already!

89       */

90       #include <linux/kernel.h>

91      static inline void __list_del(struct list_head * prev, struct list_head * next)

92      {

93              next->prev = prev;

94              prev->next = next;

95      }

96

97      /**

(gdb)

 

另外,有个关于oops分析的文章不错,地址如下:

http://blog.chinaunix.net/space.php?uid=11134731&do=blog&cuid=1166585

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值