diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2015-02-02 14:57:31 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2015-02-06 10:27:01 -0500 |
commit | b9d6130764916fac3d9bcfde2d672053a0ef3316 (patch) | |
tree | d276c6a8a853b80b72bdd856847d5e6a47e8febf /gdb/breakpoint.c | |
parent | 55325047241cf38dae3c6a577561c740a9024bf3 (diff) | |
download | gdb-b9d6130764916fac3d9bcfde2d672053a0ef3316.zip gdb-b9d6130764916fac3d9bcfde2d672053a0ef3316.tar.gz gdb-b9d6130764916fac3d9bcfde2d672053a0ef3316.tar.bz2 |
"enable count" user input error handling (PR gdb/15678)
Typing "enable count" by itself crashes GDB. Also, if you omit the
breakpoint number/range, the error message is not very clear:
(gdb) enable count 2
warning: bad breakpoint number at or near ''
(gdb) enable count
Segmentation fault (core dumped)
With this patch, the error messages are slightly more helpful:
(gdb) enable count 2
Argument required (one or more breakpoint numbers).
(gdb) enable count
Argument required (hit count).
gdb/ChangeLog:
PR gdb/15678
* breakpoint.c (map_breakpoint_numbers): Check for empty args
string.
(enable_count_command): Check args for NULL value.
gdb/testsuite/ChangeLog:
PR gdb/15678
* gdb.base/ena-dis-br.exp: Test "enable count" for bad user input.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index af0c2cf..2804453 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -14880,7 +14880,7 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, int match; struct get_number_or_range_state state; - if (args == 0) + if (args == 0 || *args == '\0') error_no_arg (_("one or more breakpoint numbers")); init_number_or_range (&state, args); @@ -15217,7 +15217,12 @@ do_map_enable_count_breakpoint (struct breakpoint *bpt, void *countptr) static void enable_count_command (char *args, int from_tty) { - int count = get_number (&args); + int count; + + if (args == NULL) + error_no_arg (_("hit count")); + + count = get_number (&args); map_breakpoint_numbers (args, do_map_enable_count_breakpoint, &count); } |