diff options
Diffstat (limited to 'gcc-4.9/gcc/gcov-dump.c')
-rw-r--r-- | gcc-4.9/gcc/gcov-dump.c | 104 |
1 files changed, 102 insertions, 2 deletions
diff --git a/gcc-4.9/gcc/gcov-dump.c b/gcc-4.9/gcc/gcov-dump.c index f21878dd1..7df649466 100644 --- a/gcc-4.9/gcc/gcov-dump.c +++ b/gcc-4.9/gcc/gcov-dump.c @@ -29,6 +29,7 @@ along with Gcov; see the file COPYING3. If not see #include "gcov-io.c" static void dump_gcov_file (const char *); +static int dump_aux_modules (const char *); static void print_prefix (const char *, unsigned, gcov_position_t); static void print_usage (void); static void print_version (void); @@ -38,6 +39,7 @@ 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_module_info (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 **); @@ -51,6 +53,7 @@ typedef struct tag_format static int flag_dump_contents = 0; static int flag_dump_positions = 0; +static int flag_dump_aux_modules_only = 0; static int flag_dump_working_sets = 0; static const struct option options[] = @@ -74,6 +77,7 @@ static const tag_format_t tag_table[] = {GCOV_TAG_LINES, "LINES", tag_lines}, {GCOV_TAG_OBJECT_SUMMARY, "OBJECT_SUMMARY", tag_summary}, {GCOV_TAG_PROGRAM_SUMMARY, "PROGRAM_SUMMARY", tag_summary}, + {GCOV_TAG_MODULE_INFO, "MODULE INFO", tag_module_info}, {0, NULL, NULL} }; @@ -97,7 +101,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv) diagnostic_initialize (global_dc, 0); - while ((opt = getopt_long (argc, argv, "hlpvw", options, NULL)) != -1) + while ((opt = getopt_long (argc, argv, "hlpvxw", options, NULL)) != -1) { switch (opt) { @@ -113,6 +117,9 @@ main (int argc ATTRIBUTE_UNUSED, char **argv) case 'p': flag_dump_positions = 1; break; + case 'x': + flag_dump_aux_modules_only = 1; + break; case 'w': flag_dump_working_sets = 1; break; @@ -121,6 +128,13 @@ main (int argc ATTRIBUTE_UNUSED, char **argv) } } + if (flag_dump_aux_modules_only) + { + while (argv[optind]) + if (dump_aux_modules (argv[optind++])) + return 1; + } + else while (argv[optind]) dump_gcov_file (argv[optind++]); return 0; @@ -135,6 +149,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 (" -x Dump names of auxiliary modules only\n"); printf (" -w, --working-sets Dump working set computed from summary\n"); } @@ -159,6 +174,52 @@ print_prefix (const char *filename, unsigned depth, gcov_position_t position) printf ("%.*s", (int) depth, prefix); } +/* Dump auxiliary module information for gcda file with + name FILENAME. */ + +static int +dump_aux_modules (const char *filename) +{ + if (!gcov_open (filename, 1)) + { + fprintf (stderr, "%s:cannot open\n", filename); + return 1; + } + + /* magic */ + gcov_read_unsigned (); + /* version */ + gcov_read_unsigned (); + /* stamp */ + gcov_read_unsigned (); + + while (1) + { + gcov_position_t base; + unsigned tag, length; + int error; + + tag = gcov_read_unsigned (); + if (!tag) + break; + length = gcov_read_unsigned (); + base = gcov_position (); + if (tag == GCOV_TAG_MODULE_INFO) + tag_module_info (filename, tag, length); + gcov_sync (base, length); + if ((error = gcov_is_error ())) + { + printf (error < 0 ? "%s:counter overflow at %lu\n" : + "%s:read error at %lu\n", filename, + (long unsigned) gcov_position ()); + return 1; + } + } + + gcov_close (); + return 0; +} + static void dump_gcov_file (const char *filename) { @@ -422,7 +483,11 @@ static void tag_counters (const char *filename ATTRIBUTE_UNUSED, unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED) { - static const char *const counter_names[] = GCOV_COUNTER_NAMES; +#define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) NAME, + static const char *const counter_names[] = { +#include "gcov-counter.def" +}; +#undef DEF_GCOV_COUNTER unsigned n_counts = GCOV_TAG_COUNTER_NUM (length); printf (" %s %u counts", @@ -498,6 +563,41 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED, } static void +tag_module_info (const char *filename ATTRIBUTE_UNUSED, + unsigned tag ATTRIBUTE_UNUSED, unsigned length) +{ + struct gcov_module_info* mod_info; + + mod_info = (struct gcov_module_info *) + alloca ((length + 2) * sizeof (gcov_unsigned_t)); + gcov_read_module_info (mod_info, length); + if (flag_dump_aux_modules_only) + { + if (!mod_info->is_primary) + printf ("%s\n", mod_info->source_filename); + } + else + { + const char *primary_suffix = + mod_info->is_primary ? "primary" : "auxiliary"; + const char *export_suffix = ""; + const char *include_all_suffix = ""; + + if (mod_info->is_primary) + { + if (MODULE_EXPORTED_FLAG (mod_info)) + export_suffix = ",exported"; + if (MODULE_INCLUDE_ALL_AUX_FLAG (mod_info)) + include_all_suffix =",include_all"; + } + + printf (": %s (ident=%u) [%s%s%s]", mod_info->source_filename, + mod_info->ident, primary_suffix, export_suffix, + include_all_suffix); + } +} + +static void dump_working_sets (const char *filename ATTRIBUTE_UNUSED, const struct gcov_ctr_summary *summary) { |