https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89959

            Bug ID: 89959
           Summary: gcov: "--long-file-names" is ignored when used in
                    combination with "--hash-filenames"
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christian.morales.vega at gmail dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Fedora 29, gcc-8.3.1-2.fc29.x86_64 (no related patch AFAICT ->
https://src.fedoraproject.org/rpms/gcc/tree/a050417cd5cb9b3269bcce2e324fab8d081e4355)


a) Running "gcov -r -s <source_dir> -o <object directory> <.gcda file>" I get
files like

<source file>.gcov


b) Running "gcov -p -r -s <source_dir> -o <object directory> <.gcda file>" I
get files like

<relative path to the source file>.gcov


c) Running "gcov -x -r -s <source_dir> -o <object directory> <.gcda file>" I
get files like

<source file>##<hash>.gcov


d) Running "gcov -p -l -r -s <source_dir> -o <object directory> <.gcda file>" I
get files like

<full path to the .gcda file>##<relative path to the source file>.gcov


e) Running "gcov -x -l -r -s <source_dir> -o <object directory> <.gcda file>" I
get files like

<source file>##<hash>.gcov



Notice that 'c' and 'e' are identical, "-l" in 'e' has had no effect. I would
have expected 'e' to be

<full path to the .gcda file>##<source file>##<hash>.gcov



Also, notice that the documentation for --hash-filenames starts by saying: "By
default, gcov uses the full pathname of the source files to create an output
filename." That's incorrect, by default it uses only the filename.
The documentation would be more clear if it would describe "--hash-filenames"
as an alternative to "--preserve-paths". Interestingly, when "-x" is being used
"-l" is ignored... but "-p" isn't. So it's possible to use "-p" and "-x"
simultaneously, which makes no sense. You are using "-x" to avoid long
filenames, but by using it together with "-p" you are just making the filename
*longer*.




FWIW the reason I'm using "-l" is not because I "want to see the individual
contributions". My problem is that I'm using CDash (www.cdash.org), which runs
gcov once per .gcda instead of running it a single time taking all the .gcda
files as input (they should fix this
https://gitlab.kitware.com/cmake/cmake/issues/19124#note_554321, but there may
be others).
By running gcov once per .gcda file the .gcov file for a header created by one
invocation can get overwritten by the next .gcov invocation. Using "-l" works
around this issue.
Again, the problem is that CDash is using gcov incorrectly and they should fix
the issue. But since I suspect they are not the only ones... maybe it makes
sense to have another option to use the hash of the .gcda file? Meaning,
running "gcov -x --hash-long-file-names -r -s <source_dir> -o <object
directory> <.gcda file>" I would get files like

<gcda_path_hash>##<source file>##<source_file_path_hash>.gcov

Which would let me, using short file names, call gcov once per .gcda file
without the risk of overwriting .gcov files.

Reply via email to