From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IbHqNAQqsGlrviEAWB0awg (envelope-from ) for ; Tue, 10 Mar 2026 10:26:12 -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=Gg0mpwHk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C8F451E0DD; Tue, 10 Mar 2026 10:26:12 -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 E11861E08D for ; Tue, 10 Mar 2026 10:26:11 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 5E1634B9DB5F for ; Tue, 10 Mar 2026 14:26:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E1634B9DB5F 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=Gg0mpwHk 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 7C5DC4BA2E08 for ; Tue, 10 Mar 2026 14:25:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7C5DC4BA2E08 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 7C5DC4BA2E08 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773152735; cv=none; b=IsAxWMB4jfkGlv5+ocMWRnr3ucI5fhQIexdoJgviQoFjFq8vNxreSqgRpBZ7rrbVKoY+EC5oqJg7c29WZRM/dGG36mKH9H+d3zOpvxOtYCfpu1Pn4stzbKvIDuJaalT7axFrM2fVfvbOmG0P2uPXLsahgQH4wcnLaW0/hoTgP3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773152735; c=relaxed/simple; bh=F57rDaJ7/wbECGZZlZ1NN2X1VURSTRgKqYxv7Rpf2dQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=luAgq2tewH+0aJsHwrCSP6Z85em7UFhmH8Qhq0W2AQYTyPa5nLmua3B+OzzfZOKk/Yid8GU5i2iG8abvUwENAcLMtIr1XuYZd6aI2fNJNOD34x1DYdjE/0sWfhbPVfeqQYzPTAFFJU5xuw0NEfgEPpKeAb3Fd7rqwJ6676OFp2A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C5DC4BA2E08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773152735; 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=P4ydkP8pjAnAcGS9REIqi74q/w76UmUr1ch7AGtrSJ0=; b=Gg0mpwHkczvQyS01QjymI2XH/qvx2B4JnukANunLZlyEpDhnf6FMfYlQUB1Ppg0SZRJUup UguKaImDWuhXTgJZWFOTmuyOX0GZ1QM505klKl7KLH+DsBxQclr+Kt4pbKbzpWGJ4fKO5T KlGdZFyvkmn4MHBdjpDfLXDCbIdR7SA= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-04YfPibpMJWY5FqOVLQxfQ-1; Tue, 10 Mar 2026 10:25:34 -0400 X-MC-Unique: 04YfPibpMJWY5FqOVLQxfQ-1 X-Mimecast-MFC-AGG-ID: 04YfPibpMJWY5FqOVLQxfQ_1773152733 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B84C180AA9B; Tue, 10 Mar 2026 14:25:28 +0000 (UTC) Received: from fedora.tailb97d54.ts.net (unknown [10.96.134.165]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 676051955D71; Tue, 10 Mar 2026 14:25:25 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen , Ciaran Woodward Subject: [PATCH v5 1/2] gdb: improve help text for set commands with limited options Date: Tue, 10 Mar 2026 11:23:23 -0300 Message-ID: <20260310142323.2619350-3-guinevere@redhat.com> In-Reply-To: <20260310142323.2619350-2-guinevere@redhat.com> References: <20260310142323.2619350-2-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: FuKiesFqZ1trw0ci0HvCGRqQ-DYdr6FoeRD5vFVnKPA_1773152733 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 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) + { + expander.wrap_here (2); + gdb_printf (&expander, "%s, ", *opt); + opt++; + } + } } 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