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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Cristian Morales Vega from comment #3)
> I have just took a look inside one of the intermediate format .gcov files
> and didn't see any "current_working_directory". There is a full path "file"
> variable though.

It's there since r266521.

> 
> Not sure if that's what you mean. In any case anything inside the .gcov
> files would not solve my issue. My problem is that all the .gcov files are
> being created in the same directory and the .gcov files themselves get
> overwritten.
> 
> So I have
> 
> ./CMakeFiles/<cmake_target_name>.dir/src/error.cpp.o
> ./CMakeFiles/<cmake_target_name>.dir/src/error.cpp.gcda
> ./CMakeFiles/<cmake_target_name>.dir/src/error.cpp.gcno
> ./test/CMakeFiles/catch_tests.dir/error.cpp.o
> ./test/CMakeFiles/catch_tests.dir/error.cpp.gcda
> ./test/CMakeFiles/catch_tests.dir/error.cpp.gcno
> 
> 
> And a single "error.cpp.gcda.gcov" file since cmake has run
> 
> /usr/bin/gcov -x -i -o <build_dir>/CMakeFiles/<cmake_target_name>.dir/src
> <build_dir>/CMakeFiles/cmake_target_name.dir/src/error.cpp.gcda
> 
> and
> 
> /usr/bin/gcov -x -i -o <build_dir>/test/CMakeFiles/catch_tests.dir
> <build_dir>/test/CMakeFiles/catch_tests.dir/error.cpp.gcda
> 
> from the same directory, put all the files in a flat tarball and sent it to
> a CDash server. So I need the file names written to my hard drive to be
> different (i.e. -x to have effect).

My suggestion would be adding 'data_file' into a JSON report:

gcov -ti -l   -s /tmp/auto -o /tmp/ main.gcda  | python -m json.tool
/tmp/main.gcda:stamp mismatch with notes file
{
    "current_working_directory": "/tmp",
    "data_file": "main.gcda",
    "files": [
        {
            "file": "auto/main.c",
            "functions": [
                {
                    "blocks": 8,
                    "blocks_executed": 0,
                    "demangled_name": "main",
                    "end_column": 1,
                    "end_line": 21,
                    "execution_count": 0,
                    "name": "main",
                    "start_column": 5,
                    "start_line": 6
                }
            ],
            "lines": [
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 6,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 8,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 10,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 12,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 15,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 17,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 18,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "main",
                    "line_number": 20,
                    "unexecuted_block": true
                }
            ]
        },
        {
            "file": "auto/foo.h",
            "functions": [
                {
                    "blocks": 2,
                    "blocks_executed": 0,
                    "demangled_name": "foo",
                    "end_column": 1,
                    "end_line": 4,
                    "execution_count": 0,
                    "name": "foo",
                    "start_column": 5,
                    "start_line": 1
                }
            ],
            "lines": [
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "foo",
                    "line_number": 1,
                    "unexecuted_block": true
                },
                {
                    "branches": [],
                    "count": 0,
                    "function_name": "foo",
                    "line_number": 3,
                    "unexecuted_block": true
                }
            ]
        }
    ],
    "format_version": "1",
    "gcc_version": "9.0.1 20190405 (experimental)"
}

Which should help you with uniq mapping now.

Patch candidate:

diff --git a/gcc/gcov.c b/gcc/gcov.c
index 1d576552a45..1fc37a07c34 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -1421,6 +1421,7 @@ generate_results (const char *file_name)

   if (bbg_cwd != NULL)
     root->set ("current_working_directory", new json::string (bbg_cwd));
+  root->set ("data_file", new json::string (file_name));

   json::array *json_files = new json::array ();
   root->set ("files", json_files);

Reply via email to