From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fr+BHtTA+2fybzIAWB0awg (envelope-from ) for ; Sun, 13 Apr 2025 09:49:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1744552148; bh=JfofejamyLIjTBmBRbsnfRPzqhGgt70qlrxWYsBhQcE=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dtXMI0b/bSh85zZzI7LhDMTp4fOOGwqiecB35SFNC61Kb7bSRa7tLrkSmE1Ji3NJG VAuLQul6cRUCOWwFVS1ABYCU1mXuOASlgA5uqJJ6Cek7maP5o+Ucq1+KFzX6UmnK7n E35bF/XOTmNmSJb7fF7096rfCM7cpTwjtUuCidFA= Received: by simark.ca (Postfix, from userid 112) id 6C87C1E0C3; Sun, 13 Apr 2025 09:49:08 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=iKRZntQD; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=nStYant3; dkim-atps=neutral Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E68581E05C for ; Sun, 13 Apr 2025 09:49:07 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6ECA83858D33 for ; Sun, 13 Apr 2025 13:49:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6ECA83858D33 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=iKRZntQD; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=nStYant3 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 0A48E3858D29 for ; Sun, 13 Apr 2025 13:48:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A48E3858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A48E3858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744552116; cv=none; b=ObUte1Cbd0LgAg/pRPPVXWdSKUuH1Z9RGs1XwlqG3L+JFhySN/YOhA62/ckNwGYzqpt39xa87t04FCg5vx3q4pqVtVdTl6mIYtlFag19i3WpPd48fpFAPL9UczNb4ItdHTmpOJEk36P+RLsbXzCTlLO5GXgSDhGwA03tAmY9lL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744552116; c=relaxed/simple; bh=JfofejamyLIjTBmBRbsnfRPzqhGgt70qlrxWYsBhQcE=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=Jcge8Tz5TcBg2LDPeZyHG2nZC/wVuh/MzAwAfIjaPdr2R4MINXCKDpOrzVnGCDxiLsVRPEZt8YQLHFbhGPTMAz+nFgPfm3Y9eiUJEXieQUBDrTdAbuLLaLwuiDPJvbNvfOYFv1kAiA/rwuAOIR9TK33GzHTbn4ll7Hy4ooUXOXM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A48E3858D29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1744552115; bh=JfofejamyLIjTBmBRbsnfRPzqhGgt70qlrxWYsBhQcE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=iKRZntQDehXxOg3PKyt7R4pKtbEFNf8wrKniFWoGKBARa+R6MIMRru5qFgPEnsrE2 49LqAxqyeK2VZb+0PNxpjzzTRumRtCAj+EOk7eBB8j0Z2gHiiyksKdfGe5emUX9TCV w9sVfCc5SQlPKKyvEb1Pr5A3u8XQNGzPGvQpVQ9w= Received: by simark.ca (Postfix, from userid 112) id 3347B1E0C3; Sun, 13 Apr 2025 09:48:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1744552114; bh=JfofejamyLIjTBmBRbsnfRPzqhGgt70qlrxWYsBhQcE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=nStYant3S7NUvAK7BCVbU5Cm8R9nFaa7cFe4/zwO9wxMriF04h6UsF7C45Bi/eq4L 63BCXoiZy6doiD7eokS5G8Gy5gMZ26oVAJceq6YAVGhndtE5i3K5Ea2JL1OejrwbJT w9BBpj3WnmdTBqWqZOVVQcLqn4gIsZmRb8fgJizE= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 77F431E05C; Sun, 13 Apr 2025 09:48:34 -0400 (EDT) Message-ID: <44fd10ba-0696-489f-b05b-b8f41c1496d4@simark.ca> Date: Sun, 13 Apr 2025 09:48:34 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: add an assert to cmd_list_element constructor To: Andrew Burgess , gdb-patches@sourceware.org References: <423dd71ea44c518a22cfaf09b8dd5e9932cbf922.1744549721.git.aburgess@redhat.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <423dd71ea44c518a22cfaf09b8dd5e9932cbf922.1744549721.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2025-04-13 09:08, Andrew Burgess wrote: > The cmd_list_element::doc variable must be non-nullptr, otherwise, in > `help_cmd` (cli/cli-decode.c), we will trigger an assert when we run > one of these lines: > > gdb_puts (c->doc, stream); > > or, > > gdb_puts (alias->doc, stream); > > as gdb_puts requires that the first argument (the doc string) be > non-nullptr. > > Better, I think, to assert when the cmd_list_element is created, > rather than catching an assert later when 'help CMD' is used. > > I only ran into this case when messing with the Python API command > creation code, I accidentally created a command with a nullptr doc > string, and only found out when I ran 'help CMD' and got an > assertion. > > Built and tested on x86-64 GNU/Linux with an all-targets build; I > don't see any regressions, so (I hope) there are no commands that > currently violate this assertion. > --- > gdb/cli/cli-decode.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h > index 217afbc8ca7..673cf6518d3 100644 > --- a/gdb/cli/cli-decode.h > +++ b/gdb/cli/cli-decode.h > @@ -62,6 +62,7 @@ struct cmd_list_element > type (not_set_cmd), > doc (doc_) > { > + gdb_assert (doc != nullptr); > memset (&function, 0, sizeof (function)); > } > > > base-commit: 33d5188ab101bf414c9950ba914a128d08166105 Would it make sense to add an assert that `name` isn't nullptr at the same time? LGTM in any case. Approved-By: Simon Marchi Simon