public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Is it possible to insert own "function points" via define in code (similar to #line), especially for --coverage?
@ 2023-01-05 15:05 Simon Sobisch
  0 siblings, 0 replies; only message in thread
From: Simon Sobisch @ 2023-01-05 15:05 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-05 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 15:05 Is it possible to insert own "function points" via define in code (similar to #line), especially for --coverage? Simon Sobisch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).