您的位置:首页 > 运维架构 > Linux

linux驱动调试--oops信息

2017-06-10 16:27 543 查看
在移植dm9000 时被一个错误困扰了很久,当时手里只有printk调试手段,觉得自己应该升级下了,先学习了根据oops信息来调试。

先构造一个错误,insmod后抛出如下信息



我们着重看这几句

PC is at memcpy+0x8c/0x29c c0148080

pc : [] lr : [<74736574>] psr: 00000013

回溯信息

Backtrace:

[] (hello_init+0x0/0x38 [dbug]) from []

看到这些信息大概可以知道问题所在了,我们接着把文件objdump一下

执行 arm-linux-objdump -D dbug.ko > dbug.inf



根据oops信息,PC is at memcpy+0x8c/0x29c c0148080 是在memcpy函数出错,在回溯信息里[] (hello_init+0x0/0x38 [dbug]) from [] 在hello_init 的0x38偏移处调用的发生错误的函数。

问题到这里就差不多了,后面会陆续跟几种调试手段。随便附上这次的测试代码

#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
char *p = NULL;
memcpy(p, "test", 4);
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{

printk(KERN_ALERT "Goodbye, cruel world\n");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息