static int so2_panic_init(void) { pr_info("panic_init\n"); timer_setup(&panic_timer, do_panic, 0); mod_timer(&panic_timer, jiffies + 2 * HZ); return 0; } 加载模块将生成以下kernel panic消息: root@qemux86:~/skels/debugging/panic# insmod panic.ko panic: loading out-of-tree modul...
CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=16000 CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y---关闭此选项,则不需要在命令行添加kmemleak=on 使用方法: 立即触发保存扫描结果 echo scan > /sys/kernel/debug/kmemleak 显示可能的内存泄漏的详细信息,需要先挂载debugfs文件系统: mount -t debugfs nodev /sys/kernel/debug...
第一步应该会比较容易找到导致panic 的C代码行,根据产生panic的代码进一步找到panic的引入点,这一步可以搭配printk来定位(如果是大概率panic就更容易定位了),这一步相对第一步花费多一点的时间,如果是应用代码分析到这里已经差不多结束了,确定了panic引入点就可以修改代码进行回归测试了,但对于kernel来说要复杂的多。
KERNEL: /usr/lib/debug/usr/lib/modules/3.10.0-514.el7.x86_64/vmlinux DUMPFILE: vmcore [PARTIAL DUMP] CPUS: 2 DATE: Fri Jul 26 14:52:41 2019 UPTIME: 90 days, 16:58:02 LOAD AVERAGE: 0.25, 0.28, 0.31 TASKS: 153 NODENAME: ustack-taicangct55.ustack.qeeyou.com RELEASE: 3.10.0-...
debugging is on, and kernel space */#define PDEBUG(fmt,args...) printk(KERN_DEBUG "scull: " fmt, ## args)#else/* This one for user space */#define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)#endif#else#define PDEBUG(fmt, args...) /* not debugging: nothing */#...
编译时需要选择compile with debug info选项 执行gdb vmlinux.elf,进入gdb终端, 1)执行list *0x8029f72c或者list *(dwc_otg_pcd_ep_queue+0xec),如下,直接可以看出哪个文件哪一行了。 4、其他 这里有一篇文章介绍ARM系统上kernel panic的小例子 http://www.opensourceforu.com/2011/01/understanding-...
#ifdef _ _KERNEL_ _ /* This one if debugging is on, and kernel space */ #define PDEBUG(fmt,args...) printk(KERN_DEBUG "scull: " fmt, ## args) #else /* This one for user space */ #define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args) ...
panic后内核的默认行 为是死在那里,目的是给开发人员一个连上去debug的机会。但对于大多数应用层开发人员来说没啥用,倒是希望它赶紧重启。为了让内核panic后重启,可以修改文件/proc/sys/kernel/panic,里面表示的是panic多少秒后系统将重启,这个文件的默认值是0,表示永远不重启。
Presently I'm using >>addr2line -e vmlinux_with_debug_info80a00000<< to decode kernel panic message. But it only shows the kernel source when the panic occur(Where program counter stopped) . As an example from the following kernel log when I decode [80a00000] it only...