Hi.
The patch fixes missing diagnostics for situations like:
$ gcc -fdbg-cnt=match123:1 ...
and I see it beneficial to support foo:0 in order to no allow
any execution of dbg_cnt(foo). It's handy for passes that are not so
easy to disable.
Ready for trunk?
Thanks,
Martin
gcc/ChangeLog:
2019-11-18 Martin Liska <[email protected]>
* dbgcnt.c (dbg_cnt_set_limit_by_name): Provide error
message for an unknown counter.
(dbg_cnt_process_single_pair): Support 0 as minimum value.
(dbg_cnt_process_opt): Remove unreachable code.
---
gcc/dbgcnt.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/gcc/dbgcnt.c b/gcc/dbgcnt.c
index c675c644007..f58ef8fd00e 100644
--- a/gcc/dbgcnt.c
+++ b/gcc/dbgcnt.c
@@ -150,7 +150,11 @@ dbg_cnt_set_limit_by_name (const char *name, unsigned int low,
break;
if (i < 0)
- return false;
+ {
+ error ("cannot find a valid counter name %qs of %<-fdbg-cnt=%> option",
+ name);
+ return false;
+ }
return dbg_cnt_set_limit_by_index ((enum debug_counter) i, name, low, high);
}
@@ -172,8 +176,9 @@ dbg_cnt_process_single_pair (char *name, char *str)
if (value2 == NULL)
{
- low = 1;
high = strtol (value1, NULL, 10);
+ /* Let's allow 0:0. */
+ low = high == 0 ? 0 : 1;
}
else
{
@@ -209,15 +214,6 @@ dbg_cnt_process_opt (const char *arg)
}
start += strlen (tokens[i]) + 1;
}
-
- if (i != tokens.length ())
- {
- char *buffer = XALLOCAVEC (char, start + 2);
- sprintf (buffer, "%*c", start + 1, '^');
- error ("cannot find a valid counter:value pair:");
- error ("%<-fdbg-cnt=%s%>", arg);
- error (" %s", buffer);
- }
}
/* Print name, limit and count of all counters. */