From: Pedro Alves <pedro@palves.net>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] [gdb/build] Return const reference in thread_info_to_thread_handle
Date: Tue, 22 Aug 2023 15:43:19 +0100 [thread overview]
Message-ID: <4917ef2f-f50a-efc0-59a8-30e86d5ac53b@palves.net> (raw)
In-Reply-To: <20230821105356.869-2-tdevries@suse.de>
On 2023-08-21 11:53, Tom de Vries via Gdb-patches wrote:
> In remote_target::thread_info_to_thread_handle we return a copy:
> ...
> gdb::byte_vector
> remote_target::thread_info_to_thread_handle (struct thread_info *tp)
> {
> remote_thread_info *priv = get_remote_thread_info (tp);
> return priv->thread_handle;
> }
> ...
>
> Fix this by returning a const reference instead:
> ...
> const gdb::optional<gdb::byte_vector> &
> remote_target::thread_info_to_thread_handle (struct thread_info *tp)
> ...
>
> Returning a gdb::optional allows us to return a nullptr, or std::nullopt in
> std::optional terms, something that is required by
> thread_db_target::thread_info_to_thread_handle.
>
> In gdb we use gdb::optional instead std::optional, because std::optional is
> availabe starting c++17 and we support c++11 and c++14, but gdb::nullopt is
> currently not available, though a submission is available [1].
>
> So we use a kludge gdb_optional_byte_vector_nullopt.
>
IMHO making the function return gdb::array_view<const gdb_byte>
would be even better. Then the byte_vector is completely an implementation
detail, and, you wouldn't need to wrap with optional, as you could just
return an empty array_view, like currently we return an empty byte_vector.
next prev parent reply other threads:[~2023-08-22 14:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 10:53 [PATCH 1/2] [gdb/build] Support reference return type in make-target-delegates.py Tom de Vries
2023-08-21 10:53 ` [PATCH 2/2] [gdb/build] Return const reference in thread_info_to_thread_handle Tom de Vries
2023-08-22 14:43 ` Pedro Alves [this message]
2023-08-22 17:34 ` Tom de Vries
2023-08-23 15:43 ` Pedro Alves
2023-08-24 6:21 ` Tom de Vries
2023-08-24 11:37 ` Pedro Alves
2023-08-23 15:43 ` [PATCH 1/2] [gdb/build] Support reference return type in make-target-delegates.py Pedro Alves
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=4917ef2f-f50a-efc0-59a8-30e86d5ac53b@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/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).