From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XVhEAWssYmqHyikAWB0awg (envelope-from ) for ; Thu, 23 Jul 2026 10:59:55 -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=EKq2g2J7; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E3A701E09E; Thu, 23 Jul 2026 10:59:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 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 2EF121E099 for ; Thu, 23 Jul 2026 10:59:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A8D84BA23EE for ; Thu, 23 Jul 2026 14:59:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A8D84BA23EE 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=EKq2g2J7 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 D61B04BA540B for ; Thu, 23 Jul 2026 14:59:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D61B04BA540B 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 D61B04BA540B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784818768; cv=none; b=odfeecl8Y3W5v8wDHEYZmx1v6nniWXqocx3JvOPbuTAWUIgaNJzrCNS+XPploy0QNoJWZ+5ko0UrMYQbv0voRn8e4WsDWZeA07n9lIxc/pb2oRCL7qk19VFlYvVQ9qyktpd+CE4sWsm6+MqwzvHP/a+Lsv6oiM0fjgwPLRdmkMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784818768; c=relaxed/simple; bh=wgDxbDaFBRrz2Vjuxu7hY7kuoBTVFp4fD579VaI7+0k=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=r5Pmg5IZg6EU+HhEu/KSPuLdWzMdVKLY9fZxucbCwWdl64v2ni263F0L+gtoqUS4BbgB4H8vpJjQ27GweuDKD2GTgfu5A4PZfPC5xINNONP0HbMoExa5TbIR1BUcLaBv2JiS7i81CtwPNVWEuN9+2eO2uokdj/Oa8PXl16zSopk= 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=EKq2g2J7 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D61B04BA540B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784818767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L7uMF+V6zoSG9bnaL36NPWwyhL+kK6NMWJuDQr7B9Nc=; b=EKq2g2J7sSnczfdtVSE72bs7o8RbQ1DnvhW5MWLH27QcBQsH7TuEb+JyxMmlZj788erPKo NZqc4VI5o9/Lf5bQ/9TuCd8pdLck18loQMXsGiNwoX38WYywDvJoVstFOcIUw4+R0nlD5i WlO18qYJF979tKGkJ948mPLHPjNPtH0= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-184-4ChuGFo3MhqqMWhY4Ae5sA-1; Thu, 23 Jul 2026 10:59:25 -0400 X-MC-Unique: 4ChuGFo3MhqqMWhY4Ae5sA-1 X-Mimecast-MFC-AGG-ID: 4ChuGFo3MhqqMWhY4Ae5sA_1784818765 Received: by mail-vk1-f200.google.com with SMTP id 71dfb90a1353d-5bfd2dcf7fdso217533e0c.1 for ; Thu, 23 Jul 2026 07:59:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784818765; x=1785423565; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references: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:content-type; bh=L7uMF+V6zoSG9bnaL36NPWwyhL+kK6NMWJuDQr7B9Nc=; b=o7K9lMBCvPVcTQv7+lb1CyzwH5WSmFWALPjq3QDDkTcHGjZdAFyZy4FK/67XpuIM/v WYfXVqis/1QozL0STyAI+oWcU0KWhnU8tnVLedt4I5LkaDbqNgNDqxEdb7fYdo42sdRQ K4LPzpDhM1NgRVyYnwxBuV6j+p0CEdRG+AIJqBoPd3z30YH+KPgWGatNUWRPTcW0WyrJ KL3lJVYb9CM7s6cHlHOlwjZjSKd4tpGxc/hFM3S+YHb9KEKfMsYnY/dbzuVZLJdYQoQp 6nJbSIqOeIUSAq4yeIeN2lEur2wE+LDppb+V0gv7lZleYmXN+buuhj5RkXt2w9OQlOzc ewUQ== X-Forwarded-Encrypted: i=1; AHgh+RoKecpqcA58hODSxKnCc1UV23P5uqSSIT7OsZc87eBdj3o6dB4ftD/+QvP5SCWmvEymyuRyrBz8BcMXZw==@sourceware.org X-Gm-Message-State: AOJu0YwE4xA/NBSYDzoZvxkzuA/QzRW7hQ97sOrX0L3okVEN5YxQr7/j Bg9nWkbFE9d/S+oShPAPrYpierzMZAKDXV15CUy87xCT0xJqG/ffo7e9A3eRqSEaGuvfQC7HHi1 RqcreZ7KEoC5qTJogyJMbhn3goQZtNZn3I0IKLZmiWCPK+y1eol0hHFt9VHqXB6Q= X-Gm-Gg: AR+sD10tnmOD/H/HZcbqi28GEfe18LQaG4+mVx3rhNONyDWyOav9hw7YLOcknfoNyM4 3xtMeoklXwDd87+5/qtr9N/6YLwDHcjMzMMpwDj2/ZsM6U8kTyFE8QC4lwX58dAEaI1d+ki/HiR LON1iD59PKVmjMF0dCGUzqLL9Xv8ywbY0v3t/nOYO8WOaAeJpK6OLyimSyePz2DEHDeE/q1Sf/h aTREK3s6eBKAu/toF4qNKlgK1uDVv7oC+DGreL7Rjkh6kwP4m7lg6qNDQDihRyt+3XWOUEtd6KP U3ID5q+B/3gfBZ3w94c3/by4WT6QUq8J23TWzseQjRmlTFJtdAIdjOQoAN0/eq75m596B371pF6 PyNB/4xc7PQ== X-Received: by 2002:a05:6122:458b:b0:5bf:b500:c4fa with SMTP id 71dfb90a1353d-5c2d9fad6d9mr1328296e0c.2.1784818764955; Thu, 23 Jul 2026 07:59:24 -0700 (PDT) X-Received: by 2002:a05:6122:458b:b0:5bf:b500:c4fa with SMTP id 71dfb90a1353d-5c2d9fad6d9mr1328274e0c.2.1784818764423; Thu, 23 Jul 2026 07:59:24 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e::75d? ([2804:14d:8084:993e::75d]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5c2c627682dsm6495291e0c.2.2026.07.23.07.59.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jul 2026 07:59:23 -0700 (PDT) Message-ID: <42b28e8d-5f3d-40cd-bd5c-fe3e4ea497b4@redhat.com> Date: Thu, 23 Jul 2026 11:59:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fix double apropos output when both alias name and command name match the pattern To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20260531163756.781643-1-philippe.waroquiers@skynet.be> <20260531163756.781643-2-philippe.waroquiers@skynet.be> From: Guinevere Larsen In-Reply-To: <20260531163756.781643-2-philippe.waroquiers@skynet.be> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: CSjkXBdj4Tj5oSdZnYYZpfsbUSQPR6tFnEXYA1bvn8E_1784818765 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 5/31/26 1:37 PM, Philippe Waroquiers wrote: > apropos_cmd first tries to match the command name with the pattern. > If that succeeds, it prints the command and all its aliases not having > a specific doc string. > In this case, it should not try to match the command aliases names as > the command has already been printed. > > Without this patch, the behaviour is: > (gdb) alias ter-exec = interpreter-exec > (gdb) apropos er-exe > interpreter-exec, ter-exec -- Execute a command in an interpreter. > interpreter-exec, ter-exec -- Execute a command in an interpreter. > (gdb) > --- Hi! Thanks for working on this and sorry for the delay in getting a review. This looks like a pretty good and straight-forward change. Hopefully it gets approved soon. Reviewed-By: Guinevere Larsen -- Cheers, Guinevere Larsen it/its she/her (deprecated) > gdb/cli/cli-decode.c | 18 ++++++++++-------- > gdb/testsuite/gdb.base/help.exp | 8 ++++++++ > 2 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > index de40faeed59..36f911c2cd6 100644 > --- a/gdb/cli/cli-decode.c > +++ b/gdb/cli/cli-decode.c > @@ -1784,16 +1784,18 @@ apropos_cmd (struct ui_file *stream, > returnvalue = regex.search (c->name, name_len, 0, name_len, NULL); > if (returnvalue >= 0) > print_doc_of_command (*c, verbose, regex, stream); > - > - /* Try to match against the name of the aliases. */ > - for (const cmd_list_element &alias : c->aliases) > + else > { > - name_len = strlen (alias.name); > - returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > - if (returnvalue >= 0) > + /* Try to match against the name of the aliases. */ > + for (const cmd_list_element &alias : c->aliases) > { > - print_doc_of_command (*c, verbose, regex, stream); > - break; > + name_len = strlen (alias.name); > + returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); > + if (returnvalue >= 0) > + { > + print_doc_of_command (*c, verbose, regex, stream); > + break; > + } > } > } > } > diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp > index a8c55721ef2..6a88c8d4db2 100644 > --- a/gdb/testsuite/gdb.base/help.exp > +++ b/gdb/testsuite/gdb.base/help.exp > @@ -135,6 +135,14 @@ gdb_test_no_output "alias mybt10 = backtrace 10" "define mybt10 alias" > gdb_test "apropos Print backtrace of all stack frames, or innermost COUNT frames\." \ > "backtrace, mybt10, mybt, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+ alias mybt10 = backtrace 10" > > +# Test apropos when both the alias name and the aliased command match the pattern. > +gdb_test_no_output "alias ter-exec = interpreter-exec" "define ter-exec alias" > +gdb_test_multiple "apropos er-exe" "check we have a single output line when alias and command name match" { > + -re "^apropos er-exe\r\ninterpreter-exec, ter-exec -- Execute a command in an interpreter\.\r\n$gdb_prompt $" { > + pass $gdb_test_name > + } > +} > + > # Test help for commands having aliases. > gdb_test "help bt" "backtrace, mybt10, mybt, where, bt\[\r\n\]+ alias mybt10 = backtrace 10\[\r\n\]+Print backtrace of all stack frames, or innermost COUNT frames\..*" >