Hi.

There are sometimes situations where a line is executed:

     1G:  307:read_size (unsigned char *p, int size)

in such case a more fine value is appreciated:

     1.4G:  307:read_size (unsigned char *p, int size)

Thus I'm suggesting to add one digit after dot.

Patch survives gcov.exp, will install if not objections.

Martin

gcc/ChangeLog:

2018-08-31  Martin Liska  <mli...@suse.cz>

        * doc/gcov.texi: Update documentation of humar
        readable mode.
        * gcov.c (format_count): Print one decimal place, it provides
        more fine number of situations like '1G' vs. '1.4G'.

gcc/testsuite/ChangeLog:

2018-08-31  Martin Liska  <mli...@suse.cz>

        * g++.dg/gcov/loop.C: Update test to support new format.
---
 gcc/doc/gcov.texi                | 2 +-
 gcc/gcov.c                       | 4 ++--
 gcc/testsuite/g++.dg/gcov/loop.C | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index f33dc8f6aed..98f4a876293 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -255,7 +255,7 @@ lcount:36,1,0
 
 @item -j
 @itemx --human-readable
-Write counts in human readable format (like 24k).
+Write counts in human readable format (like 24.6k).
 
 @item -k
 @itemx --use-colors
diff --git a/gcc/gcov.c b/gcc/gcov.c
index ff4020c713e..6a24a320046 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -2216,8 +2216,8 @@ format_count (gcov_type count)
       if (count + divisor / 2 < 1000 * divisor)
 	break;
     }
-  gcov_type r  = (count + divisor / 2) / divisor;
-  sprintf (buffer, "%" PRId64 "%c", r, units[i]);
+  float r = 1.0f * count / divisor;
+  sprintf (buffer, "%.1f%c", r, units[i]);
   return buffer;
 }
 
diff --git a/gcc/testsuite/g++.dg/gcov/loop.C b/gcc/testsuite/g++.dg/gcov/loop.C
index 7f3be5587af..24f580634d9 100644
--- a/gcc/testsuite/g++.dg/gcov/loop.C
+++ b/gcc/testsuite/g++.dg/gcov/loop.C
@@ -2,11 +2,11 @@
 /* { dg-do run { target native } } */
 
 unsigned
-loop (unsigned n, int value)		  /* count(14k) */
+loop (unsigned n, int value)		  /* count(14.0k) */
 {
   for (unsigned i = 0; i < n - 1; i++)
   {
-    value += i;				  /* count(21M) */
+    value += i;				  /* count(21.0M) */
   }
 
   return value;
@@ -18,7 +18,7 @@ int main(int argc, char **argv)
   for (unsigned i = 0; i < 7 * 1000; i++)
   {
     sum += loop (1000, sum);
-    sum += loop (2000, sum);		  /* count(7k) */
+    sum += loop (2000, sum);		  /* count(7.0k) */
   }
 
   return 0;				  /* count(1) */

Reply via email to