From patchwork Sun Aug 26 15:47:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 29052 Received: (qmail 126275 invoked by alias); 26 Aug 2018 15:47:22 -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 126245 invoked by uid 89); 26 Aug 2018 15:47:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1763 X-HELO: mailsec113.isp.belgacom.be Received: from mailsec113.isp.belgacom.be (HELO mailsec113.isp.belgacom.be) (195.238.20.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Aug 2018 15:47:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1535298441; x=1566834441; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=9mSwUAUG8JnZqReUIpPShEO0/J3fi05ujaoiMMYHznA=; b=Py2vT9XKOksUIx47/cF5GjJjQDICvyNQihFyu/pO97SE6yrI0eXsc43e 04Qbh7EHFFqJOHtrXTZa+VxunykSxQ==; Received: from 217.24-133-109.adsl-dyn.isp.belgacom.be (HELO md.home) ([109.133.24.217]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 26 Aug 2018 17:47:18 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFAv2 1/2] Fix regression for multi breakpoints command line clearing. Date: Sun, 26 Aug 2018 17:47:07 +0200 Message-Id: <20180826154708.28601-2-philippe.waroquiers@skynet.be> In-Reply-To: <20180826154708.28601-1-philippe.waroquiers@skynet.be> References: <20180826154708.28601-1-philippe.waroquiers@skynet.be> X-IsSubscribed: yes breakpoint.c is modified to fix the regression introduced when clearing the commands of several breakpoints by giving an empty list of commands, by just typing "end". GDB should read an empty list of command once, but it reads it for each breakpoint, as an empty list of command is NULL, and NULL is interpreted as 'not having read the command list yet'. The fix consists in having a boolean set to true once the command list has been read. gdb/ChangeLog 2018-08-26 Philippe Waroquiers * breakpoint.c (commands_command_1): New boolean cmd_read to detect cmd was already read. --- gdb/breakpoint.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8f0feaa474..4e7dac5157 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1219,6 +1219,10 @@ commands_command_1 (const char *arg, int from_tty, struct command_line *control) { counted_command_line cmd; + /* cmd_read will be true once we have read cmd. Note that cmd might still be + NULL after the call to read_command_lines if the user provides an empty + list of command by just typing "end". */ + bool cmd_read = false; std::string new_arg; @@ -1235,8 +1239,9 @@ commands_command_1 (const char *arg, int from_tty, map_breakpoint_numbers (arg, [&] (breakpoint *b) { - if (cmd == NULL) + if (!cmd_read) { + gdb_assert (cmd == NULL); if (control != NULL) cmd = control->body_list_0; else @@ -1256,6 +1261,7 @@ commands_command_1 (const char *arg, int from_tty, cmd = read_command_lines (str.c_str (), from_tty, 1, validator); } + cmd_read = true; } /* If a breakpoint was on the list more than once, we don't need to