测试代码如下:
#include <linux/compat.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/device.h> #include <linux/pci.h> #include <linux/fs.h> #include <linux/poll.h> #include <linux/interrupt.h> #include <linux/cdev.h> #include <linux/slab.h> #include <linux/phantom.h> static void test_crash(void) {char *pstr = NULL;printk("drivr crash n");*pstr = 12;printk("%s n",pstr);return; } static int __init test_init(void) {printk("drivr test n");test_crash();return 0; } static void __exit test_exit(void) {printk("drivr exit n");return ; } module_init(test_init); module_exit(test_exit); MODULE_AUTHOR("Alex<free5home5@163.com>"); MODULE_LICENSE("GPL");
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
fire_drangon 于 2019-04-18 10:07:59 发布
本文详细介绍了在ARM Linux系统中遇到内核崩溃的情况,特别是空指针异常的问题。通过分析出错信息确定错误源于非法地址访问,即空指针。接着,文章探讨了如何利用Oops信息进行栈回溯,查找函数调用关系,以理解错误源头。在没有CONFIG_FRAME_POINTER配置的情况下,需要手动解析栈信息。文中还阐述了栈在函数调用中的作用,以及如何通过栈回溯找到函数调用链。最后,提供了一种在内核未配置CONFIG_FRAME_POINTER时,通过反汇编地址来定位问题的方法。