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: Wed, 23 Aug 2023 16:43:10 +0100 [thread overview]
Message-ID: <6e0dd204-8e42-677e-2f5f-cc40c3d780b3@palves.net> (raw)
In-Reply-To: <947d8961-598d-5680-185c-f583d69124c8@suse.de>
On 22/08/23 18:34, Tom de Vries wrote:
> I've given the gdb::array_view<const gdb_byte> a try, and that works fine, and greatly simplifies the patch, so thanks for that suggestion.
Great!
> The first patch is no longer necessary, but we could consider committing it nevertheless, since the work is done and may be needed in the future.
I agree.
>
> -gdb::byte_vector
> +gdb::array_view<const gdb_byte>
> remote_target::thread_info_to_thread_handle (struct thread_info *tp)
> {
> remote_thread_info *priv = get_remote_thread_info (tp);
> diff --git a/gdb/target-debug.h b/gdb/target-debug.h
> index acb01d47e7c..31c25e9aefd 100644
> --- a/gdb/target-debug.h
> +++ b/gdb/target-debug.h
> @@ -236,4 +236,18 @@ target_debug_print_gdb_byte_vector_r (gdb::byte_vector &vector)
> {
> target_debug_print_const_gdb_byte_vector_r (vector);
> }
> +
> +static void
> +target_debug_print_gdb_array_view_const_gdb_byte (gdb::array_view<const gdb_byte> &vector)
array_views should be passed by value normally (because they're small). Did you run into something
that forced this to be a reference? Or was it just copied from the vector case? If it
works, we should just drop the &.
Also, one of the points of array_view is that you can pass a vector as array_view
argument, like you can pass std::string as string_view argument -- would it work to make
target_debug_print_const_gdb_byte_vector_r call this new
target_debug_print_gdb_array_view_const_gdb_byte instead of duplicating that code?
> +{
> + gdb_puts ("{", gdb_stdlog);
> +
> + for (size_t i = 0; i < vector.size (); i++)
> + {
> + gdb_printf (gdb_stdlog, " %s",
> + phex_nz (vector[i], 1));
> + }
> + gdb_puts (" }", gdb_stdlog);
> +}
> +
> #endif /* TARGET_DEBUG_H */
...
> diff --git a/gdb/target.c b/gdb/target.c
> index 16f43d072cd..8b1d48d91d9 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -2640,7 +2640,7 @@ target_thread_handle_to_thread_info (const gdb_byte *thread_handle,
>
> /* See target.h. */
>
> -gdb::byte_vector
> +gdb::array_view<const gdb_byte>
> target_thread_info_to_thread_handle (struct thread_info *tip)
> {
> target_ops *target = current_inferior ()->top_target ();
> diff --git a/gdb/target.h b/gdb/target.h
> index 6ae400e2cc2..0cea955cbd7 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -39,6 +39,10 @@ struct expression;
> struct dcache_struct;
> struct inferior;
>
> +/* Define const gdb_byte using one identifier, to make it easy for
> + make-target-delegates.py to parse. */
> +typedef const gdb_byte const_gdb_byte;
That's unfortunate, but I can live with it.
next prev parent reply other threads:[~2023-08-23 15: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
2023-08-22 17:34 ` Tom de Vries
2023-08-23 15:43 ` Pedro Alves [this message]
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=6e0dd204-8e42-677e-2f5f-cc40c3d780b3@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).