From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id x42IBKMiil/MdwAAWB0awg (envelope-from ) for ; Fri, 16 Oct 2020 18:45:55 -0400 Received: by simark.ca (Postfix, from userid 112) id 059EE1EF79; Fri, 16 Oct 2020 18:45:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 631221E99A for ; Fri, 16 Oct 2020 18:45:54 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 098473857C6C; Fri, 16 Oct 2020 22:45:54 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id DED973857839 for ; Fri, 16 Oct 2020 22:45:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DED973857839 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 8695E1E58C; Fri, 16 Oct 2020 18:45:51 -0400 (EDT) Subject: Re: [PATCH v4 2/2] gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition To: Tankut Baris Aktemur , gdb-patches@sourceware.org References: From: Simon Marchi Message-ID: Date: Fri, 16 Oct 2020 18:45:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" I don't have time to review this in as much depth as I'd like, but I took a quick look at the code and tested the user experience, and it looks good to me. If nobody else has anything to add in ~1 week from now, I'm fine with you merging this. Some small comments below: On 2020-10-13 8:25 a.m., Tankut Baris Aktemur via Gdb-patches wrote: > @@ -950,9 +950,11 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, > catch (const gdb_exception_error &e) > { > /* Condition string is invalid. If this happens to > - be the last loc, abandon. */ > + be the last loc, abandon (if not forced) or continue > + (if forced). */ > if (loc->next == nullptr) > - throw; > + if (!force) > + throw; Either do if (loc->next == nullptr && !force) throw; ... or add braces to the outer if. > } > } > > @@ -1032,6 +1034,18 @@ condition_command (const char *arg, int from_tty) > error_no_arg (_("breakpoint number")); > > p = arg; > + > + /* Check if the "-force" flag was passed. */ > + bool force = false; > + const char *tok = skip_spaces (p); > + const char *end_tok = skip_to_space (tok); > + int toklen = end_tok - tok; > + if (toklen >= 1 && strncmp (tok, "-force", toklen) == 0) > + { > + force = true; > + p = end_tok + 1; > + } > + Is there a chance you could use the gdb::option framework here? That should give tab-completion for free, in addition to simplify the parsing. I've never used it myself, so I don't know for sure it applies here, but it's worth checking. Simon