SecStone
SecStone

Reputation: 1753

GCC: Print used functions during program/library run

Is it possible to print a list of all functions used during a program run? The program and the library used by the program is compiled with GCC without optimization.

The reason for this list is that I'd like to optimize a library which has a lot of unused functions (the library is really huge and I need only a few functions).

Upvotes: 0

Views: 175

Answers (3)

osgx
osgx

Reputation: 94165

gcov (compile with gcc -ftest-coverage -fprofile-arcs) will say this too.

Upvotes: 0

dimba
dimba

Reputation: 27571

If its dynamic library (*.so) try ltrace. For example to see how ls uses libc:

ltrace --library /lib64/libc.so.6 ls

gprof can be an option too.

Upvotes: 1

lafdez
lafdez

Reputation: 68

If you can compile them again you could use a profiler such as gprof or valgrind (with its callgrind tool). I think you wouldn't need a new compiling if you use valgrind.

Upvotes: 3

Related Questions