This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] GCOV: do not support unexecuted blocks in Ada
- From: Martin Liška <mliska at suse dot cz>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Nov 2017 11:49:03 +0100
- Subject: [PATCH] GCOV: do not support unexecuted blocks in Ada
- Authentication-results: sourceware.org; auth=none
- References: <8628973.M8QiBYR5HD@polaris> <05c31541-6d1e-f42c-9b9d-5869c3c4ebd5@suse.cz> <1579188.kzOUyVlQzK@polaris> <086ea240-a699-2b68-3a5d-2c62cf45ead3@suse.cz>
Hello.
This is patch that does not print unexecuted blocks for Ada language.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
And Eric reported that he tested that.
Ready to be installed?
Martin
>From 127e6e644f0a8014e429f51bee607ad9372180d0 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 6 Nov 2017 10:49:16 +0100
Subject: [PATCH] GCOV: do not support unexecuted blocks in Ada
gcc/ChangeLog:
2017-11-06 Martin Liska <mliska@suse.cz>
* coverage.c (coverage_init): Stream information about
support of has_unexecuted_blocks.
* doc/gcov.texi: Document that.
* gcov-dump.c (dump_gcov_file): Support it in gcov_dump tool.
* gcov.c (read_graph_file): Likewise.
(output_line_beginning): Fix a small issue with
color output.
---
gcc/coverage.c | 3 +++
gcc/doc/gcov.texi | 2 +-
gcc/gcov-dump.c | 5 +++++
gcc/gcov.c | 10 ++++++++--
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 8a56a677f15..00797145593 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1262,6 +1262,9 @@ coverage_init (const char *filename)
gcov_write_unsigned (GCOV_NOTE_MAGIC);
gcov_write_unsigned (GCOV_VERSION);
gcov_write_unsigned (bbg_file_stamp);
+
+ /* Do not support has_unexecuted_blocks for Ada. */
+ gcov_write_unsigned (strcmp (lang_hooks.name, "GNU Ada") != 0);
}
}
diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index 5c4ba8a51a7..52924434504 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -343,7 +343,7 @@ marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block
is reachable via non-exceptional or exceptional paths.
Executed basic blocks having a statement with zero @var{execution_count}
end with @samp{*} character and are colored with magenta color with @option{-k}
-option.
+option. The functionality is not supported in Ada.
Note that GCC can completely remove the bodies of functions that are
not needed -- for instance if they are inlined everywhere. Such functions
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index d24e72ac4a1..40b3399e47a 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -217,6 +217,11 @@ dump_gcov_file (const char *filename)
printf ("%s:stamp %lu\n", filename, (unsigned long)stamp);
}
+ /* support for unexecuted basic blocks */
+ unsigned support_unexecuted_blocks = gcov_read_unsigned ();
+ if (!support_unexecuted_blocks)
+ printf ("%s: has_unexecuted_block is not supported\n", filename);
+
while (1)
{
gcov_position_t base, position = gcov_position ();
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 48bcdc0d4c3..ac48a4c3e8c 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -367,6 +367,9 @@ static char *bbg_file_name;
/* Stamp of the bbg file */
static unsigned bbg_stamp;
+/* Supports has_unexecuted_blocks functionality. */
+static unsigned bbg_supports_has_unexecuted_blocks;
+
/* Name and file pointer of the input file for the count data (gcda). */
static char *da_file_name;
@@ -1319,6 +1322,7 @@ read_graph_file (void)
bbg_file_name, v, e);
}
bbg_stamp = gcov_read_unsigned ();
+ bbg_supports_has_unexecuted_blocks = gcov_read_unsigned ();
while ((tag = gcov_read_unsigned ()))
{
@@ -2495,12 +2499,14 @@ output_line_beginning (FILE *f, bool exists, bool unexceptional,
if (count > 0)
{
s = format_gcov (count, 0, -1);
- if (has_unexecuted_block)
+ if (has_unexecuted_block
+ && bbg_supports_has_unexecuted_blocks)
{
if (flag_use_colors)
{
pad_count_string (s);
- s = SGR_SEQ (COLOR_BG_MAGENTA COLOR_SEPARATOR COLOR_FG_WHITE);
+ s.insert (0, SGR_SEQ (COLOR_BG_MAGENTA
+ COLOR_SEPARATOR COLOR_FG_WHITE));
s += SGR_RESET;
}
else
--
2.14.3