Fix indentation of gcov-dump.
authorMartin Liska <mliska@suse.cz>
Fri, 28 Apr 2017 12:48:44 +0000 (14:48 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 28 Apr 2017 12:48:44 +0000 (12:48 +0000)
2017-04-28  Martin Liska  <mliska@suse.cz>

* gcov-dump.c (tag_*): Add new argument to declarations.
(dump_gcov_file): Likewise.
(tag_blocks): Add and use new argument depth.
(tag_arcs): Likewise.
(tag_lines): Likewise.
(tag_counters): Likewise.
(tag_summary): Likewise.
(dump_working_sets): Use depth to do a proper indentation.

From-SVN: r247369

gcc/ChangeLog
gcc/gcov-dump.c

index 5388118..4b95fc7 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-28  Martin Liska  <mliska@suse.cz>
+
+       * gcov-dump.c (tag_*): Add new argument to declarations.
+       (dump_gcov_file): Likewise.
+       (tag_blocks): Add and use new argument depth.
+       (tag_arcs): Likewise.
+       (tag_lines): Likewise.
+       (tag_counters): Likewise.
+       (tag_summary): Likewise.
+       (dump_working_sets): Use depth to do a proper indentation.
+
 2017-04-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/80531
index 91c4866..47db179 100644 (file)
@@ -32,21 +32,22 @@ static void dump_gcov_file (const char *);
 static void print_prefix (const char *, unsigned, gcov_position_t);
 static void print_usage (void);
 static void print_version (void);
-static void tag_function (const char *, unsigned, unsigned);
-static void tag_blocks (const char *, unsigned, unsigned);
-static void tag_arcs (const char *, unsigned, unsigned);
-static void tag_lines (const char *, unsigned, unsigned);
-static void tag_counters (const char *, unsigned, unsigned);
-static void tag_summary (const char *, unsigned, unsigned);
+static void tag_function (const char *, unsigned, unsigned, unsigned);
+static void tag_blocks (const char *, unsigned, unsigned, unsigned);
+static void tag_arcs (const char *, unsigned, unsigned, unsigned);
+static void tag_lines (const char *, unsigned, unsigned, unsigned);
+static void tag_counters (const char *, unsigned, unsigned, unsigned);
+static void tag_summary (const char *, unsigned, unsigned, unsigned);
 static void dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
-                               const struct gcov_ctr_summary *summary);
+                              const struct gcov_ctr_summary *summary,
+                              unsigned depth);
 extern int main (int, char **);
 
 typedef struct tag_format
 {
   unsigned tag;
   char const *name;
-  void (*proc) (const char *, unsigned, unsigned);
+  void (*proc) (const char *, unsigned, unsigned, unsigned);
 } tag_format_t;
 
 static int flag_dump_contents = 0;
@@ -63,6 +64,9 @@ static const struct option options[] =
   { 0, 0, 0, 0 }
 };
 
+#define VALUE_PADDING_PREFIX "              "
+#define VALUE_PREFIX "%2d: "
+
 static const tag_format_t tag_table[] =
 {
   {0, "NOP", NULL},
@@ -157,8 +161,8 @@ print_prefix (const char *filename, unsigned depth, gcov_position_t position)
 
   printf ("%s:", filename);
   if (flag_dump_positions)
-    printf ("%lu:", (unsigned long) position);
-  printf ("%.*s", (int) depth, prefix);
+    printf ("%5lu:", (unsigned long) position);
+  printf ("%.*s", (int) 2 * depth, prefix);
 }
 
 static void
@@ -257,7 +261,7 @@ dump_gcov_file (const char *filename)
       print_prefix (filename, tag_depth, position);
       printf ("%08x:%4u:%s", tag, length, format->name);
       if (format->proc)
-       (*format->proc) (filename, tag, length);
+       (*format->proc) (filename, tag, length, depth);
 
       printf ("\n");
       if (flag_dump_contents && format->proc)
@@ -285,7 +289,8 @@ dump_gcov_file (const char *filename)
 
 static void
 tag_function (const char *filename ATTRIBUTE_UNUSED,
-             unsigned tag ATTRIBUTE_UNUSED, unsigned length)
+             unsigned tag ATTRIBUTE_UNUSED, unsigned length,
+             unsigned depth ATTRIBUTE_UNUSED)
 {
   unsigned long pos = gcov_position ();
 
@@ -312,7 +317,8 @@ tag_function (const char *filename ATTRIBUTE_UNUSED,
 
 static void
 tag_blocks (const char *filename ATTRIBUTE_UNUSED,
-           unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
+           unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+           unsigned depth)
 {
   unsigned n_blocks = GCOV_TAG_BLOCKS_NUM (length);
 
@@ -327,17 +333,18 @@ tag_blocks (const char *filename ATTRIBUTE_UNUSED,
          if (!(ix & 7))
            {
              printf ("\n");
-             print_prefix (filename, 0, gcov_position ());
-             printf ("\t\t%u", ix);
+             print_prefix (filename, depth, gcov_position ());
+             printf (VALUE_PADDING_PREFIX VALUE_PREFIX, ix);
            }
-         printf (" %04x", gcov_read_unsigned ());
+         printf ("%04x ", gcov_read_unsigned ());
        }
     }
 }
 
 static void
 tag_arcs (const char *filename ATTRIBUTE_UNUSED,
-         unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
+         unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+         unsigned depth)
 {
   unsigned n_arcs = GCOV_TAG_ARCS_NUM (length);
 
@@ -354,8 +361,8 @@ tag_arcs (const char *filename ATTRIBUTE_UNUSED,
          if (!(ix & 3))
            {
              printf ("\n");
-             print_prefix (filename, 0, gcov_position ());
-             printf ("\tblock %u:", blockno);
+             print_prefix (filename, depth, gcov_position ());
+             printf (VALUE_PADDING_PREFIX "block %u:", blockno);
            }
          dst = gcov_read_unsigned ();
          flags = gcov_read_unsigned ();
@@ -378,7 +385,8 @@ tag_arcs (const char *filename ATTRIBUTE_UNUSED,
 
 static void
 tag_lines (const char *filename ATTRIBUTE_UNUSED,
-          unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
+          unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+          unsigned depth)
 {
   if (flag_dump_contents)
     {
@@ -402,8 +410,8 @@ tag_lines (const char *filename ATTRIBUTE_UNUSED,
          if (!sep)
            {
              printf ("\n");
-             print_prefix (filename, 0, position);
-             printf ("\tblock %u:", blockno);
+             print_prefix (filename, depth, position);
+             printf (VALUE_PADDING_PREFIX "block %u:", blockno);
              sep = "";
            }
          if (lineno)
@@ -422,7 +430,8 @@ tag_lines (const char *filename ATTRIBUTE_UNUSED,
 
 static void
 tag_counters (const char *filename ATTRIBUTE_UNUSED,
-             unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
+             unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+             unsigned depth)
 {
 #define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) NAME,
   static const char *const counter_names[] = {
@@ -444,20 +453,20 @@ tag_counters (const char *filename ATTRIBUTE_UNUSED,
          if (!(ix & 7))
            {
              printf ("\n");
-             print_prefix (filename, 0, gcov_position ());
-             printf ("\t\t%u", ix);
+             print_prefix (filename, depth, gcov_position ());
+             printf (VALUE_PADDING_PREFIX VALUE_PREFIX, ix);
            }
 
          count = gcov_read_counter ();
-         printf (" ");
-         printf ("%" PRId64, count);
+         printf ("%" PRId64 " ", count);
        }
     }
 }
 
 static void
 tag_summary (const char *filename ATTRIBUTE_UNUSED,
-            unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
+            unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED,
+            unsigned depth)
 {
   struct gcov_summary summary;
   unsigned ix, h_ix;
@@ -469,8 +478,8 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
   for (ix = 0; ix != GCOV_COUNTERS_SUMMABLE; ix++)
     {
       printf ("\n");
-      print_prefix (filename, 0, 0);
-      printf ("\t\tcounts=%u, runs=%u",
+      print_prefix (filename, depth, 0);
+      printf (VALUE_PADDING_PREFIX "counts=%u, runs=%u",
              summary.ctrs[ix].num, summary.ctrs[ix].runs);
 
       printf (", sum_all=%" PRId64,
@@ -482,30 +491,30 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
       if (ix != GCOV_COUNTER_ARCS)
         continue;
       printf ("\n");
-      print_prefix (filename, 0, 0);
-      printf ("\t\tcounter histogram:");
+      print_prefix (filename, depth, 0);
+      printf (VALUE_PADDING_PREFIX "counter histogram:");
       for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
         {
-          histo_bucket = &summary.ctrs[ix].histogram[h_ix];
-          if (!histo_bucket->num_counters)
-            continue;
-          printf ("\n");
-          print_prefix (filename, 0, 0);
-          printf ("\t\t%d: num counts=%u, min counter="
-              "%" PRId64 ", cum_counter="
-              "%" PRId64,
-             h_ix, histo_bucket->num_counters,
-              (int64_t)histo_bucket->min_value,
-              (int64_t)histo_bucket->cum_value);
+         histo_bucket = &summary.ctrs[ix].histogram[h_ix];
+         if (!histo_bucket->num_counters)
+           continue;
+         printf ("\n");
+         print_prefix (filename, depth, 0);
+         printf (VALUE_PADDING_PREFIX VALUE_PREFIX "num counts=%u, "
+                 "min counter=%" PRId64 ", cum_counter=%" PRId64,
+                 h_ix, histo_bucket->num_counters,
+                 (int64_t)histo_bucket->min_value,
+                 (int64_t)histo_bucket->cum_value);
         }
       if (flag_dump_working_sets)
-        dump_working_sets (filename, &summary.ctrs[ix]);
+       dump_working_sets (filename, &summary.ctrs[ix], depth);
     }
 }
 
 static void
 dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
-                   const struct gcov_ctr_summary *summary)
+                  const struct gcov_ctr_summary *summary,
+                  unsigned depth)
 {
   gcov_working_set_t gcov_working_sets[NUM_GCOV_WORKING_SETS];
   unsigned ws_ix, pctinc, pct;
@@ -514,8 +523,8 @@ dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
   compute_working_sets (summary, gcov_working_sets);
 
   printf ("\n");
-  print_prefix (filename, 0, 0);
-  printf ("\t\tcounter working sets:");
+  print_prefix (filename, depth, 0);
+  printf (VALUE_PADDING_PREFIX "counter working sets:");
   /* Multiply the percentage by 100 to avoid float.  */
   pctinc = 100 * 100 / NUM_GCOV_WORKING_SETS;
   for (ws_ix = 0, pct = pctinc; ws_ix < NUM_GCOV_WORKING_SETS;
@@ -526,8 +535,8 @@ dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
       ws_info = &gcov_working_sets[ws_ix];
       /* Print out the percentage using int arithmatic to avoid float.  */
       printf ("\n");
-      print_prefix (filename, 0, 0);
-      printf ("\t\t%u.%02u%%: num counts=%u, min counter="
+      print_prefix (filename, depth + 1, 0);
+      printf (VALUE_PADDING_PREFIX "%u.%02u%%: num counts=%u, min counter="
                "%" PRId64,
                pct / 100, pct - (pct / 100 * 100),
                ws_info->num_counters,