Re: [PATCH v5 01/25] New target methods for memory tagging support

Simon Marchi via Gdb-patches
2021-02-05T02:31:49Z

On 2021-01-27 3:20 p.m., Luis Machado via Gdb-patches wrote:
> Updates on v5:
>
> - Remove the memory_tagging global (in favor of setting a specific print
> option) and related functions.
>
> Updates on v4:
>
> - Updated the return types of fetch/store member functions from int to bool.
> - Implemented target-debug type print helpers.
> - Renamed global memtag to memory_tagging.
>
> Updates on v3:
>
> - Updated the code documentation for the fetch_memtags and store_memtags
> methods.
>
> Updates on v2:
>
> - Added type parameter to fetch_memtags/store_memtags hooks.
>
> --
>
> This patch starts adding some of the generic pieces to accomodate memory
> tagging.
>
> We have three new target methods:
>
> - supports_memory_tagging: Checks if the target supports memory tagging. This
> defaults to false for targets that don't support memory tagging.
>
> - fetch_memtags: Fetches the allocation tags associated with a particular
> memory range [address, address + length).
>
> The default is to return 0 without returning any tags. This should only
> be called if memory tagging is supported.
>
> - store_memtags: Stores a set of allocation tags for a particular memory
> range [address, address + length).
>
> The default is to return 0. This should only
> be called if memory tagging is supported.
>
> gdb/ChangeLog:
>
> YYYY-MM-DD Luis Machado <luis.machado@linaro.org>
>
> * remote.c (remote_target) <supports_memory_tagging>: New method
> override.
> <fetch_memtags>: New method override.
> <store_memtags>: New method override.
> (remote_target::supports_memory_tagging): New method.
> (remote_target::fetch_memtags): New method.
> (remote_target::store_memtags): New method.
> * target-delegates.c: Regenerate.
> * target.h (struct target_ops) <supports_memory_tagging>: New virtual
> method.
> <fetch_memtags>: New virtual method.
> <store_memtags>: New virtual method.
> (target_supports_memory_tagging): Define.
> (target_fetch_memtags): Define.
> (target_store_memtags): Define.
> * target-debug.h (target_debug_print_size_t)
> (target_debug_print_const_gdb_byte_vector_r)
> (target_debug_print_gdb_byte_vector_r): New functions.
> ---
> gdb/remote.c | 34 +++++++++++++++
> gdb/target-debug.h | 24 +++++++++++
> gdb/target-delegates.c | 95 ++++++++++++++++++++++++++++++++++++++++++
> gdb/target.h | 41 ++++++++++++++++++
> 4 files changed, 194 insertions(+)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index bc995edc53..b130f1ddae 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -690,6 +690,14 @@ class remote_target : public process_stratum_target
> int remove_exec_catchpoint (int) override;
> enum exec_direction_kind execution_direction () override;
>
> + bool supports_memory_tagging () override;
> +
> + bool fetch_memtags (CORE_ADDR address, size_t len,
> + gdb::byte_vector &tags, int type) override;
> +
> + bool store_memtags (CORE_ADDR address, size_t len,
> + const gdb::byte_vector &tags, int type) override;

The indentation is a bit off here. Otherwise, LGTM.

Simon