diff options
author | Tom de Vries <tdevries@suse.de> | 2023-08-24 13:40:38 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-08-24 13:40:38 +0200 |
commit | 1f08d324601ef7fd4cce3cff8f8db4a774791828 (patch) | |
tree | f5dc02b94c0fe17232557d8bf24b9f705a7ba337 /gdb/linux-thread-db.c | |
parent | f1917fc63166d73a9d0930d96468e486a49c666d (diff) | |
download | gdb-1f08d324601ef7fd4cce3cff8f8db4a774791828.zip gdb-1f08d324601ef7fd4cce3cff8f8db4a774791828.tar.gz gdb-1f08d324601ef7fd4cce3cff8f8db4a774791828.tar.bz2 |
[gdb/build] Return gdb::array_view in thread_info_to_thread_handle
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 gdb::array_view instead:
...
gdb::array_view<const gdb_byte>
remote_target::thread_info_to_thread_handle (struct thread_info *tp)
...
Tested on x86_64-linux.
This fixes the build when building with -std=c++20.
Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/linux-thread-db.c')
-rw-r--r-- | gdb/linux-thread-db.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 7d9fd57..16c250c 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -107,7 +107,7 @@ public: thread_info *thread_handle_to_thread_info (const gdb_byte *thread_handle, int handle_len, inferior *inf) override; - gdb::byte_vector thread_info_to_thread_handle (struct thread_info *) override; + gdb::array_view<const gdb_byte> thread_info_to_thread_handle (struct thread_info *) override; }; static std::string libthread_db_search_path = LIBTHREAD_DB_SEARCH_PATH; @@ -312,6 +312,7 @@ struct thread_db_thread_info : public private_thread_info /* Cached thread state. */ td_thrhandle_t th {}; thread_t tid {}; + gdb::optional<gdb::byte_vector> thread_handle; }; static thread_db_thread_info * @@ -1724,20 +1725,20 @@ thread_db_target::thread_handle_to_thread_info (const gdb_byte *thread_handle, /* Return the thread handle associated the thread_info pointer TP. */ -gdb::byte_vector +gdb::array_view<const gdb_byte> thread_db_target::thread_info_to_thread_handle (struct thread_info *tp) { thread_db_thread_info *priv = get_thread_db_thread_info (tp); if (priv == NULL) - return gdb::byte_vector (); + return {}; int handle_size = sizeof (priv->tid); - gdb::byte_vector rv (handle_size); + priv->thread_handle.emplace (handle_size); - memcpy (rv.data (), &priv->tid, handle_size); + memcpy (priv->thread_handle->data (), &priv->tid, handle_size); - return rv; + return *priv->thread_handle; } /* Get the address of the thread local variable in load module LM which |