Fix gcov-dump tool for GCDA files (PR gcov-profile/83509).

Message ID 4db66950-be6a-0631-77db-61fd0f176183@suse.cz
State New
Headers show
Series
  • Fix gcov-dump tool for GCDA files (PR gcov-profile/83509).
Related show

Commit Message

Martin Liška Dec. 20, 2017, 2:43 p.m.
Hi.

It's quite simple bug, where we read more than allowed in case of GCDA files.
Tested on couple of source files.

Ready for trunk?
Thanks,
Martin

gcc/ChangeLog:

2017-12-20  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/83509
	* gcov-dump.c (dump_gcov_file): Do not read info about
	support_unexecuted_blocks for gcda files.
---
 gcc/gcov-dump.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Nathan Sidwell Dec. 20, 2017, 3:50 p.m. | #1
On 12/20/2017 09:43 AM, Martin Liška wrote:
> Hi.

> 

> It's quite simple bug, where we read more than allowed in case of GCDA files.

> Tested on couple of source files.


ok


-- 
Nathan Sidwell
Jeff Law Dec. 20, 2017, 3:50 p.m. | #2
On 12/20/2017 07:43 AM, Martin Liška wrote:
> Hi.

> 

> It's quite simple bug, where we read more than allowed in case of GCDA files.

> Tested on couple of source files.

> 

> Ready for trunk?

> Thanks,

> Martin

> 

> gcc/ChangeLog:

> 

> 2017-12-20  Martin Liska  <mliska@suse.cz>

> 

> 	PR gcov-profile/83509

> 	* gcov-dump.c (dump_gcov_file): Do not read info about

> 	support_unexecuted_blocks for gcda files.

OK.
jeff

Patch

diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index e5e649cb18f..7dc28bbf216 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -170,6 +170,7 @@  dump_gcov_file (const char *filename)
 {
   unsigned tags[4];
   unsigned depth = 0;
+  bool is_data_type;
 
   if (!gcov_open (filename, 1))
     {
@@ -181,14 +182,13 @@  dump_gcov_file (const char *filename)
   {
     unsigned magic = gcov_read_unsigned ();
     unsigned version;
-    const char *type = NULL;
     int endianness = 0;
     char m[4], v[4];
 
     if ((endianness = gcov_magic (magic, GCOV_DATA_MAGIC)))
-      type = "data";
+      is_data_type = true;
     else if ((endianness = gcov_magic (magic, GCOV_NOTE_MAGIC)))
-      type = "note";
+      is_data_type = false;
     else
       {
 	printf ("%s:not a gcov file\n", filename);
@@ -199,7 +199,8 @@  dump_gcov_file (const char *filename)
     GCOV_UNSIGNED2STRING (v, version);
     GCOV_UNSIGNED2STRING (m, magic);
 
-    printf ("%s:%s:magic `%.4s':version `%.4s'%s\n", filename, type,
+    printf ("%s:%s:magic `%.4s':version `%.4s'%s\n", filename,
+	    is_data_type ? "data" : "note",
  	    m, v, endianness < 0 ? " (swapped endianness)" : "");
     if (version != GCOV_VERSION)
       {
@@ -217,10 +218,13 @@  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);
+  if (!is_data_type)
+    {
+      /* 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)
     {