From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KTsZEP41AmrSqzAAWB0awg (envelope-from ) for ; Mon, 11 May 2026 16:03:10 -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=LGfdhSzT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 33F6D1E0C3; Mon, 11 May 2026 16:03:10 -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_MSPIKE_H2,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 0FBAE1E067 for ; Mon, 11 May 2026 16:03:09 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FE9F4BB58A0 for ; Mon, 11 May 2026 20:03:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FE9F4BB58A0 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=LGfdhSzT Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 7F3454B99F5F for ; Mon, 11 May 2026 20:02:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F3454B99F5F 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 7F3454B99F5F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778529753; cv=none; b=l8bfqNwT/9mYOjLxonYI9DmID5Hk7RzHbr0BmOX7N62hMfMlNrs5bUJERfG0HL9KDMx1at/tnbMyGjpc884KBI1i8VhjUw+jgIeDDwhhW5AS679kI6YY3q4vRUOeaPm222DApGoYUwvwfvNR41Qqr9rndb1v6zqjV1PmlZXt0cE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778529753; c=relaxed/simple; bh=ICF+cxQxtJIJiFXNXUuwEADzb89GXubvHCUzRWpfHWI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oxrIMhxmCe4Z+WAvqIvHChn2msQYfbnrdiJAGHmQqguZjA2adRrJsjD2yqy5rOySrMq2vgFeBtKGWuThMnODGKPYfIM1CkDTMqURJ2cgChfIvbK82kXjWIrLxdhb7ALZ5o24Yle3stbU8iQkZg9jvSvNT66eZ8cGJR7q+sYt8Q0= ARC-Authentication-Results: i=1; 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=LGfdhSzT DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F3454B99F5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778529753; 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: in-reply-to:in-reply-to:references:references; bh=0ZpwmkjAEOqTij7PyGYumDDLvKj6kE+1krRdIVWBXfg=; b=LGfdhSzTLpDLNe73IneaniJ85xnMlrL4dxjUc0+YEL+cGoRFSVKOz0eJEikWD8awnRNIUm jPuW6GbN0lXIToTAYeOWdIGyCzW8ENyBQ+TvQVVRXeI7VqE7CmMTxB5IaOGnUXdFG978wl xMmgVfEAMH6pOILt+u0X3i7w/HmNQxc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-549-XlfHjeSSOkKUJBBaYEj_AA-1; Mon, 11 May 2026 16:02:31 -0400 X-MC-Unique: XlfHjeSSOkKUJBBaYEj_AA-1 X-Mimecast-MFC-AGG-ID: XlfHjeSSOkKUJBBaYEj_AA_1778529750 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6847619560AD; Mon, 11 May 2026 20:02:30 +0000 (UTC) Received: from fedora.tailb97d54.ts.net (unknown [10.96.134.67]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B858F19560A2; Mon, 11 May 2026 20:02:27 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen , Ciaran Woodward Subject: [PATCH v6 1/2] gdb: improve help text for set commands with limited options Date: Mon, 11 May 2026 17:01:25 -0300 Message-ID: <20260511200126.75554-2-guinevere@redhat.com> In-Reply-To: <20260511200126.75554-1-guinevere@redhat.com> References: <20260511200126.75554-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: h4RnCKsPZzQzS4zAuIKcY-bFp7LaD9LQJXe6Ns37dfs_1778529750 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 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. 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 de40faeed59..928c476eaaf 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1875,6 +1875,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); + gdb_printf (&expander, " "); + for (const char * const *opt = c->enums; + *opt != nullptr; opt ++) + { + 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..9512523c1df 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..4692ac44624 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..e8cecf5ca43 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.54.0