0

Is there a way to generate a list of C++ methods being called for an executable? I have a dynamic library and would like to see how many of the methods are being called from the executable. I can see that the C++ methods are being exported through dumpbin or readelf. However, when I run these tools on an executable that is calling the dynamic library, only the C methods and one C++ method is being listed. Is there something special with C++ imports?

David J
  • 1
  • 1
  • 1
    Just about any decent (or even crappy) profiler should be able to tell you. If you want a list of what's potentially called, the import table of the executable should tell you (at least right now, it sounds like you're looking at exports, not imports). – Jerry Coffin Jan 04 '13 at 20:56
  • Looks like you're after a code coverage test or some sort of profiling. Tools exist that do that. – Kerrek SB Jan 04 '13 at 21:02
  • Yes I am trying to do a code coverage test of a class library. At this point, I am not so interested of the code coverage at run time so I wanted to see if I could do something quick with dumpbin or readelf, but it doesn't seem like it is possible with these tools? – David J Jan 04 '13 at 21:07

2 Answers2

1

You can build your library and program with profiling, then you can get a list of all functions called (and how much time is spent in each function).

You can also add manual trace logging, meaning you add a call that writes to the console at the start and end of each function.

The profiling is probably the simplest and easiest way to go. Look here for the option needed when building, and e.g. here for a manual of the program gprof needed for extracting the information.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
0

You could use profiling techniques, e.g. compile your entire program with the -pg flag passed to gcc (and at link time), then use gprof. (There is also oprofile).

You could use ltrace to understand the library calls done.

You might be interested by this article about reverse engineering tools.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547