Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Pedro Alves <pedro@palves.net>,
	Luis Machado <luis.machado@linaro.org>,
	Christian Biesinger <cbiesinger@google.com>,
	Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: make inferior::terminal a unique ptr
Date: Thu, 25 Jun 2020 14:39:22 -0400	[thread overview]
Message-ID: <139027e2-4991-cd04-cdcd-416ba5a48c05@simark.ca> (raw)
In-Reply-To: <04581d9f-2d9b-304c-e223-657f312c4549@palves.net>

On 2020-06-25 2:09 p.m., Pedro Alves wrote:
> On 6/25/20 6:59 PM, Luis Machado wrote:
>> On 6/25/20 2:28 PM, Pedro Alves wrote:
>>> On 6/25/20 6:18 PM, Christian Biesinger via Gdb-patches wrote:
>>>> On Thu, Jun 25, 2020 at 10:55 AM Simon Marchi via Gdb-patches
>>>> <gdb-patches@sourceware.org> wrote:
>>>>> -    current_inferior ()->terminal = xstrdup (terminal_name);
>>>>> +    current_inferior ()->terminal.reset (xstrdup (terminal_name));
>>>>
>>>> Perhaps it really should be a std::string?
>>>
>>> I think there's no good reason for that.  It's a string that doesn't
>>> ever need to grow/shrink.  And then its use is to pass down to
>>> a syscall that accepts C-style null-terminated strings:
>>
>> I tend to agree with Christian. I suppose one positive outcome is to make the code less cumbersome. It's not like xstrdup is great to read anyway.
>>
>> Are we worried about performance implications of passing std::string's around like this?
> 
> It's more like -- why store a fat 32 bytes object in the inferior when
> a pointer does just as well.  There's no code that would benefit from
> making this a string, like, there's no strlen call that that would avoid.
> The code that wants to consume this wants a pointer.  A method-based
> interface like I pointed at in that github commit exposes a pointer.
> So it would just be implementation detail.
> 
> Thanks,
> Pedro Alves
> 

Heh, that's more noise than I expected for this patch :)

I tend to agree with Pedro on this.  I initially tried to replace it with
a gdb::optional<std::string>, then making get_inferior_io_terminal return a
reference to that... in the end it required changing a bunch of code in a way
that didn't really make it better.  The intent of this patch is just to get rid
of the manual free-ing, which is a concrete improvement.

Simon


  reply	other threads:[~2020-06-25 18:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 15:55 Simon Marchi
2020-06-25 17:18 ` Christian Biesinger
2020-06-25 17:28   ` Pedro Alves
2020-06-25 17:59     ` Luis Machado
2020-06-25 18:09       ` Pedro Alves
2020-06-25 18:39         ` Simon Marchi [this message]
2020-06-25 21:20         ` Christian Biesinger
2020-06-25 17:32 ` Pedro Alves
2020-06-25 18:42   ` Simon Marchi
2020-06-25 21:17     ` Pedro Alves
2020-06-25 20:15 ` Tom Tromey
2020-06-25 21:07   ` Simon Marchi
2020-06-25 21:45     ` 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=139027e2-4991-cd04-cdcd-416ba5a48c05@simark.ca \
    --to=simark@simark.ca \
    --cc=cbiesinger@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@linaro.org \
    --cc=pedro@palves.net \
    --cc=simon.marchi@efficios.com \
    /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