[PATCH 2/4] Error on bad count number

Yao Qi
2014-03-05T12:49:15Z

GDB is quiet for these invalid input like this

(gdb) enable count 1.1 1
(gdb)

This patch is to check the input number is valid, and emit error if
input number isn't valid. With this patch, it becomes:

(gdb) enable count 1.1 1
Bad count number '1.1 1'

gdb:

2014-03-05 Yao Qi <yao@codesourcery.com>

* breakpoint.c (enable_count_command): Emit error if 'count'
is zero.

gdb/testsuite:

2014-03-05 Yao Qi <yao@codesourcery.com>

* gdb.base/ena-dis-br.exp: Test bad count number.
---
gdb/breakpoint.c | 4 ++++
gdb/testsuite/gdb.base/ena-dis-br.exp | 5 +++++
2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2f2c625..5dcaa0e 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -14934,8 +14934,12 @@ do_map_enable_count_breakpoint (struct breakpoint *bpt, void *countptr)
static void
enable_count_command (char *args, int from_tty)
{
+ char *p = args;
int count = get_number (&args);

+ if (count == 0)
+ error (_("Bad count number '%s'"), p);
+
map_breakpoint_numbers (args, do_map_enable_count_breakpoint, &count);
}

diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index 6f2c469..4b83e56 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -169,6 +169,11 @@ gdb_test "continue" \
".*marker1 .*:($bp_location15|$bp_location16).*" \
"continue through enable count, now disabled"

+# Test enable count with bad count number.
+
+gdb_test "enable count 1.1 $bp" "Bad count number '1.1 $bp'.*" \
+ "enable count with bad number"
+
# Verify that we can set a breakpoint with an ignore count N, which
# should cause the next N triggers of the bp to be ignored. (This is
# a flavor of enablement/disablement, after all.)
--
1.7.7.6