Linux内核调试理清函数调用

来源:互联网 发布:slam算法工程师 薪资 编辑:程序博客网 时间:2024/06/06 19:50

最近在调试内核中断代码时发现一个很好用的宏,在linu/kernel.h:

#define _RET_IP_ (unsigned long)__builtin_return_address(0)
#define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })

调用过程:

printk("memblock_reserve: [%#016llx-%#016llx] %pF\n",
    (unsigned long long)base,
    (unsigned long long)base + size,
    (void *)_RET_IP_);

这样就可以打印出调用函数名称

0 0