From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tom@tromey.com>,
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 2/5] gdbsupport: make gdb_abspath return an std::string
Date: Mon, 18 Apr 2022 16:11:47 -0400 [thread overview]
Message-ID: <3fab15b9-7d48-c5c7-4c94-e481c30d9848@polymtl.ca> (raw)
In-Reply-To: <8735iauql1.fsf@tromey.com>
On 2022-04-18 15:41, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> From: Simon Marchi <simon.marchi@efficios.com>
> Simon> I'm trying to switch these functions to use std::string instead of char
> Simon> arrays, as much as possible. Some callers benefit from it (can avoid
> Simon> doing a copy of the result), while others suffer (have to make one more
> Simon> copy).
>
> I hate copies but the main thing is to make sure none of them are in hot
> paths. This seems fine on that front.
>
> Sometimes I wonder if gdb would be better off with its own string type
> -- say a combination of gdb::unique_xmalloc_ptr<char> and string_view.
> This would interact more nicely with legacy code without sacrificing C++
> string methods. We could stick the string length in there as well if we
> thought that was worthwhile.
Yeah, we'll always be stuck with APIs (system or otherwise) that hand us
strings that we need free (so, use gdb::unique_xmalloc_ptr<char>). And
as far as I know there's no way of building an std::string that would
take ownership of the malloc'ed char array. We would have no choice but
to make a copy if we wanted to build an std::string out of it. So
having our own string type that could do that would be a plus. On the
other hand, the day we use an API that returns an std::string, we won't
be able to build our string type from the std::string without copying
it...
Simon
next prev parent reply other threads:[~2022-04-18 20:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-14 20:01 [PATCH 1/5] gdb: call gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search Simon Marchi
2022-04-14 20:01 ` [PATCH 2/5] gdbsupport: make gdb_abspath return an std::string Simon Marchi
2022-04-18 19:41 ` Tom Tromey
2022-04-18 20:09 ` Pedro Alves
2022-04-18 20:11 ` Simon Marchi [this message]
2022-04-14 20:01 ` [PATCH 3/5] gdbsupport: make gdb_realpath_keepfile " Simon Marchi
2022-04-18 19:44 ` Tom Tromey
2022-04-14 20:01 ` [PATCH 4/5] gdb: use gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search Simon Marchi
2022-04-18 19:44 ` Tom Tromey
2022-04-18 20:12 ` Simon Marchi
2022-04-14 20:01 ` [PATCH 5/5] gdbsupport: add path_join function Simon Marchi
2022-04-15 5:59 ` Eli Zaretskii
2022-04-18 18:11 ` Simon Marchi
2022-04-18 18:30 ` Eli Zaretskii
2022-04-18 19:24 ` Pedro Alves
2022-04-15 14:38 ` Lancelot SIX
2022-04-15 16:55 ` Lancelot SIX
2022-04-18 18:43 ` Simon Marchi
2022-04-18 19:09 ` Pedro Alves
2022-04-18 19:12 ` Simon Marchi
2022-04-18 20:55 ` Simon Marchi
2022-04-18 21:07 ` Pedro Alves
2022-04-19 0:19 ` Simon Marchi
2022-04-18 19:22 ` Pedro Alves
2022-04-18 20:01 ` Tom Tromey
2022-04-18 23:11 ` Lancelot SIX
2022-04-20 0:22 ` Simon Marchi
2022-04-18 19:36 ` [PATCH 1/5] gdb: call gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search 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=3fab15b9-7d48-c5c7-4c94-e481c30d9848@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).