Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char>
Date: Wed, 09 Oct 2024 13:17:50 +0100	[thread overview]
Message-ID: <87ed4pbhch.fsf@redhat.com> (raw)
In-Reply-To: <952e0e55-b99c-4c24-ae1c-7f3c502bb826@simark.ca>

Simon Marchi <simark@simark.ca> writes:

> On 2024-10-09 07:07, Andrew Burgess wrote:
>> Simon Marchi <simark@simark.ca> writes:
>> 
>>> On 2024-10-06 14:37, Andrew Burgess wrote:
>>>> Convert target_desc::arch and target_desc::osabi from 'const char*' to
>>>> gdb::unique_xmalloc_ptr<char>.  This also allows us to remove the user
>>>> defined ~target_desc destructor.
>>>>
>>>> I doubt it ever actually occurred, but in theory at least, there was a
>>>> memory leak in set_tdesc_architecture and set_tdesc_osabi where the
>>>> member variables were assigned without freeing any previous
>>>> value... but I suspect that usually these fields are only set once.
>>>>
>>>> There should be no user visible changes after this commit.
>>>
>>> Could they be std::string instead?
>> 
>> I considered this, but that would, I think, require wider reaching
>> changes as the API to add the osabi to the returned tdesc passes the
>> information via 'const char *'.  This approach added the memory safety
>> without requiring any further changes.
>> 
>> If you'd prefer std::string be used then let me know and I'll update
>> things.
>
> Up to you, I don't mind, it can be done later.

I'll leave it then if that's OK.

My reason is that, if the osbi member variable changes to std::string
then it makes sense that tdesc_osabi_name return 'const std::string &'.
Which means that tdesc_osabi_name in GDB will also need to return 'const
std::string &', but on the GDB side we store 'enum gdb_osabi' rather
than the actual string ... so now that code needs updating too.

I only wanted to fix this so that I could call set_tdesc_osbi without
leaking memory, and gdb::unique_xmalloc_ptr<char>, which we use in loads
of places, achieves that, and leaves the API untouched.

But I'm not against changing to std::string if someone's keen :)

Thanks,
Andrew


  reply	other threads:[~2024-10-09 12:18 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-06 18:37 [PATCH 0/3] Set osabi in remote target descriptions Andrew Burgess
2024-10-06 18:37 ` [PATCH 1/3] gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char> Andrew Burgess
2024-10-07 17:00   ` Tom Tromey
2024-10-08 19:02   ` Simon Marchi
2024-10-09 11:07     ` Andrew Burgess
2024-10-09 11:45       ` Simon Marchi
2024-10-09 12:17         ` Andrew Burgess [this message]
2024-10-09 15:35           ` Simon Marchi
2024-10-09 15:50             ` Andrew Burgess
2024-10-06 18:37 ` [PATCH 2/3] gdb: make use of set_tdesc_osabi overload in features/ files Andrew Burgess
2024-10-07 17:00   ` Tom Tromey
2024-10-08 19:12   ` Simon Marchi
2024-10-09 11:08     ` Andrew Burgess
2024-10-09 11:48       ` Simon Marchi
2024-10-09 12:04         ` Andrew Burgess
2024-10-06 18:37 ` [PATCH 3/3] gdbserver: pass osabi to GDB in target description Andrew Burgess
2024-10-07  9:38   ` Luis Machado
2024-10-07 17:00   ` Tom Tromey
2024-10-08 17:11 ` [PATCH 0/5] Set osabi in remote target descriptions Andrew Burgess
2024-10-08 17:11   ` [PATCH 1/5] gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char> Andrew Burgess
2024-10-10 13:37     ` Simon Marchi
2024-10-10 15:31       ` Andrew Burgess
2024-10-08 17:11   ` [PATCH 2/5] gdb: make use of set_tdesc_osabi overload in features/ files Andrew Burgess
2024-10-08 17:11   ` [PATCH 3/5] gdb: split osabi support between gdb/ and gdbsupport/ directories Andrew Burgess
2024-10-09  7:12     ` Luis Machado
2024-10-10 13:47     ` Simon Marchi
2024-10-08 17:11   ` [PATCH 4/5] gdb/gdbserver: change shared set_tdesc_osabi to take gdb_osabi Andrew Burgess
2024-10-09  7:12     ` Luis Machado
2024-10-10 15:23     ` Simon Marchi
2024-10-08 17:11   ` [PATCH 5/5] gdbserver: pass osabi to GDB in target description Andrew Burgess
2024-10-09  7:14     ` Luis Machado
2024-10-10 15:56     ` Simon Marchi
2024-10-10 20:19     ` Mark Wielaard
2024-10-11  8:31       ` Andrew Burgess
2024-10-10 15:57   ` [PATCH 0/5] Set osabi in remote target descriptions Simon Marchi
2024-10-10 16:41     ` Andrew Burgess

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=87ed4pbhch.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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