From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1aLFEk1euWnzgS0AWB0awg (envelope-from ) for ; Tue, 17 Mar 2026 09:59:41 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LH2C2IEt; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2E7101E0BC; Tue, 17 Mar 2026 09:59:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 306DD1E08C for ; Tue, 17 Mar 2026 09:59:40 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 9F6034CCCA15 for ; Tue, 17 Mar 2026 13:59:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F6034CCCA15 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=LH2C2IEt 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 9207C4B19699 for ; Tue, 17 Mar 2026 13:58:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9207C4B19699 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 9207C4B19699 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=1773755937; cv=none; b=HIHB+iSkKfjZ0JMJklNTdU4h97p/57M2UzJx42tgWf8medW20LxX9TY1FJhe2WF7Sn9gAGKwTbTat5CUrrqgqnBh9pxg3wk9Kum7J7e2iWQD+cgXfgNZnKiqVmZskqzQAqCRCH3UUA/7/J9YQZC/DEE4z60+edf5vmwav5FzLu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773755937; c=relaxed/simple; bh=bmIxPinjhjQpGeEej5hz75sFOyrvcu0QEjUmMNa0Z/8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=L1YH15Dq/alk/uEUZiE8+COGgH78NUSd3m6JiHqOIxCE9hi1PoiUUNQUKU13XwkT+3LRH7CGr7ZHtkiVMSjdhJfV9iQb74qbgmomppuwVSnb6Yn6I96Al1qjgxGMsn/vdv4mKqI1qANbDJoZEyE9SR/aci2dmc89RSxNFke7A+8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9207C4B19699 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773755937; 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: in-reply-to:in-reply-to:references:references; bh=NCexoZz6kf/8fP7rQN3i+w0wtt8W9ZYQRD+xqVyOLwk=; b=LH2C2IEt7IM+XWZxmpdx7G/nUOeBpeyUtVssbKZMxUKL23vwFWkQlErGQndL7TZl0uOFSV T+uu7+YBFqNqTt5n2q5IDYF+DwP4Tojh+3SCmy6e++EDq2ycLzu5t5Z5oTynrsq5qut9SQ rP5wX09BStn+AIyBMXiXAmAZEDjgaUo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-bQeUndsQPKe6fCqkFq-h-w-1; Tue, 17 Mar 2026 09:58:54 -0400 X-MC-Unique: bQeUndsQPKe6fCqkFq-h-w-1 X-Mimecast-MFC-AGG-ID: bQeUndsQPKe6fCqkFq-h-w_1773755933 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-48539bda3dcso62114835e9.2 for ; Tue, 17 Mar 2026 06:58:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773755932; x=1774360732; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NCexoZz6kf/8fP7rQN3i+w0wtt8W9ZYQRD+xqVyOLwk=; b=ikS3oGZs3X+Va8HcEqdVnm1DJQdD/8l/0aQP07fpcseTgulHgrAnkDEisodfNa5EGr C2V58iQBa7KHYH9SavEUR6BPXpUTX8nU6h8T5qZy2436+7mYqdlGya+UiTLPl6iUgI+p 7wNT1BnzAUX0xhb2ZNaNbjsyQcTutSzLrmj+0899yvmSt5xQ0abOV8v3jsc+voFZOLRB FxMzMrQ3rFLQbT9Dw49uDB2w7+kVxoVimtlatkAi+YTQLGxU5AT0s5RM0PH1eie+CMdK 0GOVFo0NKsoVrn3pzwgrgdabWYLxy9XGIc435GdOMMWayR4X7Bupz3bpeaCTJVtCTIcm VhXw== X-Forwarded-Encrypted: i=1; AJvYcCWmNA08ZWmzID/r30HPhS3d5ZEyzcG/dmd56z9F6htK8Ixs4tLW6YnEjgMNwDuiqjAQjg7IACPTWP5qMA==@sourceware.org X-Gm-Message-State: AOJu0YzfESyH/AlEPezaWWyjYF4BgU95Bc5h7tmq68V2zRKTeY40vzng R+VOA0yhChgPkcqbxcKy82dviwwNY2fSIixrYlp/jMTQZs6NiFF7PRK3lRhhhXdwvkEIFcfFNz3 yc0mFxzNhnKEP5pPG9VNMCY+zh4kJmYXbkO5FurhN2+I4HkNTHArW8jYBFoT5+uXZwRudJAg= X-Gm-Gg: ATEYQzyPlaYB/5stQ2Rxf+OdyecZNmULnIXLXh51hjMuQEcHfkqTxuYmyMrbxeEZSff 0we+kYqdOXZkzOJl+WU6ZFqLw+SnP+vfRqI94JbwGlsqPRu6vKLn7NsYuC+oFA5U4H2dFDv8jcW Ks/kiLzvBRJA91zxu9lUsMTkgeSEIdt52gt+oJwS986h0h5wDKn2K260MnWfCiFMaAwCJIgPNlk FLAIlnNudhu3E6L/qHIG2j1uC9CHApYUHnW/jCKW9SyDrZYwMJ2ggR03jboTNaE6VRkkp66O4TC L3w7KPOiO3y6Ws0mopXlvuh/+mr+5DzBdBTcXvUuXHHIWXVuPIg8mQEUmGLPy+m3bYWhwGAJKHu oV+6YpoaLhzqVYaGf X-Received: by 2002:a05:600c:3b16:b0:480:69b6:dfed with SMTP id 5b1f17b1804b1-4855671e83bmr291267955e9.24.1773755932209; Tue, 17 Mar 2026 06:58:52 -0700 (PDT) X-Received: by 2002:a05:600c:3b16:b0:480:69b6:dfed with SMTP id 5b1f17b1804b1-4855671e83bmr291267305e9.24.1773755931664; Tue, 17 Mar 2026 06:58:51 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48557c89186sm297666575e9.1.2026.03.17.06.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 06:58:51 -0700 (PDT) From: Andrew Burgess To: Guinevere Larsen , gdb-patches@sourceware.org Cc: Guinevere Larsen , Ciaran Woodward Subject: Re: [PATCH v5 1/2] gdb: improve help text for set commands with limited options In-Reply-To: <20260310142323.2619350-3-guinevere@redhat.com> References: <20260310142323.2619350-2-guinevere@redhat.com> <20260310142323.2619350-3-guinevere@redhat.com> Date: Tue, 17 Mar 2026 13:58:50 +0000 Message-ID: <87bjgm7e1x.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eDVnfbxi0TP1-M_uHxNbJNNScKfELYi2_9jHyRkYVJw_1773755933 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Guinevere Larsen writes: > Some "set" commands only allow a select few options, such as the "set > architecture" command, however, there is no way for a user to know which > options are allowed without trying to set something and getting an > error. This commit improves the situation by making the help command list > all the available options. I was experimenting with this patch looking at how other enum set commands, checking that their output also looks good with this new feature, and I ran into 'help set demangle-style'. It's output (before this patch) is: (gdb) help set demangle-style Set the current C++ demangling style. Use `set demangle-style' without arguments for a list of demangling styles. And indeed: (gdb) set demangle-style Requires an argument. Valid arguments are none, auto, gnu-v3, java, gnat, dlang, rust. And: (gdb) set architecture Requires an argument. Valid arguments are ARC600, A6, ARC601, ARC700, A7, ... etc ... So there is an existing way to get an option list. Maybe what's missing here is that most enum command help texts don't reference this mechanism. What if, instead of listing all the options, which can get pretty long, you auto-added a sentence similar to the one seen in the demangle-style output? E.g. "Use `set ` without arguments for a list of available options." This would keep the help text less cluttered, but would give clear guidance on how to get the option list. Just my thoughts. Thanks, Andrew > > Reviewed-By: Ciaran Woodward > --- > gdb/cli/cli-decode.c | 12 ++++++++++++ > gdb/testsuite/gdb.base/help.exp | 9 +++++++++ > gdb/testsuite/gdb.python/py-doc-reformat.exp | 2 +- > gdb/testsuite/gdb.python/py-parameter.exp | 17 +++++++++++++---- > 4 files changed, 35 insertions(+), 5 deletions(-) > > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > index 285f5f1f0c4..5a580387fee 100644 > --- a/gdb/cli/cli-decode.c > +++ b/gdb/cli/cli-decode.c > @@ -1876,6 +1876,18 @@ help_cmd (const char *command, struct ui_file *stream) > /* Be sure to expand TABs in the documentation. */ > tab_expansion_file expander (stream); > gdb_puts (c->doc, &expander); > + if (c->enums != nullptr) > + { > + gdb_puts ("\nAvailable options are:\n", &expander); > + const char * const *opt = c->enums; > + gdb_printf (&expander, " "); > + while (opt != nullptr && *opt != nullptr) The 'opt != nullptr' check here seems redundant. We already check 'c->enums != nullptr' before entering this block, and I think if 'opt++' causes us to reach nullptr then things have probably gone seriously wrong. You could fold the setup of 'opt', the condition check, and the increment into a for loop like: for (const char * const *opt = c->enums; *opt != nullptr; opt++) { ... } > + { > + expander.wrap_here (2); > + gdb_printf (&expander, "%s, ", *opt); > + opt++; Given the simplified loop condition check, you could solve the trailing ', ' like: { expander.wrap_here (2); const char *suffix = (*(opt + 1) == nullptr) ? "." : ", "; gdb_printf (&expander, "%s%s", *opt, suffix); } > + } > + } > } > else > { > diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp > index a8c55721ef2..fca8522faa0 100644 > --- a/gdb/testsuite/gdb.base/help.exp > +++ b/gdb/testsuite/gdb.base/help.exp > @@ -174,3 +174,12 @@ gdb_test "help mybt" " alias mybt = backtrace \[\r\n\]+An alias of command backt > # Check pre-defined aliases cannot be documented. > gdb_test "document where" "Alias \"where\" is built-in.*" \ > "documenting builtin where alias disallowed" > + > +# Check help of a command with limited options lists all the options > +# as expected. The command "set breakpoint condition-evaluation" was > +# chosen because it has few options and isn't dependent on configure > +# options. > +gdb_test "help set breakpoint condition-evaluation" \ > + [multi_line ".*" \ > + "Available options are:" \ > + " auto, host, target, "] > diff --git a/gdb/testsuite/gdb.python/py-doc-reformat.exp b/gdb/testsuite/gdb.python/py-doc-reformat.exp > index 8b0a27f4937..a3c0b85c9e8 100644 > --- a/gdb/testsuite/gdb.python/py-doc-reformat.exp > +++ b/gdb/testsuite/gdb.python/py-doc-reformat.exp > @@ -126,7 +126,7 @@ proc test { input_docs expected_output } { > -re "^This is the set doc line\r\n" { > exp_continue > } > - -re "^$expected_output\r\n$::gdb_prompt $" { > + -re "^$expected_output\r\nAvailable options are:\r\n on, off, \r\n$::gdb_prompt $" { > pass $gdb_test_name > } > } > diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp > index e8b0ef24efb..aec00d527b2 100644 > --- a/gdb/testsuite/gdb.python/py-parameter.exp > +++ b/gdb/testsuite/gdb.python/py-parameter.exp > @@ -367,7 +367,10 @@ proc_with_prefix test_empty_doc_parameter {} { > # Setting the __doc__ string to empty means GDB will completely > # elide it from the output. > gdb_test "help set print test-empty-doc-param" \ > - "^Set the current value of 'print test-empty-doc-param'\\." > + [multi_line \ > + "^Set the current value of 'print test-empty-doc-param'\\." \ > + "Available options are:" \ > + " on, off, "] > > gdb_test_multiline "None __doc__ parameter" \ > "python" "" \ > @@ -384,7 +387,9 @@ proc_with_prefix test_empty_doc_parameter {} { > gdb_test "help set print test-none-doc-param" \ > [multi_line \ > "^Set the current value of 'print test-none-doc-param'\\." \ > - "This command is not documented\\."] > + "This command is not documented\\." \ > + "Available options are:" \ > + " on, off, "] > } > > # Test a parameter in which the set_doc/show_doc strings are either > @@ -406,7 +411,9 @@ proc_with_prefix test_empty_set_show_doc_parameter {} { > gdb_test "help set print test-empty-set-show-param" \ > [multi_line \ > "^Set the current value of 'print test-empty-set-show-param'\\." \ > - "This command is not documented\\."] > + "This command is not documented\\." \ > + "Available options are:" \ > + " on, off, "] > > gdb_test "help show print test-empty-set-show-param" \ > [multi_line \ > @@ -429,7 +436,9 @@ proc_with_prefix test_empty_set_show_doc_parameter {} { > gdb_test "help set print test-none-set-show-param" \ > [multi_line \ > "^Set the current value of 'print test-none-set-show-param'\\." \ > - "This command is not documented\\."] > + "This command is not documented\\." \ > + "Available options are:" \ > + " on, off, "] > > gdb_test "help show print test-none-set-show-param" \ > [multi_line \ > -- > 2.53.0