Commit c74bd3fb by Martin Liska Committed by Martin Liska

Print working directory to gcov files (PR gcov-profile/84846).

2018-05-18  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/84846
	* coverage.c (coverage_init): Write PWD to .gcno file.
	* doc/gcov.texi: Document how working directory is printed.
	* gcov-dump.c (dump_gcov_file): Print PWD.
	* gcov.c (output_intermediate_file): Likewise.
	(read_graph_file): Read PWD string.
	(output_lines): Print PWD.

From-SVN: r260359
parent bec3ee81
2018-05-18 Martin Liska <mliska@suse.cz>
PR gcov-profile/84846
* coverage.c (coverage_init): Write PWD to .gcno file.
* doc/gcov.texi: Document how working directory is printed.
* gcov-dump.c (dump_gcov_file): Print PWD.
* gcov.c (output_intermediate_file): Likewise.
(read_graph_file): Read PWD string.
(output_lines): Print PWD.
2018-05-18 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> 2018-05-18 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR middle-end/85817 PR middle-end/85817
......
...@@ -1269,6 +1269,7 @@ coverage_init (const char *filename) ...@@ -1269,6 +1269,7 @@ coverage_init (const char *filename)
gcov_write_unsigned (GCOV_NOTE_MAGIC); gcov_write_unsigned (GCOV_NOTE_MAGIC);
gcov_write_unsigned (GCOV_VERSION); gcov_write_unsigned (GCOV_VERSION);
gcov_write_unsigned (bbg_file_stamp); gcov_write_unsigned (bbg_file_stamp);
gcov_write_string (getpwd ());
/* Do not support has_unexecuted_blocks for Ada. */ /* Do not support has_unexecuted_blocks for Ada. */
gcov_write_unsigned (strcmp (lang_hooks.name, "GNU Ada") != 0); gcov_write_unsigned (strcmp (lang_hooks.name, "GNU Ada") != 0);
......
...@@ -189,6 +189,7 @@ one entry per line ...@@ -189,6 +189,7 @@ one entry per line
@smallexample @smallexample
version:@var{gcc_version} version:@var{gcc_version}
cwd:@var{working_directory}
file:@var{source_file_name} file:@var{source_file_name}
function:@var{start_line_number},@var{end_line_number},@var{execution_count},@var{function_name} function:@var{start_line_number},@var{end_line_number},@var{execution_count},@var{function_name}
lcount:@var{line number},@var{execution_count},@var{has_unexecuted_block} lcount:@var{line number},@var{execution_count},@var{has_unexecuted_block}
...@@ -210,6 +211,7 @@ Here is a sample when @option{-i} is used in conjunction with @option{-b} option ...@@ -210,6 +211,7 @@ Here is a sample when @option{-i} is used in conjunction with @option{-b} option
@smallexample @smallexample
version: 8.1.0 20180103 version: 8.1.0 20180103
cwd:/home/gcc/testcase
file:tmp.cpp file:tmp.cpp
function:7,7,0,_ZN3FooIcEC2Ev function:7,7,0,_ZN3FooIcEC2Ev
function:7,7,1,_ZN3FooIiEC2Ev function:7,7,1,_ZN3FooIiEC2Ev
...@@ -441,6 +443,7 @@ Here is a sample: ...@@ -441,6 +443,7 @@ Here is a sample:
@smallexample @smallexample
-: 0:Source:tmp.cpp -: 0:Source:tmp.cpp
-: 0:Working directory:/home/gcc/testcase
-: 0:Graph:tmp.gcno -: 0:Graph:tmp.gcno
-: 0:Data:tmp.gcda -: 0:Data:tmp.gcda
-: 0:Runs:1 -: 0:Runs:1
...@@ -508,6 +511,7 @@ counts, and the output looks like this: ...@@ -508,6 +511,7 @@ counts, and the output looks like this:
@smallexample @smallexample
-: 0:Source:tmp.cpp -: 0:Source:tmp.cpp
-: 0:Working directory:/home/gcc/testcase
-: 0:Graph:tmp.gcno -: 0:Graph:tmp.gcno
-: 0:Data:tmp.gcda -: 0:Data:tmp.gcda
-: 0:Runs:1 -: 0:Runs:1
...@@ -596,6 +600,7 @@ When you use the @option{-b} option, your output looks like this: ...@@ -596,6 +600,7 @@ When you use the @option{-b} option, your output looks like this:
@smallexample @smallexample
-: 0:Source:tmp.cpp -: 0:Source:tmp.cpp
-: 0:Working directory:/home/gcc/testcase
-: 0:Graph:tmp.gcno -: 0:Graph:tmp.gcno
-: 0:Data:tmp.gcda -: 0:Data:tmp.gcda
-: 0:Runs:1 -: 0:Runs:1
......
...@@ -220,6 +220,8 @@ dump_gcov_file (const char *filename) ...@@ -220,6 +220,8 @@ dump_gcov_file (const char *filename)
if (!is_data_type) if (!is_data_type)
{ {
printf ("%s:cwd: %s\n", filename, gcov_read_string ());
/* Support for unexecuted basic blocks. */ /* Support for unexecuted basic blocks. */
unsigned support_unexecuted_blocks = gcov_read_unsigned (); unsigned support_unexecuted_blocks = gcov_read_unsigned ();
if (!support_unexecuted_blocks) if (!support_unexecuted_blocks)
......
...@@ -432,6 +432,9 @@ static unsigned bbg_stamp; ...@@ -432,6 +432,9 @@ static unsigned bbg_stamp;
/* Supports has_unexecuted_blocks functionality. */ /* Supports has_unexecuted_blocks functionality. */
static unsigned bbg_supports_has_unexecuted_blocks; static unsigned bbg_supports_has_unexecuted_blocks;
/* Working directory in which a TU was compiled. */
static const char *bbg_cwd;
/* Name and file pointer of the input file for the count data (gcda). */ /* Name and file pointer of the input file for the count data (gcda). */
static char *da_file_name; static char *da_file_name;
...@@ -1037,6 +1040,7 @@ output_intermediate_file (FILE *gcov_file, source_info *src) ...@@ -1037,6 +1040,7 @@ output_intermediate_file (FILE *gcov_file, source_info *src)
{ {
fprintf (gcov_file, "version:%s\n", version_string); fprintf (gcov_file, "version:%s\n", version_string);
fprintf (gcov_file, "file:%s\n", src->name); /* source file name */ fprintf (gcov_file, "file:%s\n", src->name); /* source file name */
fprintf (gcov_file, "cwd:%s\n", bbg_cwd);
std::sort (src->functions.begin (), src->functions.end (), std::sort (src->functions.begin (), src->functions.end (),
function_line_start_cmp ()); function_line_start_cmp ());
...@@ -1550,6 +1554,7 @@ read_graph_file (void) ...@@ -1550,6 +1554,7 @@ read_graph_file (void)
bbg_file_name, v, e); bbg_file_name, v, e);
} }
bbg_stamp = gcov_read_unsigned (); bbg_stamp = gcov_read_unsigned ();
bbg_cwd = xstrdup (gcov_read_string ());
bbg_supports_has_unexecuted_blocks = gcov_read_unsigned (); bbg_supports_has_unexecuted_blocks = gcov_read_unsigned ();
function_info *fn = NULL; function_info *fn = NULL;
...@@ -2918,6 +2923,8 @@ output_lines (FILE *gcov_file, const source_info *src) ...@@ -2918,6 +2923,8 @@ output_lines (FILE *gcov_file, const source_info *src)
const char *retval; const char *retval;
fprintf (gcov_file, DEFAULT_LINE_START "Source:%s\n", src->coverage.name); fprintf (gcov_file, DEFAULT_LINE_START "Source:%s\n", src->coverage.name);
fprintf (gcov_file, DEFAULT_LINE_START "Working directory:%s\n",
bbg_cwd);
if (!multiple_files) if (!multiple_files)
{ {
fprintf (gcov_file, DEFAULT_LINE_START "Graph:%s\n", bbg_file_name); fprintf (gcov_file, DEFAULT_LINE_START "Graph:%s\n", bbg_file_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment