summaryrefslogtreecommitdiff
path: root/gcc/gcov-dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gcov-dump.c')
-rw-r--r--gcc/gcov-dump.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index 3f3d4554cbf..7f8e23109f8 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -38,6 +38,8 @@ 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 dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
+ const struct gcov_ctr_summary *summary);
extern int main (int, char **);
typedef struct tag_format
@@ -49,6 +51,7 @@ typedef struct tag_format
static int flag_dump_contents = 0;
static int flag_dump_positions = 0;
+static int flag_dump_working_sets = 0;
static const struct option options[] =
{
@@ -56,6 +59,7 @@ static const struct option options[] =
{ "version", no_argument, NULL, 'v' },
{ "long", no_argument, NULL, 'l' },
{ "positions", no_argument, NULL, 'o' },
+ { "working-sets", no_argument, NULL, 'w' },
{ 0, 0, 0, 0 }
};
@@ -93,7 +97,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
diagnostic_initialize (global_dc, 0);
- while ((opt = getopt_long (argc, argv, "hlpv", options, NULL)) != -1)
+ while ((opt = getopt_long (argc, argv, "hlpvw", options, NULL)) != -1)
{
switch (opt)
{
@@ -109,6 +113,9 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
case 'p':
flag_dump_positions = 1;
break;
+ case 'w':
+ flag_dump_working_sets = 1;
+ break;
default:
fprintf (stderr, "unknown flag `%c'\n", opt);
}
@@ -128,6 +135,7 @@ print_usage (void)
printf (" -v, --version Print version number\n");
printf (" -l, --long Dump record contents too\n");
printf (" -p, --positions Dump record positions\n");
+ printf (" -w, --working-sets Dump working set computed from summary\n");
}
static void
@@ -484,5 +492,39 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
(HOST_WIDEST_INT)histo_bucket->min_value,
(HOST_WIDEST_INT)histo_bucket->cum_value);
}
+ if (flag_dump_working_sets)
+ dump_working_sets (filename, &summary.ctrs[ix]);
+ }
+}
+
+static void
+dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
+ const struct gcov_ctr_summary *summary)
+{
+ gcov_working_set_t gcov_working_sets[NUM_GCOV_WORKING_SETS];
+ unsigned ws_ix, pctinc, pct;
+ gcov_working_set_t *ws_info;
+
+ compute_working_sets (summary, gcov_working_sets);
+
+ printf ("\n");
+ print_prefix (filename, 0, 0);
+ printf ("\t\tcounter 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_ix++, pct += pctinc)
+ {
+ if (ws_ix == NUM_GCOV_WORKING_SETS - 1)
+ pct = 9990;
+ 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="
+ HOST_WIDEST_INT_PRINT_DEC,
+ pct / 100, pct - (pct / 100 * 100),
+ ws_info->num_counters,
+ (HOST_WIDEST_INT)ws_info->min_counter);
}
}