简要说明:使用 dump_stack() 打印内核里的堆栈信息。
Purpose
dump_stack()
function which will give you a call trace. This function is not enabled in the default kernel and must be enabled. This article will cover how to enable and use the dump_stack()
Enabling in Kernel Config
dump_stack()
function in the kernel config the following options must be set. You can use make menuconfig or make xconfig to do this.
- Kernel hacking -> Kernel debugging
- Kernel hacking -> Verbose kernel error messages
dump_stack()
You need to rebuild your Linux kernel image after enabling these options.
Using dump_stack()
dump_stack()
function is as easy as calling dump_stack() wherever you wish to print out the stack. This will cause a stack trace to be printed at that point.
Conclusion
This is a useful way to print out the stack while leaving the kernel unharmed.