From: Martin Liska Date: Mon, 18 Nov 2019 11:51:20 +0000 (+0100) Subject: Improve -dbg-cnt error message and support :0. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=342ae9ad5517d74e7b2a87beeea15ac139ada0fe;p=gcc.git Improve -dbg-cnt error message and support :0. 2019-11-18 Martin Liska * 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. From-SVN: r278396 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a829a68f543..846506b2088 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-11-18 Martin Liska + + * 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. + 2019-11-18 Martin Liska PR ipa/92529 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. */