From: Pedro Alves Date: Tue, 7 Nov 2017 11:00:31 +0000 (+0000) Subject: Breakpoint location parsing: always error instead of warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cc638e867c240546b4dbc791761099d3ca5fe4a9;p=binutils-gdb.git Breakpoint location parsing: always error instead of warning It's odd that when parsing a breakpoint or location number, we error out in most cases, but warn in others. (gdb) disable 1- bad breakpoint number at or near: '1-' (gdb) disable -1 bad breakpoint number at or near: '-1' (gdb) disable .foo bad breakpoint number at or near: '.foo' (gdb) disable foo.1 Bad breakpoint number 'foo.1' (gdb) disable 1.foo warning: bad breakpoint number at or near '1.foo' This changes GDB to always error out. It required touching one testcase that expected the warning. gdb/ChangeLog: 2017-11-07 Pedro Alves * breakpoint.c (extract_bp_number_and_location): Change return type to void. Throw error instead of warning. (enable_disable_command): Adjust. gdb/testsuite/ChangeLog: 2017-11-07 Pedro Alves * gdb.base/ena-dis-br.exp: Don't expect "warning:". --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1770b1f02a8..5bac526f760 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-11-07 Pedro Alves + + * breakpoint.c (extract_bp_number_and_location): Change return + type to void. Throw error instead of warning. + (enable_disable_command): Adjust. + 2017-11-07 Xavier Roirand Pedro Alves diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e100f431913..a94a0d0ccc6 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -14225,7 +14225,7 @@ find_location_by_number (int bp_num, int loc_num) location number range. */ -static bool +static void extract_bp_number_and_location (const std::string &arg, std::pair &bp_num_range, std::pair &bp_loc_range) @@ -14267,10 +14267,7 @@ extract_bp_number_and_location (const std::string &arg, const char *ptls = bp_loc; bp_loc_range.first = get_number_trailer (&ptls, '\0'); if (bp_loc_range.first == 0) - { - warning (_("bad breakpoint number at or near '%s'"), arg.c_str ()); - return false; - } + error (_("bad breakpoint number at or near '%s'"), arg.c_str ()); bp_loc_range.second = bp_loc_range.first; } } @@ -14294,10 +14291,7 @@ extract_bp_number_and_location (const std::string &arg, const char *ptf = arg.c_str (); bp_num_range.first = get_number (&ptf); if (bp_num_range.first == 0) - { - warning (_("bad breakpoint number at or near '%s'"), arg.c_str ()); - return false; - } + error (_("bad breakpoint number at or near '%s'"), arg.c_str ()); bp_num_range.second = bp_num_range.first; } bp_loc_range.first = 0; @@ -14306,8 +14300,6 @@ extract_bp_number_and_location (const std::string &arg, if (bp_num_range.first == 0 || bp_num_range.second == 0) error (_("bad breakpoint number at or near: '%s'"), arg.c_str ()); - - return true; } /* Enable or disable a breakpoint location BP_NUM.LOC_NUM. ENABLE @@ -14408,24 +14400,23 @@ enable_disable_command (const char *args, int from_tty, bool enable) { std::pair bp_num_range, bp_loc_range; - if (extract_bp_number_and_location (num, bp_num_range, bp_loc_range)) + extract_bp_number_and_location (num, bp_num_range, bp_loc_range); + + if (bp_loc_range.first == bp_loc_range.second + && bp_loc_range.first == 0) { - if (bp_loc_range.first == bp_loc_range.second - && bp_loc_range.first == 0) - { - /* Handle breakpoint ids with formats 'x' or 'x-z'. */ - map_breakpoint_number_range (bp_num_range, - enable - ? enable_breakpoint - : disable_breakpoint); - } - else - { - /* Handle breakpoint ids with formats 'x.y' or - 'x.y-z'. */ - enable_disable_breakpoint_location_range - (bp_num_range.first, bp_loc_range, enable); - } + /* Handle breakpoint ids with formats 'x' or 'x-z'. */ + map_breakpoint_number_range (bp_num_range, + enable + ? enable_breakpoint + : disable_breakpoint); + } + else + { + /* Handle breakpoint ids with formats 'x.y' or + 'x.y-z'. */ + enable_disable_breakpoint_location_range + (bp_num_range.first, bp_loc_range, enable); } num = extract_arg (&args); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6468e52bec3..76bd960221a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-07 Pedro Alves + + * gdb.base/ena-dis-br.exp: Don't expect "warning:". + 2017-11-07 Xavier Roirand Pedro Alves diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index 9b8d2515572..2bbb734439f 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -395,10 +395,10 @@ proc test_ena_dis_br { what } { } } - # Now enable(disable) $b4.1 fooobaar and - # it should give warning on fooobaar. + # Now enable(disable) '$b4.1 fooobaar'. This should error on + # fooobaar. gdb_test "$what $b4.1 fooobaar" \ - "warning: bad breakpoint number at or near 'fooobaar'" \ + "bad breakpoint number at or near 'fooobaar'" \ "$what \$b4.1 fooobar" set test1 "${what}d \$b4.1"