0

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.

pearleye
  • 29
  • 4
  • 1
    possible 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 Answers2

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.

Community
  • 1
  • 1
Orace
  • 7,822
  • 30
  • 45
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".

DevSolar
  • 67,862
  • 21
  • 134
  • 209
Rock Deng
  • 21
  • 2