Fix indentation of gcov-dump.

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
This commit is contained in:
Martin Liska 2017-04-28 14:48:44 +02:00 committed by Martin Liska
parent 1ad784e2fc
commit 5c5059bcf8
2 changed files with 69 additions and 49 deletions

View 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> 2017-04-28 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/80531 PR bootstrap/80531

View 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_prefix (const char *, unsigned, gcov_position_t);
static void print_usage (void); static void print_usage (void);
static void print_version (void); static void print_version (void);
static void tag_function (const char *, unsigned, unsigned); static void tag_function (const char *, unsigned, unsigned, unsigned);
static void tag_blocks (const char *, unsigned, unsigned); static void tag_blocks (const char *, unsigned, unsigned, unsigned);
static void tag_arcs (const char *, unsigned, unsigned); static void tag_arcs (const char *, unsigned, unsigned, unsigned);
static void tag_lines (const char *, unsigned, unsigned); static void tag_lines (const char *, unsigned, unsigned, unsigned);
static void tag_counters (const char *, unsigned, unsigned); static void tag_counters (const char *, unsigned, unsigned, unsigned);
static void tag_summary (const char *, unsigned, unsigned); static void tag_summary (const char *, unsigned, unsigned, unsigned);
static void dump_working_sets (const char *filename ATTRIBUTE_UNUSED, 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 **); extern int main (int, char **);
typedef struct tag_format typedef struct tag_format
{ {
unsigned tag; unsigned tag;
char const *name; char const *name;
void (*proc) (const char *, unsigned, unsigned); void (*proc) (const char *, unsigned, unsigned, unsigned);
} tag_format_t; } tag_format_t;
static int flag_dump_contents = 0; static int flag_dump_contents = 0;
@ -63,6 +64,9 @@ static const struct option options[] =
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
#define VALUE_PADDING_PREFIX " "
#define VALUE_PREFIX "%2d: "
static const tag_format_t tag_table[] = static const tag_format_t tag_table[] =
{ {
{0, "NOP", NULL}, {0, "NOP", NULL},
@ -157,8 +161,8 @@ print_prefix (const char *filename, unsigned depth, gcov_position_t position)
printf ("%s:", filename); printf ("%s:", filename);
if (flag_dump_positions) if (flag_dump_positions)
printf ("%lu:", (unsigned long) position); printf ("%5lu:", (unsigned long) position);
printf ("%.*s", (int) depth, prefix); printf ("%.*s", (int) 2 * depth, prefix);
} }
static void static void
@ -257,7 +261,7 @@ dump_gcov_file (const char *filename)
print_prefix (filename, tag_depth, position); print_prefix (filename, tag_depth, position);
printf ("%08x:%4u:%s", tag, length, format->name); printf ("%08x:%4u:%s", tag, length, format->name);
if (format->proc) if (format->proc)
(*format->proc) (filename, tag, length); (*format->proc) (filename, tag, length, depth);
printf ("\n"); printf ("\n");
if (flag_dump_contents && format->proc) if (flag_dump_contents && format->proc)
@ -285,7 +289,8 @@ dump_gcov_file (const char *filename)
static void static void
tag_function (const char *filename ATTRIBUTE_UNUSED, 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 (); unsigned long pos = gcov_position ();
@ -312,7 +317,8 @@ tag_function (const char *filename ATTRIBUTE_UNUSED,
static void static void
tag_blocks (const char *filename ATTRIBUTE_UNUSED, 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); unsigned n_blocks = GCOV_TAG_BLOCKS_NUM (length);
@ -327,17 +333,18 @@ tag_blocks (const char *filename ATTRIBUTE_UNUSED,
if (!(ix & 7)) if (!(ix & 7))
{ {
printf ("\n"); printf ("\n");
print_prefix (filename, 0, gcov_position ()); print_prefix (filename, depth, gcov_position ());
printf ("\t\t%u", ix); printf (VALUE_PADDING_PREFIX VALUE_PREFIX, ix);
} }
printf (" %04x", gcov_read_unsigned ()); printf ("%04x ", gcov_read_unsigned ());
} }
} }
} }
static void static void
tag_arcs (const char *filename ATTRIBUTE_UNUSED, 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); unsigned n_arcs = GCOV_TAG_ARCS_NUM (length);
@ -354,8 +361,8 @@ tag_arcs (const char *filename ATTRIBUTE_UNUSED,
if (!(ix & 3)) if (!(ix & 3))
{ {
printf ("\n"); printf ("\n");
print_prefix (filename, 0, gcov_position ()); print_prefix (filename, depth, gcov_position ());
printf ("\tblock %u:", blockno); printf (VALUE_PADDING_PREFIX "block %u:", blockno);
} }
dst = gcov_read_unsigned (); dst = gcov_read_unsigned ();
flags = gcov_read_unsigned (); flags = gcov_read_unsigned ();
@ -378,7 +385,8 @@ tag_arcs (const char *filename ATTRIBUTE_UNUSED,
static void static void
tag_lines (const char *filename ATTRIBUTE_UNUSED, 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) if (flag_dump_contents)
{ {
@ -402,8 +410,8 @@ tag_lines (const char *filename ATTRIBUTE_UNUSED,
if (!sep) if (!sep)
{ {
printf ("\n"); printf ("\n");
print_prefix (filename, 0, position); print_prefix (filename, depth, position);
printf ("\tblock %u:", blockno); printf (VALUE_PADDING_PREFIX "block %u:", blockno);
sep = ""; sep = "";
} }
if (lineno) if (lineno)
@ -422,7 +430,8 @@ tag_lines (const char *filename ATTRIBUTE_UNUSED,
static void static void
tag_counters (const char *filename ATTRIBUTE_UNUSED, 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, #define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) NAME,
static const char *const counter_names[] = { static const char *const counter_names[] = {
@ -444,20 +453,20 @@ tag_counters (const char *filename ATTRIBUTE_UNUSED,
if (!(ix & 7)) if (!(ix & 7))
{ {
printf ("\n"); printf ("\n");
print_prefix (filename, 0, gcov_position ()); print_prefix (filename, depth, gcov_position ());
printf ("\t\t%u", ix); printf (VALUE_PADDING_PREFIX VALUE_PREFIX, ix);
} }
count = gcov_read_counter (); count = gcov_read_counter ();
printf (" "); printf ("%" PRId64 " ", count);
printf ("%" PRId64, count);
} }
} }
} }
static void static void
tag_summary (const char *filename ATTRIBUTE_UNUSED, 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; struct gcov_summary summary;
unsigned ix, h_ix; unsigned ix, h_ix;
@ -469,8 +478,8 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
for (ix = 0; ix != GCOV_COUNTERS_SUMMABLE; ix++) for (ix = 0; ix != GCOV_COUNTERS_SUMMABLE; ix++)
{ {
printf ("\n"); printf ("\n");
print_prefix (filename, 0, 0); print_prefix (filename, depth, 0);
printf ("\t\tcounts=%u, runs=%u", printf (VALUE_PADDING_PREFIX "counts=%u, runs=%u",
summary.ctrs[ix].num, summary.ctrs[ix].runs); summary.ctrs[ix].num, summary.ctrs[ix].runs);
printf (", sum_all=%" PRId64, printf (", sum_all=%" PRId64,
@ -482,30 +491,30 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
if (ix != GCOV_COUNTER_ARCS) if (ix != GCOV_COUNTER_ARCS)
continue; continue;
printf ("\n"); printf ("\n");
print_prefix (filename, 0, 0); print_prefix (filename, depth, 0);
printf ("\t\tcounter histogram:"); printf (VALUE_PADDING_PREFIX "counter histogram:");
for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
{ {
histo_bucket = &summary.ctrs[ix].histogram[h_ix]; histo_bucket = &summary.ctrs[ix].histogram[h_ix];
if (!histo_bucket->num_counters) if (!histo_bucket->num_counters)
continue; continue;
printf ("\n"); printf ("\n");
print_prefix (filename, 0, 0); print_prefix (filename, depth, 0);
printf ("\t\t%d: num counts=%u, min counter=" printf (VALUE_PADDING_PREFIX VALUE_PREFIX "num counts=%u, "
"%" PRId64 ", cum_counter=" "min counter=%" PRId64 ", cum_counter=%" PRId64,
"%" PRId64, h_ix, histo_bucket->num_counters,
h_ix, histo_bucket->num_counters, (int64_t)histo_bucket->min_value,
(int64_t)histo_bucket->min_value, (int64_t)histo_bucket->cum_value);
(int64_t)histo_bucket->cum_value);
} }
if (flag_dump_working_sets) if (flag_dump_working_sets)
dump_working_sets (filename, &summary.ctrs[ix]); dump_working_sets (filename, &summary.ctrs[ix], depth);
} }
} }
static void static void
dump_working_sets (const char *filename ATTRIBUTE_UNUSED, 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]; gcov_working_set_t gcov_working_sets[NUM_GCOV_WORKING_SETS];
unsigned ws_ix, pctinc, pct; unsigned ws_ix, pctinc, pct;
@ -514,8 +523,8 @@ dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
compute_working_sets (summary, gcov_working_sets); compute_working_sets (summary, gcov_working_sets);
printf ("\n"); printf ("\n");
print_prefix (filename, 0, 0); print_prefix (filename, depth, 0);
printf ("\t\tcounter working sets:"); printf (VALUE_PADDING_PREFIX "counter working sets:");
/* Multiply the percentage by 100 to avoid float. */ /* Multiply the percentage by 100 to avoid float. */
pctinc = 100 * 100 / NUM_GCOV_WORKING_SETS; pctinc = 100 * 100 / NUM_GCOV_WORKING_SETS;
for (ws_ix = 0, pct = pctinc; ws_ix < 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]; ws_info = &gcov_working_sets[ws_ix];
/* Print out the percentage using int arithmatic to avoid float. */ /* Print out the percentage using int arithmatic to avoid float. */
printf ("\n"); printf ("\n");
print_prefix (filename, 0, 0); print_prefix (filename, depth + 1, 0);
printf ("\t\t%u.%02u%%: num counts=%u, min counter=" printf (VALUE_PADDING_PREFIX "%u.%02u%%: num counts=%u, min counter="
"%" PRId64, "%" PRId64,
pct / 100, pct - (pct / 100 * 100), pct / 100, pct - (pct / 100 * 100),
ws_info->num_counters, ws_info->num_counters,