Linux Device Driver example for dump_stack() to print the stack trace of module loading
One of the useful options in debugging is to print the call trace/stack trace. Linux kernel provides a function to print the stack trace: dump_stack().
Calling dump_stack() function will print the stack trace at that point.
Code:
Output:
Calling dump_stack() function will print the stack trace at that point.
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/module.h> | |
#include <linux/kernel.h> | |
static int myinit(void) | |
{ | |
pr_info("dump_stack myinit\n"); | |
dump_stack(); | |
pr_info("dump_stack after\n"); | |
return 0; | |
} | |
static void myexit(void) | |
{ | |
pr_info("panic myexit\n"); | |
} | |
module_init(myinit) | |
module_exit(myexit) | |
MODULE_LICENSE("GPL"); |
Comments
Post a Comment