From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 08BeCd4n4WkTqRwAWB0awg (envelope-from ) for ; Thu, 16 Apr 2026 14:18:06 -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=XbVQl5cq; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 014051E04F; Thu, 16 Apr 2026 14:18:05 -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 668ED1E04F for ; Thu, 16 Apr 2026 14:18:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D04854C900CA for ; Thu, 16 Apr 2026 18:18:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D04854C900CA 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=XbVQl5cq 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 76A9D4BA9028 for ; Thu, 16 Apr 2026 18:17:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 76A9D4BA9028 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 76A9D4BA9028 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=1776363457; cv=none; b=N1P9NYhK//jhpN0THxl8GH8hDx3WIGAbpWmWbNl3kqqBmdsLeurFfHke1TE9C1xL7Zxx69Hx5/esJ5RCfTrhyF8kyYVaL7xt6T62foprnJSkaiRVNmSfGXmA69wcVS/KcJoECM9LULWn2YRJ1utbZk0H0KPOum5O0OvLH8V4PkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776363457; c=relaxed/simple; bh=qvAzjtzYoE1B9A4IjiiUXPW1wK+jgIlOTOkMj+KAwIM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=j+wMDXoYaxCLgzlXYu2XRC46xuzhPmXyQEPh+9gGF3vWzRbAtWMSZ6hsffkg1KH77dQVEHu3b4QIZz4zdIzT5QcOwEso48ZyjBrFYAY5Hj46PIZpin0yY7d66hzhbzdH4C5k+W7Nwo6iKO+ejO5SvBZ+8A+w4k1sgd11W/JtZsE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76A9D4BA9028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776363457; 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=dziPu50qgBv9g5X0MMq171HDJ58L7QJJZqrMBcXThj4=; b=XbVQl5cqlH1NdiVydlIm6LJrF4k3gUiNbrJRgcv9N7hRTFhgIA2Bp5y627Hq6GqSWHLECM qfAFwhYc59DbolSEMOmlcI4IrcuNzBSwz/2k/Q/Vj1elko/zclbYTtdR3GBBZdqDHCBLXe 0xwpA3lNWPLuwCO3RYgSViLCpNsfhaM= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-QFz9wWdmP-CHeLRiIO2ABQ-1; Thu, 16 Apr 2026 14:17:35 -0400 X-MC-Unique: QFz9wWdmP-CHeLRiIO2ABQ-1 X-Mimecast-MFC-AGG-ID: QFz9wWdmP-CHeLRiIO2ABQ_1776363454 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-953bde1773cso10878511241.1 for ; Thu, 16 Apr 2026 11:17:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776363454; x=1776968254; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dziPu50qgBv9g5X0MMq171HDJ58L7QJJZqrMBcXThj4=; b=OZqNKBkHl2tHo7vRF72RkqAHNLq/p/Tfr9eiIYNVbfNcszJZB/COp7puWtPx8fufqs aAbM5tZ/4Au3Fk/fuCWWhlFNCiEVaM4LddL4byW4mE0V6JgWwhapbKHx9Ywm7MdPbkvS aa9xSbfiqycCOxH13zGs2GMXmWRf5Gg54T1TYmfA0pt7xGnzkOR8/3CekVXEqjZ8+nr6 /7B2ZC4m2vfZcWcsoZdLAP9ggKfsdgqy62vaYTY7Cd3ybRJRb1+9Q3TxDcxtHt8i12cA pxq7LAMf229X2MZ8I7SRuMDFbMtZMSr7uxfWmybNc3AhRJJU8MfXWB9OouvqpTmIQQ6K lOvw== X-Forwarded-Encrypted: i=1; AFNElJ+8ghewkvp3u4qu1ujktfqwehGAwXZ1mTm9Q8V8eEd5f4eVu7a92CMsK24jrPXWwEwAuGyY0NUFD4WgWw==@sourceware.org X-Gm-Message-State: AOJu0YxKpJRhfDSWmtlvvDOyotNR3T5oRR4sD2sA2m3cUO5/ehDpXCIR bVbQw511M6MVtTeyKHOAR+ZB52edVJyux95Wryl8ouu+0WQckGPk60BoXx9DIAU4nEiclRZOoMU T+yZkrErdoMxz9E/DpZbIsmDQbbqs3yI52rEG3AomHzpA0omk7YGBf/uBEdXJquypa6d8i5g= X-Gm-Gg: AeBDieu7jR0Jdd4qFbP6V/B/YcTAI5aUhnIMKDh1IhaJG7gYmwjxEZHTgLs9zOGEz+n cLBo1KxnkrpQ0tqtRqUyh3ZbzDufd9fWDfL5OT076mdYck9VsRRGkkb/xGSR6QAGeQ9zNAyCQ9S loVEb/7yqEqj0IOrZgNK9TvgGmZ94Y0llzw8Cs821y23iR0z3fryRNqPoon4xLEU6jIUR7gAAmC BE5IHGH6X6ycs4zqlr8vo5cUeRqvYriImHg8BFYghdSRJYU4YMLYzSyDqXhfavWq4VSdYSE49Do TF5C+DldYLVK/UlsRpRti4/HMMrs8kZOTRkbsso+WCAc2qzmTHtA7xgozRCo93Gr102nTejXuRV tgd6VhW9UHrSaB/94DnHcD/jwgCN8+QUunbP/+6biCQ== X-Received: by 2002:a05:6122:3103:b0:56c:e871:31a8 with SMTP id 71dfb90a1353d-56fa3969056mr297960e0c.7.1776363453893; Thu, 16 Apr 2026 11:17:33 -0700 (PDT) X-Received: by 2002:a05:6122:3103:b0:56c:e871:31a8 with SMTP id 71dfb90a1353d-56fa3969056mr297925e0c.7.1776363453345; Thu, 16 Apr 2026 11:17:33 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e::75d? ([2804:14d:8084:993e::75d]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-9588841473csm379195241.4.2026.04.16.11.17.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Apr 2026 11:17:32 -0700 (PDT) Message-ID: <956dbb06-de36-411d-8f34-7582d12d4e3b@redhat.com> Date: Thu, 16 Apr 2026 15:17:27 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/2] gdb: improve help text for set commands with limited options To: Andrew Burgess , gdb-patches@sourceware.org Cc: Ciaran Woodward References: <20260310142323.2619350-2-guinevere@redhat.com> <20260310142323.2619350-3-guinevere@redhat.com> <87bjgm7e1x.fsf@redhat.com> From: Guinevere Larsen In-Reply-To: <87bjgm7e1x.fsf@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qR_u9lVfilim1FtHtxK-MQHPnY7Hi06S3hvEsqzaasg_1776363454 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 3/17/26 10:58 AM, Andrew Burgess wrote: > 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. My issue with this approach is that this is an error message. Meaning that in most terminals the output will actually be: ❌️ Requires an argument. Valid arguments are none, auto, gnu-v3, java, gnat, dlang, rust. Notice the ❌️ emoji, making it clear this is an error. My view is that instructing the user to run a command that returns an error is not great UX, and that not having the available options in the help text is pretty unintuitive. I knew of this option from the first iteration of adding this to the help text, but I just think it is much more intuitive to explain everything in the help. > > 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++) > { ... } Good point, I'll do this > >> + { >> + expander.wrap_here (2); >> + gdb_printf (&expander, "%s, ", *opt); >> + opt++; > Given the simplified loop condition check, you could solve the trailing > ', ' like: and this. -- Cheers, Guinevere Larsen It/she > > { > 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