Assume there is a function pointer (sock->ops->ioctl()) in kernel space. Now how do I print the name of the function stored in this pointer using printk or any other method you know.
Asked
Active
Viewed 2,115 times
0
-
1possible duplicate of [How to get function's name from function's pointer in C?](http://stackoverflow.com/questions/351134/how-to-get-functions-name-from-functions-pointer-in-c) – Orace Apr 02 '15 at 10:24
2 Answers
4
As it is says here:
In the Linux kernel, you can use directly "%pF" format of printk !
void *func = &foo; printk("func: %pF at address: %p\n", func, func);
Also as you know that printk
is involved, you may have used some tools to find documentation about it.
-
-
@user3486405 Nope, see [this](https://www.kernel.org/doc/Documentation/printk-formats.txt). It prints both the name and the address. – Sam Protsenko Nov 24 '16 at 21:52
2
Base on Orace's answer, you might try %pS
instead of %pF
. I've tested that %pF
is not working in 5.10.x version of kernel, but %pS
works. Furthermore, I found a related comment in vsprintf.c
-
"
%pf
and%pF
were obsoleted and later removed in favor of%ps
and%pS
. Be careful when re-using these specifiers".