I am debugging an open source library that has a structure that gets initialized开发者_C百科 on load. One of the struct's members is a function pointer. What is the quickest way to figure to which function it is pointing to? For example, if I print out the value of the function pointer, is there some tool that I can use to find the name of the function? I am doing this on an embedded Linux system and GDB is not available (yet).
The linker can output a map file. Assuming your functions don't move around, you can look up the address in there. The option to produce the map file can vary; on my Mac it's -map
, the Linux man page says it's -Map
.
As a bit of an editorial aside, if you don't have a working source-level debugging solution, the first thing you should do is get one. Stop all other work until you have a suitable infrastructure for development. You might have to fight to convince your management that it's important, but hopefully you can make them understand.
I think you will find the addr2line command useful.
精彩评论