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;
{ 0, 0, 0, 0 }
};
+#define VALUE_PADDING_PREFIX " "
+#define VALUE_PREFIX "%2d: "
+
static const tag_format_t tag_table[] =
{
{0, "NOP", NULL},
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
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)
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 ();
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);
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);
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 ();
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)
{
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)
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[] = {
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;
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,
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;
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;
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,