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

            Bug ID: 105063
           Summary: [GCOV] Ability to map .gcda paths
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vit9696 at protonmail dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

When compiling code with `-fprofile-arcs` gcc encodes .gcda file path relative
to object file. In some cases this is infeasible, as the compilation directory
may have extra long prefix, which is not practical to store on embedded
targets.

To avoid this issue we would like to replace this prefix with a custom value.
Currently there are 3 options in GCC, which allow one to do coverage file
mapping:

* -fprofile-dir
* -fprofile-prefix-map
* -fprofile-prefix-path

We assumed that at least one of them should do what we need, yet it is not
true:

* Normal gives /app/output.gcda (https://godbolt.org/z/jaj6vhnd5)
* -fprofile-dir=/test gives /test//app/output.gcda
(https://godbolt.org/z/8h7brYE84)
* -fprofile-prefix-map=/app=/test gives /app/output.gcda
(https://godbolt.org/z/c9TxeMPzM)
* -fprofile-prefix-path=/test -fprofile-generate=/app give
/app//app/output.gcda (https://godbolt.org/z/bh7esxPcK)

I see two routes to solve this issue:

1. One of the existing options is fixed to do this. E.g.
-fprofile-prefix-map=/app=/test could result in /test/output.gcda.
2. A new option is introduced to map gcda files.

The relevant code is in coverage.cc:coverage_init
(https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/coverage.cc;h=8ece5db680e614f8225d9e8407dd89bd27020b4d;hb=refs/heads/master#l1253).

Reply via email to