BHS*_*BHS 20 kernel linux-device-driver linux-kernel embedded-linux kernel-mode
有没有办法在linux内核中获取函数调用?我知道__ func __返回正在执行的函数名.我正在寻找名为" __ func __ "的函数
mpe*_*mpe 40
你可以得到来电者__builtin_return_address(0).
呼叫者的呼叫者是__builtin_return_address(1)等等.
它是GCC扩展,在gcc手册中有记录:http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html
编辑:我应该指出,这可以获得调用者的地址.如果您需要功能名称,可以使用%pS,例如:
printk("Caller is %pS\n", __builtin_return_address(0));
Run Code Online (Sandbox Code Playgroud)
如果您不想打印,可以使用kallsyms_lookup()等.