public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Pedro Alves <pedro@palves.net>,
	Christina Schimpe <christina.schimpe@intel.com>,
	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)
Date: Thu, 21 Apr 2022 17:28:16 +0100	[thread overview]
Message-ID: <87fsm6qu3j.fsf@redhat.com> (raw)
In-Reply-To: <87ilr2r98p.fsf@redhat.com>

Andrew Burgess <aburgess@redhat.com> writes:

> Pedro Alves <pedro@palves.net> writes:
>
>> On 2022-04-21 11:25, Andrew Burgess wrote:
>>> Pedro Alves <pedro@palves.net> 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 <aburgess@redhat.com>
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<char> 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<gdb::unique_xmalloc_ptr<char>> legacy_names;
+      gdb::unique_xmalloc_ptr<char> 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


  reply	other threads:[~2022-04-21 16:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 13:11 [PATCH v2 0/3] Apply fixme notes for multi-target support Christina Schimpe
2022-03-29 13:11 ` [PATCH v2 1/3] gdb: Make global feature array a per-remote target array Christina Schimpe
2022-03-29 13:45   ` Eli Zaretskii
2022-04-18 14:56   ` Tom Tromey
2022-04-18 19:01   ` Pedro Alves
2022-04-20 11:30     ` "show remote foo-packet" regression (Re: [PATCH v2 1/3] gdb: Make global feature array a per-remote target array) Pedro Alves
2022-04-20 11:31     ` Pedro Alves
2022-04-21 10:25       ` Andrew Burgess
2022-04-21 10:31         ` Pedro Alves
2022-04-21 11:01           ` Andrew Burgess
2022-04-21 16:28             ` Andrew Burgess [this message]
2022-04-21 18:20               ` Pedro Alves
2022-04-27 13:55     ` [PATCH v2 1/3] gdb: Make global feature array a per-remote target array Schimpe, Christina
2022-05-25 14:27       ` Pedro Alves
2022-06-01 10:45         ` Schimpe, Christina
2022-03-29 13:11 ` [PATCH v2 2/3] gdb: Add per-remote target variables for memory read and write config Christina Schimpe
2022-03-29 13:48   ` Eli Zaretskii
2022-04-18 14:56   ` Tom Tromey
2022-03-29 13:11 ` [PATCH v2 3/3] gdb: Remove workaround for the vCont packet Christina Schimpe
2022-04-18 14:59   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsm6qu3j.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=christina.schimpe@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).