From patchwork Thu Oct 26 15:25:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23852 Received: (qmail 2248 invoked by alias); 26 Oct 2017 15:25:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 2159 invoked by uid 89); 26 Oct 2017 15:25:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Oct 2017 15:25:40 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1F425F7B5 for ; Thu, 26 Oct 2017 15:25:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C1F425F7B5 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 373427F5FD for ; Thu, 26 Oct 2017 15:25:38 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v5 2/4] Breakpoint location parsing: always error instead of warning Date: Thu, 26 Oct 2017 16:25:33 +0100 Message-Id: <1509031535-17778-3-git-send-email-palves@redhat.com> In-Reply-To: <1509031535-17778-1-git-send-email-palves@redhat.com> References: <1509031535-17778-1-git-send-email-palves@redhat.com> 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: yyyy-mm-dd 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: yyyy-mm-dd Pedro Alves * gdb.base/ena-dis-br.exp: Don't expect "warning:". --- gdb/breakpoint.c | 47 ++++++++++++++--------------------- gdb/testsuite/gdb.base/ena-dis-br.exp | 6 ++--- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 2c5a3a4..43a7d87 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -14255,7 +14255,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) @@ -14297,10 +14297,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; } } @@ -14324,10 +14321,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; @@ -14336,8 +14330,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 @@ -14438,24 +14430,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/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index 9b8d251..2bbb734 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"