kernel 调试之——dump_stack

#include <linux/kernel.h>
#include <linux/module.h>

void func2();
void func3();

void func1()
{
printk("<0>Hello, my name is func1 !\n");
func2();
}
void func2()
{
printk("<0>Hello, my name is func2 !\n");
func3();
}
void func3()
{
printk("<0>Hello, my name is func3 !\n");
dump_stack();

}
static int __init my_module_init(void)
{
    printk("<0>Hello, module is installed by 10175298!\n");
    return 0;
}
static void __exit my__module_cleanup(void)
{
    printk("<0>Good-bye, module was removed!\n");
}
module_init(my_module_init);
module_exit(my__module_cleanup);
MODULE_LICENSE("GPL");



#cat /proc/kmsg 


<0>Hello, module is installed by 10175298!
<0>Hello, my name is func1 !
<0>Hello, my name is func2 !
<0>Hello, my name is func3 !
<4>Pid: 22707, comm: insmod Not tainted 2.6.27.5-117.fc10.i686 #1
<4> [<c06a5857>] ? printk+0xf/0x18
<4> [<e0a0b012>] func3+0x12/0x15 [hello_module]
<4> [<e0a0b027>] func2+0x12/0x15 [hello_module]
<4> [<e0a0b03c>] func1+0x12/0x16 [hello_module]
<4> [<e0855012>] my_module_init+0x12/0x16 [hello_module]
<4> [<c0401125>] _stext+0x3d/0x115
<4> [<e0855000>] ? my_module_init+0x0/0x16 [hello_module]
<4> [<c044bf7d>] sys_init_module+0x87/0x178
<4> [<c0403c76>] syscall_call+0x7/0xb
<4> [<c06a007b>] ? init_intel_cacheinfo+0x0/0x421
<4> =======================


猜你喜欢

转载自blog.csdn.net/yangchaofeng001/article/details/42687399