We can do something like
gcc --coverage some.c
and then get the function information after running it with gcov.
This works fine with "plain C", but when executing generated code you're
out of luck.
Most easy example: bison
it generates relevant #line directives to "switch" between parser.y and
parser.c.
Inspecting parser.c shows many functions "commonly not interesting"
(like bison generated state functions), so these generated files are
often ignored / excluded.
Inspecting parser.y shows all the functions that are defined "directly"
in the parser.y file (within the %{} block), but it doesn't show any of
the most interesting terminals.
The idea is to insert something like
{
#function push
#function my-important-terminal
code here
#function pop
}
and then have gcov consider this part "as if it has been a function".
For a similar case, related to profiling, I've only found the option to
make the C code non-portable by inserting nested functions here (I
haven't checked yet, but guess gcov and lcov would handle those similar
to gdb/perf/...); but maybe there is something "general" that can be
used instead.
Any insights / ideas?
Thanks a lot,
Simon