linux驱动调试--oops信息

在移植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");
}

猜你喜欢

转载自blog.csdn.net/a1171936767/article/details/72991806
今日推荐