dump_stack是用来回溯内核运行的信息的,打印内核信息堆栈段;
dump_stack原型:
void dump_stack(void);
1、使用这个功能时需要将内核配置勾选上;
make menuconfig -> kernel hacking--> kernel debug
2、在函数中使用:
1 #include <linux/module.h> 2 #include <linux/init.h> 3 #include <linux/kprobes.h> 4 #include <asm/traps.h> 5 6 MODULE_LICENSE("Dual BSD/GPL"); 7 8 static int __init hello_init(void) 9 { 10 printk(KERN_ALERT "dump_stack start\n"); 11 dump_stack(); 12 printk(KERN_ALERT "dump_stack over\n"); 13 return 0; 14 } 15 static void __exit hello_exit(void) 16 { 17 printk(KERN_ALERT "test module\n"); 18 } 19 20 module_init(hello_init); 21 module_exit(hello_exit);