From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32422 invoked by alias); 3 Nov 2017 19:07:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 32341 invoked by uid 89); 3 Nov 2017 19:07:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.224) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 19:07:51 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway22.websitewelcome.com (Postfix) with ESMTP id C81F4D668 for ; Fri, 3 Nov 2017 14:07:49 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id AhJleaAgjDL8rAhJlePIO0; Fri, 03 Nov 2017 14:07:49 -0500 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:51150 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eAhJl-00180k-KB; Fri, 03 Nov 2017 14:07:49 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Fix regression in "commands" Date: Fri, 03 Nov 2017 19:07:00 -0000 Message-Id: <20171103190747.389-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eAhJl-00180k-KB X-Source-Sender: 71-218-90-63.hlrn.qwest.net (pokyo.Home) [71.218.90.63]:51150 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2017-11/txt/msg00088.txt.bz2 Pedro pointed out a regression in "commands", where trying to clear a breakpoint's command list would fail: (top-gdb) commands Type commands for breakpoint(s) 3, one per line. End with a line saying just "end". >end No breakpoints specified. (top-gdb) I believe the bug was introduced by my patch that changes counted_command_line to be a shared_ptr. This causes the problem because now the counted_command_line in commands_command_1 can be NULL, whereas previously it never could be. The fix here is to track whether commands have been read using a separate flag. 2017-11-03 Tom Tromey * breakpoint.c (commands_command_1): Use a flag to track whether commands have been read. 2017-11-03 Tom Tromey * gdb.base/break.exp: Add test for empty "commands". --- gdb/ChangeLog | 5 +++++ gdb/breakpoint.c | 7 +++++-- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/break.exp | 5 +++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1f823ca..0dc20bf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-11-03 Tom Tromey + + * breakpoint.c (commands_command_1): Use a flag to track whether + commands have been read. + 2017-11-03 Ulrich Weigand * doublest.c (convert_doublest_to_floatformat): Fix uninitialized diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 0bf47d5..609f1ed 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1255,6 +1255,7 @@ commands_command_1 (const char *arg, int from_tty, struct command_line *control) { counted_command_line cmd; + bool read_commands = false; std::string new_arg; @@ -1271,7 +1272,7 @@ commands_command_1 (const char *arg, int from_tty, map_breakpoint_numbers (arg, [&] (breakpoint *b) { - if (cmd == NULL) + if (!read_commands) { if (control != NULL) cmd = copy_command_lines (control->body_list[0]); @@ -1288,6 +1289,8 @@ commands_command_1 (const char *arg, int from_tty, ? check_tracepoint_command : 0), b); } + + read_commands = true; } /* If a breakpoint was on the list more than once, we don't need to @@ -1300,7 +1303,7 @@ commands_command_1 (const char *arg, int from_tty, } }); - if (cmd == NULL) + if (!read_commands) error (_("No breakpoints specified.")); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 158fea4..e82d2b9 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-03 Tom Tromey + + * gdb.base/break.exp: Add test for empty "commands". + 2017-11-03 Yao Qi * gdb.mi/list-thread-groups-available.exp: Skip it if XML parsing diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index 96e2f35..604d957 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -854,3 +854,8 @@ gdb_test_no_output "set \$foo=81.5" \ gdb_test "break $srcfile:\$foo" \ "Convenience variables used in line specs must have integer values.*" \ "set breakpoint via non-integer convenience variable disallowed" + + +# Test that commands can be cleared without error. +gdb_test "commands\nend" ">end" "clear breakpoint commands" + -- 2.9.5