I have complete project in C, which can be built with gcc or Visual Studio. There are no calls to external libraries.
I would like to know how many functions there is in that project.
There are no unused functions in source code, and the project comes with tests which run it with different params, so for a dynamic approach (e.g. run-time call tree) I would need to accumulate results after each test.
Are there any tools that can perform static or dynamic analysis?
With gcc
:
$ nm elf_file | grep "T " | grep -v " _" | wc -l
Note that gcc
can inline some functions even with optimizations disabled, so you should compile with:
-O0 -fno-builtin -fno-inline-functions-called-once
(-finline-functions-called-once
is enabled by default even in -O0
)