内核异常分析方法

1.通过sysdump/ramdump或者串口抓取内核日记

https://blog.csdn.net/mike8825/article/details/85039187

https://blog.csdn.net/mike8825/article/details/79219913

2.通过工具分析出错原因

写的一个空指针demo

内核异常分析方法_第1张图片

运行代码,通过串口或者sysdump抓取内核日记

内核异常分析方法_第2张图片

2.1通过arm-eabi-addr2line(将地址转换为行号)

从上面可以看出PC的地址是0xc04e8394,获取出错行号

./arm-eabi-addr2line -e vmlinux 0xc04e8394
/home/w/AndroidP/kernel/drivers/misc/suspend_lock.c:15

2.2通过arm-eabi-objdump反汇编

./arm-eabi-objdump -S vmlinux > vmlinux.txt

grep -rin c04e8394 vmlinux.txt 
1315671:c04e8394:	e5843000 	str	r3, [r4]

内核异常分析方法_第3张图片

2.3通过arm-eabi-gdb定位出错位置

w@server:/home/w/AndroidP$ ./arm-eabi-gdb out/target/product/sp9850ka_1h10_go/obj/KERNEL/vmlinux
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
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=x86_64-linux-gnu --target=arm-linux-android".
For bug reporting instructions, please see:
...
Reading symbols from /home/w/AndroidP/out/target/product/sp9850ka_1h10_go/obj/KERNEL/vmlinux...done.
(gdb) list *0xc04e8394
0xc04e8394 is in null_pointer (/home/w/AndroidP/kernel/drivers/misc/suspend_lock.c:15).
10	static struct miscdevice poll_dev;
11	
12	ssize_t null_pointer(struct device *dev, struct device_attribute *attr,char *buf)
13	{
14		char *p=NULL;
15		memcpy(p, "test", 4);
16		printk("%s\n",__FUNCTION__);
17		return 0;
18	}

如不在代码上运行,结果如下

./arm-eabi-gdb vmlinux
(gdb) list *0xc04e8394
0xc04e8394 is in null_pointer (/home/w/AndroidP/kernel/drivers/misc/suspend_lock.c:15).
10	/home/w/AndroidP/kernel/drivers/misc/suspend_lock.c: 没有那个文件或目录

 不初始化,然后使用互斥锁mutex

内核异常分析方法_第4张图片

 运行后,定屏,触摸没反应(cat /proc/interrupts没看到tp的中断),adb能连上手机,dmesg查看内核缓冲区log,如下图

内核异常分析方法_第5张图片

 根据pc位置调到指定的代码

(gdb) list *0xc0953844
0xc0953844 is in _raw_spin_lock (/home/w/AndroidP/kernel/arch/arm/include/asm/spinlock.h:77).
72		: "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
73		: "cc");
74	
75		while (lockval.tickets.next != lockval.tickets.owner) {
76			wfe();
77			lockval.tickets.owner = ACCESS_ONCE(lock->tickets.owner);
78		}
79	
80		smp_mb();
81	}

3.测试DDR稳定性

https://blog.csdn.net/mike8825/article/details/102622311

你可能感兴趣的:(死机)