从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx

上传人:b****2 文档编号:14755586 上传时间:2022-10-24 格式:DOCX 页数:10 大小:22.71KB
下载 相关 举报
从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx_第1页
第1页 / 共10页
从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx_第2页
第2页 / 共10页
从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx_第3页
第3页 / 共10页
从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx_第4页
第4页 / 共10页
从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx

《从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx(10页珍藏版)》请在冰豆网上搜索。

从oops中查找错误代码行堆栈错误信息Word文档下载推荐.docx

Oops:

817[#1]

Moduleslinkedin:

CPU:

Nottainted 

(2.6.27.18#221)

PCisatfree_block+0x78/0x168 

//当前指令地址

LRisatrelease_console_sem+0x19c/0x1b8 

//函数返回地址

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

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

就可以得到出错行

[root@kqyang-hikvisionlinux-2.6.27_svn_quyong]#arm-wrs-linux-gnueabi-armv6jel_vfp-uclibc_small-gdbvmlinux

GNUgdb(WindRiverLinuxSourceryG++4.3-85)6.8.50.20080821-cvs

Copyright(C)2008FreeSoftwareFoundation,Inc.

LicenseGPLv3+:

GNUGPLversion3orlater<

http:

//gnu.org/licenses/gpl.html>

Thisisfreesoftware:

youarefreetochangeandredistributeit.

ThereisNOWARRANTY,totheextentpermittedbylaw. 

Type"

showcopying"

and"

showwarranty"

fordetails.

ThisGDBwasconfiguredas"

--host=i686-pc-linux-gnu--target=arm-wrs-linux-gnueabi"

.

Forbugreportinginstructions,pleasesee:

<

support@>

...

(gdb)l*0x40097B38

0x40097b38isinfree_block(include/linux/list.h:

93).

88 

*theprev/nextentriesalready!

89 

*/

90 

#include<

linux/kernel.h>

91 

staticinlinevoid__list_del(structlist_head*prev,structlist_head*next)

92 

{

93 

next->

prev=prev;

94 

prev->

next=next;

95 

}

96

97 

/**

(gdb)

原文地址:

linux内核的oops信息作者:

XINU

Oops可看成是内核级(特权级)的SegmentationFault。

一般应用程序(用户级)如进行了内存的非法访问(地址不合法、无权限访问、……)或执行了非法指令,则会得到Segfault信号,一般对应的行为是coredump,应用程序也可以自行获取Segfault信号进行处理,而内核出错则是打印出Oops信息。

内核打印Oops信息的执行流程:

1、do_page_fault()(arch/i386/mm/fault.c),如果内核出现非法访问,则该函数会打印出EIP、PDE等信息,如下:

Unabletohandlekernelpagingrequestatvirtualaddressf899b670

printingeip:

c01de48c

*pde=00737067

接下来调用die("

Oops"

regs,error_code);

函数,此时如果系统还活着(至少要满足两个条件:

1.在进程上下文2.没有设置panic_on_oops),则会kill掉当前进程,以致死机。

2、die()(arch/i386/kernel/traps.c),该函数最开始会打印出:

Oops:

0002[#1]

其中,0002代表错误码,#1代表Oops发生次数。

error_code:

*bit0 

0meansnopagefound,1meansprotectionfault

*bit1 

0meansread,1meanswrite

*bit2 

0meanskernel,1meansuser-mode

*bit3 

0meansdata,1meansinstruction

接下来会调用show_registers(regs)函数,输出寄存器、当前进程、堆栈、指令代码等信息,以供判断。

Linux内核在发生kernelpanic时会打印出Oops信息,把当前的寄存器状态、堆栈信息、完整的Calltrace都打印出来,以帮助我们定位错误。

下在是一个例子,该例子展示了空指针引用错误。

01 

#include<

02 

linux/module.h>

03 

04 

staticint__inithello_init(void)

05 

{

06 

int*p=0;

07 

08 

*p=1;

09 

return0;

10 

}

11

12 

staticvoid__exithello_exit(void)

13 

14 

return;

15 

16

17 

module_init(hello_init);

18 

module_exit(hello_exit);

19

20 

MODULE_LICENSE("

GPL"

);

从上面的代码中,我们可以很容易看到出错的代码在08行,当我们把它编译成一个*.ko模块,并使用insmod将其添加到内核时,Oops信息如期而至,如下:

100.243737]BUG:

unabletohandlekernelNULLpointerdereferenceat(null)

100.244985]IP:

[<

f82d2005>

]hello_init+0x5/0x11[hello]

100.262266]*pde=00000000 

100.288395]Oops:

0002[#1]SMP 

100.305468]lastsysfsfile:

/sys/devices/virtual/sound/timer/uevent

100.325955]Moduleslinkedin:

hello(+)vmblockvsockvmmemctlvmhgfsacpiphpsnd_ens1371gameportsnd_ac97_codecac97_bussnd_pcm_oss 

snd_mixer_osssnd_pcmsnd_seq_dummysnd_seq_osssnd_seq_midisnd_rawmidisnd_seq_midi_eventsnd_seqsnd_timersnd_seq_deviceppdevpsmouseserio_raw 

fbcontileblitfontbitblitsoftcursorsndparport_pcsoundcoresnd_page_allocvmcii2c_piix4vga16fbvgastateintel_agpagpgartshpchplpparport 

floppypcnet32miimptspimptscsihmptbasescsi_transport_spivmxnet

100.472178][ 

100.494931]Pid:

1586,comm:

insmodNottainted(2.6.32-21-generic#32-Ubuntu)VMwareVirtualPlatform

100.540018]EIP:

0060:

[<

]EFLAGS:

00010246CPU:

0

100.562844]EIPisathello_init+0x5/0x11[hello]

100.584351]EAX:

00000000EBX:

fffffffcECX:

f82cf040EDX:

00000001

100.609358]ESI:

f82cf040EDI:

00000000EBP:

f1b9ff5cESP:

f1b9ff5c

100.631467] 

DS:

007bES:

007bFS:

00d8GS:

00e0SS:

0068

100.657664]Processinsmod(pid:

1586,ti=f1b9e000task=f137b340task.ti=f1b9e000) 

100.706083]Stack:

100.731783] 

f1b9ff88c0101131f82cf04

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 其它课程

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1