转 https://blog.csdn.net/iefswang/article/details/25225973
在内核调试时,我们需要跟踪函数调用过程,在这时,我们经常会碰到函数指针的情况,那么,我们怎么跟踪到具体的函数处呢?如何打印出函数指针的函数名?
这里有两种方法。先说比较笨重的方法:
http://stackoverflow.com/questions/351134/how-to-get-functions-name-from-functions-pointer-in-c// Define it like this
typedef struct
{
char *dec_text;
#ifdef _DEBUG_FUNC
void (*action)(char);
#endif
} func_Struct;
// Initialize it like this
func_Struct func[3]= {
#ifdef _DEBUG_FUNC
{"my_Set(char input)",&my_Set}};
{"my_Get(char input)",&my_Get}};
{"my_Clr(char input)",&my_Clr}};
#else
{&my_Set}};
{&my_Get}};
{&my_Clr}};
#endif
// And finally you can use it like this