inux kernel 里面打印堆栈的函数

来源:互联网 发布:java继承的定义 编辑:程序博客网 时间:2024/04/28 06:02

inux kernel 里面打印堆栈的函数


调用dump_stack()就会打印当前cpu的堆栈的调用函数了。参考内核源代码
arch/x86_64/kernel/traps.c


/*
* The architecture-independent dump_stack generator
*/
void dump_stack(void)
{
        unsigned long dummy;
        show_trace(&dummy);
}



        /*
         * When in-kernel, we also print out the stack and code at the
         * time of the fault..
         */
        if (in_kernel) {

                printk("Stack: ");
                show_stack(NULL, (unsigned long*)rsp);
还有一种是可以打出函数调用的过程:

print_symbol("caller is %s/n", (long)__builtin_return_address(0));
原创粉丝点击