From: Martin Liska Date: Tue, 6 Oct 2020 09:18:55 +0000 (+0200) Subject: dbgcnt: print list after compilation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a30d4fc5199ba16cec39fd3f9cca878a9699cf4e;p=gcc.git dbgcnt: print list after compilation gcc/ChangeLog: * common.opt: Remove -fdbg-cnt-list from deferred options. * dbgcnt.c (dbg_cnt_set_limit_by_index): Make a copy to original_limits. (dbg_cnt_list_all_counters): Print also current counter value and print to stderr. * opts-global.c (handle_common_deferred_options): Do not handle -fdbg-cnt-list. * opts.c (common_handle_option): Likewise. * toplev.c (finalize): Handle it after compilation here. --- diff --git a/gcc/common.opt b/gcc/common.opt index 292c2de694e..7e789d1c47f 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1202,7 +1202,7 @@ Common Report Var(flag_data_sections) Place data items into their own section. fdbg-cnt-list -Common Report Var(common_deferred_options) Defer +Common Report Var(flag_dbg_cnt_list) List all available debugging counters with their limits and counts. fdbg-cnt= diff --git a/gcc/dbgcnt.c b/gcc/dbgcnt.c index 01893ce7238..2a2dd57507d 100644 --- a/gcc/dbgcnt.c +++ b/gcc/dbgcnt.c @@ -45,6 +45,7 @@ static struct string2counter_map map[debug_counter_number_of_counters] = typedef std::pair limit_tuple; static vec limits[debug_counter_number_of_counters]; +static vec original_limits[debug_counter_number_of_counters]; static unsigned int count[debug_counter_number_of_counters]; @@ -134,6 +135,8 @@ dbg_cnt_set_limit_by_index (enum debug_counter index, const char *name, } } + original_limits[index] = limits[index].copy (); + return true; } @@ -226,25 +229,27 @@ void dbg_cnt_list_all_counters (void) { int i; - printf (" %-30s %s\n", G_("counter name"), G_("closed intervals")); - printf ("-----------------------------------------------------------------\n"); + fprintf (stderr, " %-30s%-15s %s\n", G_("counter name"), + G_("counter value"), G_("closed intervals")); + fprintf (stderr, "-----------------------------------------------------------------\n"); for (i = 0; i < debug_counter_number_of_counters; i++) { - printf (" %-30s ", map[i].name); - if (limits[i].exists ()) + fprintf (stderr, " %-30s%-15d ", map[i].name, count[i]); + if (original_limits[i].exists ()) { - for (int j = limits[i].length () - 1; j >= 0; j--) + for (int j = original_limits[i].length () - 1; j >= 0; j--) { - printf ("[%u, %u]", limits[i][j].first, limits[i][j].second); + fprintf (stderr, "[%u, %u]", original_limits[i][j].first, + original_limits[i][j].second); if (j > 0) - printf (", "); + fprintf (stderr, ", "); } - putchar ('\n'); + fprintf (stderr, "\n"); } else - printf ("unset\n"); + fprintf (stderr, "unset\n"); } - printf ("\n"); + fprintf (stderr, "\n"); } #if CHECKING_P diff --git a/gcc/opts-global.c b/gcc/opts-global.c index b024ab8e18f..1816acf805b 100644 --- a/gcc/opts-global.c +++ b/gcc/opts-global.c @@ -378,10 +378,6 @@ handle_common_deferred_options (void) dbg_cnt_process_opt (opt->arg); break; - case OPT_fdbg_cnt_list: - dbg_cnt_list_all_counters (); - break; - case OPT_fdebug_prefix_map_: add_debug_prefix_map (opt->arg); break; diff --git a/gcc/opts.c b/gcc/opts.c index 3bda59afced..da503c32dd0 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2361,11 +2361,6 @@ common_handle_option (struct gcc_options *opts, /* Deferred. */ break; - case OPT_fdbg_cnt_list: - /* Deferred. */ - opts->x_exit_after_options = true; - break; - case OPT_fdebug_prefix_map_: case OPT_ffile_prefix_map_: /* Deferred. */ diff --git a/gcc/toplev.c b/gcc/toplev.c index a4cb8bb262e..8c1e1e1f44f 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -86,6 +86,7 @@ along with GCC; see the file COPYING3. If not see #include "optinfo-emit-json.h" #include "ipa-modref-tree.h" #include "ipa-modref.h" +#include "dbgcnt.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -2213,6 +2214,9 @@ finalize (bool no_backend) if (profile_report) dump_profile_report (); + if (flag_dbg_cnt_list) + dbg_cnt_list_all_counters (); + /* Language-specific end of compilation actions. */ lang_hooks.finish (); }