Commit 0a090f42 by Seongbae Park Committed by Seongbae Park

opts.c (common_handle_option): Handle new option -fdbg-cnt-list.


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.

From-SVN: r125657
parent 773a7861
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> 2007-06-12 Eric Botcazou <ebotcazou@adacore.com>
* tree-ssa-alias.c (finalize_ref_all_pointers): Clear pt_anything * tree-ssa-alias.c (finalize_ref_all_pointers): Clear pt_anything
......
...@@ -392,9 +392,13 @@ fdata-sections ...@@ -392,9 +392,13 @@ fdata-sections
Common Report Var(flag_data_sections) Optimization Common Report Var(flag_data_sections) Optimization
Place data items into their own section Place data items into their own section
fdbg-cnt-list
Common Report
List all available debugging counters with their limits and counts.
fdbg-cnt= fdbg-cnt=
Common RejectNegative Joined 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 ; Nonzero for -fdefer-pop: don't pop args after each function call
; instead save them up to pop many calls' args with one insns. ; instead save them up to pop many calls' args with one insns.
......
...@@ -23,6 +23,7 @@ See dbgcnt.def for usage information. */ ...@@ -23,6 +23,7 @@ See dbgcnt.def for usage information. */
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "errors.h"
#include "dbgcnt.h" #include "dbgcnt.h"
...@@ -70,7 +71,7 @@ dbg_cnt_set_limit_by_index (enum debug_counter index, int value) ...@@ -70,7 +71,7 @@ dbg_cnt_set_limit_by_index (enum debug_counter index, int value)
fprintf (stderr, "dbg_cnt '%s' set to %d\n", map[index].name, value); 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) dbg_cnt_set_limit_by_name (const char *name, int len, int value)
{ {
int i; int i;
...@@ -79,29 +80,66 @@ dbg_cnt_set_limit_by_name (const char *name, int len, int value) ...@@ -79,29 +80,66 @@ dbg_cnt_set_limit_by_name (const char *name, int len, int value)
break; break;
if (i < 0) if (i < 0)
return; return false;
dbg_cnt_set_limit_by_index (i, value); 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 *colon = strchr (arg, ':');
char *comma; char *endptr = NULL;
int value;
if (colon == NULL) 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, ','); void
while (comma) 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, ':'); char *buffer = alloca (arg - start + 2);
if (colon == NULL || !(colon[1] >= '0' && colon[1] <= '9')) sprintf (buffer, "%*c", (int)(1 + (arg - start)), '^');
return; error ("Can not find a valid counter:value pair:");
dbg_cnt_set_limit_by_name (comma + 1, colon - (comma + 1), atoi (colon + 1)); error ("-fdbg-cnt=%s", start);
comma = strchr (colon + 1, ','); 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");
}
...@@ -35,5 +35,6 @@ enum debug_counter { ...@@ -35,5 +35,6 @@ enum debug_counter {
extern bool dbg_cnt_is_enabled (enum debug_counter index); extern bool dbg_cnt_is_enabled (enum debug_counter index);
extern bool dbg_cnt (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_process_opt (const char *arg);
extern void dbg_cnt_list_all_counters (void);
#endif /* GCC_DBGCNT_H */ #endif /* GCC_DBGCNT_H */
...@@ -269,6 +269,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -269,6 +269,7 @@ Objective-C and Objective-C++ Dialects}.
@item Debugging Options @item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}. @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol @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-noaddr -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ipa-all -fdump-ipa-cgraph @gol -fdump-ipa-all -fdump-ipa-cgraph @gol
...@@ -4211,6 +4212,21 @@ above for a description of @var{auxname} and instructions on how to ...@@ -4211,6 +4212,21 @@ above for a description of @var{auxname} and instructions on how to
generate test coverage data. Coverage data will match the source files generate test coverage data. Coverage data will match the source files
more closely, if you do not optimize. 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 -d@var{letters}
@item -fdump-rtl-@var{pass} @item -fdump-rtl-@var{pass}
@opindex d @opindex d
......
...@@ -1434,6 +1434,10 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1434,6 +1434,10 @@ common_handle_option (size_t scode, const char *arg, int value,
dbg_cnt_process_opt (arg); dbg_cnt_process_opt (arg);
break; break;
case OPT_fdbg_cnt_list:
dbg_cnt_list_all_counters ();
break;
case OPT_fdiagnostics_show_location_: case OPT_fdiagnostics_show_location_:
if (!strcmp (arg, "once")) if (!strcmp (arg, "once"))
diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE; diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment