1. Linux driver打印函数调用堆栈
#include <linux/kprobes.h>
#include <asm/traps.h>
dump_stack();
2. 强制空指针, 引发panic
添加如下语句, 既可引发panic:
*(int *)0 = 1;
3. printk打印debug信息
#define KERN_EMERG KERN_SOH "0" /* system is unusable */
#define KERN_ALERT KERN_SOH "1" /* action must be taken immediately */
#define KERN_CRIT KERN_SOH "2" /* critical conditions */
#define KERN_ERR KERN_SOH "3" /* error conditions */
#define KERN_WARNING KERN_SOH "4" /* warning conditions */
#define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */
#define KERN_INFO KERN_SOH "6" /* informational */
#define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
使用adb命令:
> adb shell "echo 8 > /proc/sys/kernel/printk"
4. bugreport获取全部LOG
> adb bugreport > bugreport.txt
使用bugreport获取开机LOG.