title: Trouble running GCOV with multiple source files of the same name
body: <p>According to <a href="https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html#Invoking-Gcov" rel="nofollow">GCC online docs</a>,  gcov should be run with the current directory the same as that when you invoked the compiler. Let’s say I have the following source files layout:</p>
  
  <pre><code>-root
     -source
        -dir1
           -file.cpp
        -dir2
           -file.cpp
  </code></pre>
  
  <p>I run gcc in directory “root” with according flags (namely -fprofile-arcs, -ftest-coverage, and –lgcov). Then I run the generated program. By default, .gcno, .gcda files are generated beside object files, which looks like:</p>
  
  <pre><code>-root
     -source
        -dir1
           -file.cpp
           -file.o
           -file.gcno
           -file.gcda
        -dir2
           -file.cpp
           -file.o
           -file.gcno
           -file.gcda
  </code></pre>
  
  <p>It’s time to run gcov. The above online docs requires me to run gcov at the same directory “root” (where I run gcc to build the program). And .gcov coverage files will be generated at the current directory, which is also “root”. Since there are two files with the same name (both “file.cpp”), there will only be one file.cpp.gcov generated. The other is overwritten.</p>
  
  <p>How gcov solves this problem? Does it support multiple files with the same name? </p>
  
  <p>One workaround is to use <code>–p</code> option <code>(--preserve-paths</code>). But since it’ll create a super long file name in my case, I’d rather not to use it as a general solution. </p>
  
  <p>I’d be glad to know if someone can share some backgrounds of why gcov has to be run at the same directory where gcc is invoked? Or maybe gcov can provide an option to define where those source files are located, to be more flexible?</p>