This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] GCOV: print {start,end}_column in JSON file and gcov-dump tool.


Hi.

This is one more enhancement of JSON intermediate format export. Apart from
that, I also improved documentation of the format and gcov-dump output.

Patch survives gcov.exp regression tests. I'm going to install the patch
after some time.

Thanks,
Martin

gcc/ChangeLog:

2019-03-11  Martin Liska  <mliska@suse.cz>

	* coverage.c (coverage_begin_function): Stream also
	end_column.
	* doc/gcov.texi: Document 2 new fields in JSON file.  Improve
	documentation about function declaration location.
	* gcov-dump.c (tag_function): Print whole range
	of function declaration.
	* gcov.c (struct function_info): Add end_column field.
	(function_info::function_info): Initialize it.
	(output_json_intermediate_file): Output {start,end}_column
	fields.
	(read_graph_file): Read end_column.
---
 gcc/coverage.c    |  2 ++
 gcc/doc/gcov.texi | 15 ++++++++++++++-
 gcc/gcov-dump.c   |  4 +++-
 gcc/gcov.c        | 10 +++++++++-
 4 files changed, 28 insertions(+), 3 deletions(-)


diff --git a/gcc/coverage.c b/gcc/coverage.c
index a34c5da49bf..1ffefd5f482 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -652,8 +652,10 @@ coverage_begin_function (unsigned lineno_checksum, unsigned cfg_checksum)
 
   /* Function can start in a single file and end in another one.  */
   int end_line = endloc.file == xloc.file ? endloc.line : xloc.line;
+  int end_column = endloc.file == xloc.file ? endloc.column: xloc.column;
   gcc_assert (xloc.line <= end_line);
   gcov_write_unsigned (end_line);
+  gcov_write_unsigned (end_column);
   gcov_write_length (offset);
 
   return !gcov_is_error ();
diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index 0960e4acb26..ecad5d11847 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -236,9 +236,11 @@ Each @var{function} has the following form:
   "blocks": @var{blocks},
   "blocks_executed": @var{blocks_executed},
   "demangled_name": "@var{demangled_name},
+  "end_column": @var{end_column},
   "end_line": @var{end_line},
   "execution_count": @var{execution_count},
   "name": @var{name},
+  "start_column": @var{start_column}
   "start_line": @var{start_line}
 @}
 @end smallexample
@@ -255,6 +257,9 @@ Fields of the @var{function} element have following semantics:
 @item
 @var{demangled_name}: demangled name of the function
 
+@item
+@var{end_column}: column in the source file where the function ends
+
 @item
 @var{end_line}: line in the source file where the function ends
 
@@ -264,10 +269,18 @@ Fields of the @var{function} element have following semantics:
 @item
 @var{name}: name of the function
 
+@item
+@var{start_column}: column in the source file where the function begins
+
 @item
 @var{start_line}: line in the source file where the function begins
 @end itemize
 
+Note that line numbers and column numbers number from 1.  In the current
+implementation, @var{start_line} and @var{start_column} do not include
+any template parameters and the leading return type but that
+this is likely to be fixed in the future.
+
 Each @var{line} has the following form:
 
 @smallexample
@@ -293,11 +306,11 @@ Fields of the @var{line} element have following semantics:
 @item
 @var{unexecuted_block}: flag whether the line contains an unexecuted block
 (not all statements on the line are executed)
-@end itemize
 
 @item
 @var{function_name}: a name of a function this @var{line} belongs to
 (for a line with an inlined statements can be not set)
+@end itemize
 
 Each @var{branch} has the following form:
 
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index 72d94d95165..67b1e88a5bc 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -315,7 +315,9 @@ tag_function (const char *filename ATTRIBUTE_UNUSED,
 	  unsigned line_start = gcov_read_unsigned ();
 	  unsigned column_start = gcov_read_unsigned ();
 	  unsigned line_end = gcov_read_unsigned ();
-	  printf (":%u:%u:%u", line_start, column_start, line_end);
+	  unsigned column_end = gcov_read_unsigned ();
+	  printf (":%u:%u-%u:%u", line_start, column_start,
+		  line_end, column_end);
 	  if (artificial)
 	    printf (", artificial");
 	}
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 37e787a1823..1d576552a45 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -283,6 +283,9 @@ struct function_info
   /* Last line number.  */
   unsigned end_line;
 
+  /* Last line column.  */
+  unsigned end_column;
+
   /* Index of source file where the function is defined.  */
   unsigned src;
 
@@ -631,7 +634,8 @@ function_info::function_info (): m_name (NULL), m_demangled_name (NULL),
   ident (0), lineno_checksum (0), cfg_checksum (0), has_catch (0),
   artificial (0), is_group (0),
   blocks (), blocks_executed (0), counts (),
-  start_line (0), start_column (), end_line (0), src (0), lines (), next (NULL)
+  start_line (0), start_column (0), end_line (0), end_column (0),
+  src (0), lines (), next (NULL)
 {
 }
 
@@ -1131,7 +1135,9 @@ output_json_intermediate_file (json::array *json_files, source_info *src)
       function->set ("demangled_name",
 		     new json::string ((*it)->get_demangled_name ()));
       function->set ("start_line", new json::number ((*it)->start_line));
+      function->set ("start_column", new json::number ((*it)->start_column));
       function->set ("end_line", new json::number ((*it)->end_line));
+      function->set ("end_column", new json::number ((*it)->end_column));
       function->set ("blocks",
 		     new json::number ((*it)->get_block_count ()));
       function->set ("blocks_executed",
@@ -1726,6 +1732,7 @@ read_graph_file (void)
 	  unsigned start_line = gcov_read_unsigned ();
 	  unsigned start_column = gcov_read_unsigned ();
 	  unsigned end_line = gcov_read_unsigned ();
+	  unsigned end_column = gcov_read_unsigned ();
 
 	  fn = new function_info ();
 	  functions.push_back (fn);
@@ -1739,6 +1746,7 @@ read_graph_file (void)
 	  fn->start_line = start_line;
 	  fn->start_column = start_column;
 	  fn->end_line = end_line;
+	  fn->end_column = end_column;
 	  fn->artificial = artificial;
 
 	  current_tag = tag;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]