Message ID | 423dd71ea44c518a22cfaf09b8dd5e9932cbf922.1744549721.git.aburgess@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 26B2B3858C78 for <patchwork@sourceware.org>; Sun, 13 Apr 2025 13:09:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26B2B3858C78 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=el58BVXw X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 5FB923858D29 for <gdb-patches@sourceware.org>; Sun, 13 Apr 2025 13:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FB923858D29 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5FB923858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744549733; cv=none; b=N1iGgAkkmlsSN2EYotolnmCcVLFq5ey02eqQAL0ZsqHO4su7gvvGKzTjN0xPE4UelWG8oT2KeaoW6MpWU9o4K0Ar3Orgl0wnvKT4Bvqc7oQ8XKJyuFxGndWQe+0kX85xZsV4iknTIcbcOJr4R0X2JShyyHMlrG5+SBqDnwze9c4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744549733; c=relaxed/simple; bh=/530GOWFb9ZoyFpB2LmZLNM5sxo2qFoq1LuSgdSATbg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rnOfvc2HOsSkzpwTtwLHpEhO/5WF0BQtD2JPZuaJmvbHqFMvUcAYFh4zSjC4UeooEtGNBF6fJFpZdZnhQudKrhz/GSFyncf0zrzgv66qa16bH8zRHsop2/sV67bOZDH/lSWMKXd9CeYfjbmUqJrYxdVtKchQxQt9HvgN525y8tI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FB923858D29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744549733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ULu1svW2oDoMZPMzXBKYe2vrYBdBn99U9Rne+zyJ1DU=; b=el58BVXwvNQ0dDKY/YkCI4gPlD+INJxOJi/Hz4o1CtN2R9RI+p/O3SBUoK1w3VcL2SBCQy 4yU7gNzMlkzX6Da+ZYKZtfcwhcI1DeIS6K7e0HV/lg8G+/HIts5NmXQ6g/uE54N9sKcY4f kk6bY/SQTRzslgZYGbNWQ4iXWKa+wlY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-2njdB3g6NCuLdsMGt-lx8g-1; Sun, 13 Apr 2025 09:08:50 -0400 X-MC-Unique: 2njdB3g6NCuLdsMGt-lx8g-1 X-Mimecast-MFC-AGG-ID: 2njdB3g6NCuLdsMGt-lx8g_1744549729 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43cf172ffe1so29733645e9.3 for <gdb-patches@sourceware.org>; Sun, 13 Apr 2025 06:08:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744549728; x=1745154528; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ULu1svW2oDoMZPMzXBKYe2vrYBdBn99U9Rne+zyJ1DU=; b=NZ9XjvmU41oETBGiw7UX5T93U0JlUIvleraZ9KxD2vxUaguoAQdu0hJ7Cyn3hcxrxv ZvNrzms+1+yhCkmGK7WDZTaZFbPbU4m1H5LqjTGweuj6wW6GJUj/4cBkacHnNrog9Jjp DtEY7izgvLKPXMQUPZjk4JZjWVikemSCNvpvwoOr/z9xTEjsJJw2Z6ccggJwdESARZWv Mi5L/FWETiKjLmVZG5j244XJgHkL2h+O3iNCudg2sD5FJB1k25dj6rqsk8mVxdatvT7B be4AdV7tuiexvuE0SNU8E2Ld05d+L86/8kj/HdZtHAMA7X5l5/WdwnyKYs/xV8eapJZp 7K5g== X-Gm-Message-State: AOJu0Yxzli9s4G7vsd2RNe++toIFaExLdWwO9RbcUoSP39UhKh0xZ2Fo L4iX0OlVWp+27jjcXsRS0zYFFX7jGYaRmyrylJkDRgSpijC5CPUSgB2RVKOozfKBmNtP7DNaYBX t5LWdnzc4XYQy9Kflqjx6i+XkuZi08ZCkh+ejj9oO39mf9wLqEd/M8zX0b8yNKEMNhQBMTKo3tN 9SCYh9P/maJzYs9C5r4zWWE64xSXHPWrHPF3yGEtkN7q8= X-Gm-Gg: ASbGncsAz1nxXgOcErq2q+AV3IrprRYzkhiyRjCbw3o69TuP44cffVrIYGPLESd4xor tI9rKRpXw0YepCk4waPsUfAH2rMQC7t/jrZyuR2WLXyf3ocxheG9nNpb7xuce1g7X4qMZkZjqbF VqZW6V31Wo3X2RjzSfX4mxU1XL/MoPrVoRJkKcoGo/I1O4I0m4/y05d8D8h2+mGemQPaqAUNcSK V5AfLOmadlbKJ3i43P/f7MNdW/jyqf21zgGF5mjxRiSwKeQajDiSenYq5M1zhzRyuN2nzUqEQ7R 9H0xfCgTQt7MXcS7a+P1tezNZUtSHW2auxHk X-Received: by 2002:a05:600c:458b:b0:43c:fc0c:7f33 with SMTP id 5b1f17b1804b1-43f3a925f6amr78995725e9.2.1744549728066; Sun, 13 Apr 2025 06:08:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnL32yHb+vuo+v5ba8empn9l/pYkUIk0WlHQ+ghJGpbX3DVY34qeuWd8IxNIV/YAPBtnBaPQ== X-Received: by 2002:a05:600c:458b:b0:43c:fc0c:7f33 with SMTP id 5b1f17b1804b1-43f3a925f6amr78995515e9.2.1744549727495; Sun, 13 Apr 2025 06:08:47 -0700 (PDT) Received: from localhost (30.226.159.143.dyn.plus.net. [143.159.226.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39eae96c03dsm7724892f8f.24.2025.04.13.06.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Apr 2025 06:08:47 -0700 (PDT) From: Andrew Burgess <aburgess@redhat.com> To: gdb-patches@sourceware.org Cc: Andrew Burgess <aburgess@redhat.com> Subject: [PATCH] gdb: add an assert to cmd_list_element constructor Date: Sun, 13 Apr 2025 14:08:45 +0100 Message-ID: <423dd71ea44c518a22cfaf09b8dd5e9932cbf922.1744549721.git.aburgess@redhat.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: y9qXNQuqOaEuEyY1T8CvGNub0lkjqfwrBBRPC7pDiw0_1744549729 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
Series |
gdb: add an assert to cmd_list_element constructor
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | fail | Patch failed to apply |
linaro-tcwg-bot/tcwg_gdb_build--master-arm | fail | Patch failed to apply |
Commit Message
Andrew Burgess
April 13, 2025, 1:08 p.m. UTC
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(+) base-commit: 33d5188ab101bf414c9950ba914a128d08166105
Comments
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.marchi@efficios.com> Simon
Simon Marchi <simark@simark.ca> writes: > 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? Good idea. I've added this assert, and (after some testing) pushed the patch. Thanks, Andrew > > LGTM in any case. > > Approved-By: Simon Marchi <simon.marchi@efficios.com>
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)); }