From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 25yrIjmGYWJfaQEAWB0awg (envelope-from ) for ; Thu, 21 Apr 2022 12:28:41 -0400 Received: by simark.ca (Postfix, from userid 112) id 80A961E15F; Thu, 21 Apr 2022 12:28:41 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=gVPTAXEv; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 simark.ca (Postfix) with ESMTPS id E33F01E15D for ; Thu, 21 Apr 2022 12:28:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 794B1385DC1F for ; Thu, 21 Apr 2022 16:28:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 794B1385DC1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650558520; bh=YhAvzN4GbHLFltUYEAdYo6TDXULkyVAM3+bXoyx9fXg=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gVPTAXEv2gvon7zWh3HpWYF11OmCSlfDa6N7gfl2NK7ruluD3HTEZY0EVM57X0z3c W40uU+6zvR+/CBNutO9SgotVV5VTsbZHam7aG1iI16JG/GwArXOdlB7BgZYRn7+ouB drNT4MCOwQ9RKdGOHe6HZBSUR8lMwpZfMZPPUTm4= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 967303856DFA for ; Thu, 21 Apr 2022 16:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 967303856DFA 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-670Nsi_jNBeXnuTahn5IWw-1; Thu, 21 Apr 2022 12:28:20 -0400 X-MC-Unique: 670Nsi_jNBeXnuTahn5IWw-1 Received: by mail-wm1-f69.google.com with SMTP id r83-20020a1c4456000000b0038ff033b654so59338wma.0 for ; Thu, 21 Apr 2022 09:28:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=YhAvzN4GbHLFltUYEAdYo6TDXULkyVAM3+bXoyx9fXg=; b=4SrVjac1uSgkbZWgpNMABtz0Edy24vA+jC9DUow0uIbBzco5MRxy6ObvsH5Ify6XM7 pWdkdsNbukS99VHb+MqiYnQhrj1R7EAQ/7ufZdEpZhYTBeXEvSyguTnsCf6h48lWPjNb g+n+CxQqm/ZxglLbizqzehvokSinhl1Be8CjDJCT5ZGmYySZDFnoXrtVUPc8njnskPiB UCUgYcYfyLEKYr1btz60bdpHKsqNRZv5uxHYIG0QYnRigxHFrLSEAvpUqoOBaObcLkZ1 TTytmFTehN+fGjPAWRvxw7PQKHM+LHdjaym3kbdNa7L6i4GP7bKKLDpjO96J6N/t3OrS Q/mw== X-Gm-Message-State: AOAM531xn2Mo2mjSFtw0ALVd6mXSGyJIDSIpUHZ/w3yeaQ0KoJenB6/x GpznandnQl3cBdzaAdAJ4Qz/Xhi+sCBCoihtuNX0IseVJbujfMoe38el7YlkVr6hmCvqRSPoR1f fSnIUIodxC2Tj/G+ZY33JjA== X-Received: by 2002:a05:600c:4f56:b0:392:4cd4:b161 with SMTP id m22-20020a05600c4f5600b003924cd4b161mr9516551wmq.178.1650558498720; Thu, 21 Apr 2022 09:28:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfXDcsKgMDDemfZmHyx16mpGR50y0Vwnb3NRESGSn148hNQaAOpS+MBZZVc+BgmnPDVSlNPw== X-Received: by 2002:a05:600c:4f56:b0:392:4cd4:b161 with SMTP id m22-20020a05600c4f5600b003924cd4b161mr9516536wmq.178.1650558498467; Thu, 21 Apr 2022 09:28:18 -0700 (PDT) Received: from localhost (host81-136-113-48.range81-136.btcentralplus.com. [81.136.113.48]) by smtp.gmail.com with ESMTPSA id f7-20020a05600c4e8700b00391dd70a0aesm2625239wmq.41.2022.04.21.09.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 09:28:17 -0700 (PDT) To: Pedro Alves , Christina Schimpe , gdb-patches@sourceware.org Subject: Re: "show remote foo-packet" regression (Re: [PATCH v2 1/3] gdb: Make global feature array a per-remote target array) In-Reply-To: <87ilr2r98p.fsf@redhat.com> References: <20220329131158.3970228-1-christina.schimpe@intel.com> <20220329131158.3970228-2-christina.schimpe@intel.com> <08fd8bbf-c44e-7313-d7b3-7b0770c2c7d4@palves.net> <7c319441-067e-6f5c-cf80-84d696c9236e@palves.net> <87mtgerawv.fsf@redhat.com> <6fb9a140-0163-ce56-ac78-f5bf3f1b7795@palves.net> <87ilr2r98p.fsf@redhat.com> Date: Thu, 21 Apr 2022 17:28:16 +0100 Message-ID: <87fsm6qu3j.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Andrew Burgess writes: > Pedro Alves writes: > >> On 2022-04-21 11:25, Andrew Burgess wrote: >>> Pedro Alves writes: >>>> >>>> This commit is present in the GDB 12 branch and not in GDB 11, so it's a regression there. >>> >>> Sorry for the regression. I took a look at the code and I honestly have >>> no idea why I thought the code in the above commit would work :-/ >>> >> >> No worries, happens all the time to me. :-) >> >>> Below is a patch that should fix this issue. I probably should write a >>> test to go along with it, but thought I'd share this for feedback first. >>> >>> Let me know what you think, >> >> LGTM. Thanks for fixing it. > > Thanks, I'll just let a test run complete, and push this later today. I pushed the following patch to master and gdb-12-branch. Thanks, Andrew --- commit 5f21c7aae2040f3463d1ff56a4b0bcdbba34832d Author: Andrew Burgess Date: Thu Apr 21 11:16:18 2022 +0100 gdb: fix 'remote show FOO-packet' aliases The following behaviour was observed in GDB: (gdb) show remote X-packet Support for the `p' packet is auto-detected, currently unknown. Note the message mentions the 'p' packet. This is a regression since this commit: commit 8579fd136a614985bd27f20539c7bb7c5a51287d Date: Mon Nov 8 14:58:46 2021 +0000 gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr Before this commit the behaviour was: (gdb) show remote X-packet Support for the `X' packet is auto-detected, currently unknown. The problem was caused by a failed attempt to ensure that some allocated strings were deleted when GDB exits. The code in the above commit attempted to make use of 'static' to solve this problem, however, the solution was just wrong. In this new commit I instead allocate a static vector into which all the allocated strings are stored, this ensures the strings are released when GDB exits (which makes output from tools like valgrind cleaner), but each string within the vector can be unique, which fixes the regression. diff --git a/gdb/remote.c b/gdb/remote.c index 75d6bf3919d..562cc586f2b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1968,15 +1968,17 @@ add_packet_config_cmd (struct packet_config *config, const char *name, /* set/show remote NAME-packet {auto,on,off} -- legacy. */ if (legacy) { - /* It's not clear who should take ownership of this string, so, for - now, make it static, and give copies to each of the add_alias_cmd - calls below. */ - static gdb::unique_xmalloc_ptr legacy_name + /* It's not clear who should take ownership of the LEGACY_NAME string + created below, so, for now, place the string into a static vector + which ensures the strings is released when GDB exits. */ + static std::vector> legacy_names; + gdb::unique_xmalloc_ptr legacy_name = xstrprintf ("%s-packet", name); add_alias_cmd (legacy_name.get (), cmds.set, class_obscure, 0, &remote_set_cmdlist); add_alias_cmd (legacy_name.get (), cmds.show, class_obscure, 0, &remote_show_cmdlist); + legacy_names.emplace_back (std::move (legacy_name)); } } diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp index 1f0869433f2..579dcd40e5c 100644 --- a/gdb/testsuite/gdb.base/remote.exp +++ b/gdb/testsuite/gdb.base/remote.exp @@ -195,4 +195,9 @@ gdb_test_no_output "set remote hardware-breakpoint-limit -1" gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647" gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647" +# Check the X/P/p alias commands display the correct packet names. +foreach pkt {X P p} { + gdb_test "show remote ${pkt}-packet" "Support for the `${pkt}' packet is.*" +} + gdb_exit