* opts.c (common_handle_option): Handle new option -fdbg-cnt-list.
* dbgcnt.c (dbg_cnt_set_limit_by_name): Return value
to indicate an error.
(dbg_cnt_process_single_pair, dbg_cnt_list_all_counters): New functions
(dbg_cnt_process_opt): Print an error on a bad argument.
* dbgcnt.h (dbg_cnt_list_all_counters): New function declaration.
* common.opt (-fdbg-cnt-list): New.
* doc/invoke.texi (-fdbg-cnt-list,-fdbg-cnt=): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125657
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-06-12 Seongbae Park <seongbae.park@gmail.com>
+
+ * opts.c (common_handle_option): Handle new option -fdbg-cnt-list.
+ * dbgcnt.c (dbg_cnt_set_limit_by_name): Return value
+ to indicate an error.
+ (dbg_cnt_process_single_pair, dbg_cnt_list_all_counters): New functions
+ (dbg_cnt_process_opt): Print an error on a bad argument.
+ * dbgcnt.h (dbg_cnt_list_all_counters): New function declaration.
+ * common.opt (-fdbg-cnt-list): New.
+ * doc/invoke.texi (-fdbg-cnt-list,-fdbg-cnt=): New.
+
2007-06-12 Eric Botcazou <ebotcazou@adacore.com>
* tree-ssa-alias.c (finalize_ref_all_pointers): Clear pt_anything
Common Report Var(flag_data_sections) Optimization
Place data items into their own section
+fdbg-cnt-list
+Common Report
+List all available debugging counters with their limits and counts.
+
fdbg-cnt=
Common RejectNegative Joined
--fdbg-cnt=<counter>:<limit> Set the debug counter limit.
+-fdbg-cnt=<counter>:<limit>[,<counter>:<limit>,...] Set the debug counter limit.
; Nonzero for -fdefer-pop: don't pop args after each function call
; instead save them up to pop many calls' args with one insns.
#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include "errors.h"
#include "dbgcnt.h"
fprintf (stderr, "dbg_cnt '%s' set to %d\n", map[index].name, value);
}
-static void
+static bool
dbg_cnt_set_limit_by_name (const char *name, int len, int value)
{
int i;
break;
if (i < 0)
- return;
+ return false;
dbg_cnt_set_limit_by_index (i, value);
+ return true;
}
-void
-dbg_cnt_process_opt (const char *arg)
+
+/* Process a single "name:value" pair.
+ Returns NULL if there's no valid pair is found.
+ Otherwise returns a pointer to the end of the pair. */
+
+static const char *
+dbg_cnt_process_single_pair (const char *arg)
{
char *colon = strchr (arg, ':');
- char *comma;
+ char *endptr = NULL;
+ int value;
if (colon == NULL)
- return;
+ return NULL;
+
+ value = strtol (colon + 1, &endptr, 10);
- dbg_cnt_set_limit_by_name (arg, colon - arg, atoi (colon + 1));
+ if (endptr != NULL && endptr != colon + 1
+ && dbg_cnt_set_limit_by_name (arg, colon - arg, value))
+ return endptr;
+
+ return NULL;
+}
- comma = strchr (colon + 1, ',');
- while (comma)
+void
+dbg_cnt_process_opt (const char *arg)
+{
+ const char *start = arg;
+ const char *next;
+ do {
+ next = dbg_cnt_process_single_pair (arg);
+ if (next == NULL)
+ break;
+ } while (*next == ',' && (arg = next + 1));
+
+ if (next == NULL || *next != 0)
{
- colon = strchr (comma + 1, ':');
- if (colon == NULL || !(colon[1] >= '0' && colon[1] <= '9'))
- return;
- dbg_cnt_set_limit_by_name (comma + 1, colon - (comma + 1), atoi (colon + 1));
- comma = strchr (colon + 1, ',');
+ char *buffer = alloca (arg - start + 2);
+ sprintf (buffer, "%*c", (int)(1 + (arg - start)), '^');
+ error ("Can not find a valid counter:value pair:");
+ error ("-fdbg-cnt=%s", start);
+ error (" %s", buffer);
}
}
+
+/* Print name, limit and count of all counters. */
+
+void dbg_cnt_list_all_counters (void)
+{
+ int i;
+ printf (" %-30s %-5s %-5s\n", "counter name", "limit", "value");
+ printf ("----------------------------------------------\n");
+ for (i = 0; i < debug_counter_number_of_counters; i++)
+ printf (" %-30s %5d %5u\n",
+ map[i].name, limit[map[i].counter], count[map[i].counter]);
+ printf ("\n");
+}
extern bool dbg_cnt_is_enabled (enum debug_counter index);
extern bool dbg_cnt (enum debug_counter index);
extern void dbg_cnt_process_opt (const char *arg);
+extern void dbg_cnt_list_all_counters (void);
#endif /* GCC_DBGCNT_H */
@item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
+-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} @gol
-fdump-noaddr -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ipa-all -fdump-ipa-cgraph @gol
generate test coverage data. Coverage data will match the source files
more closely, if you do not optimize.
+@item -fdbg-cnt-list
+@opindex fdbg-cnt-list
+Print the name and the counter upperbound for all debug counters.
+
+@item -fdbg-cnt=@var{counter-value-list}
+@opindex fdbg-cnt
+Set the internal debug counter upperbound. @var{counter-value-list}
+is a comma-separated list of @var{name}:@var{value} pairs
+which sets the upperbound of each debug counter @var{name} to @var{value}.
+All debug counters have the initial upperbound of @var{UINT_MAX},
+thus dbg_cnt() returns true always unless the upperbound is set by this option.
+e.g. With -fdbg-cnt=dce:10,tail_call:0
+dbg_cnt(dce) will return true only for first 10 invocations
+and dbg_cnt(tail_call) will return false always.
+
@item -d@var{letters}
@item -fdump-rtl-@var{pass}
@opindex d
dbg_cnt_process_opt (arg);
break;
+ case OPT_fdbg_cnt_list:
+ dbg_cnt_list_all_counters ();
+ break;
+
case OPT_fdiagnostics_show_location_:
if (!strcmp (arg, "once"))
diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;