From 48136e006e324980195e21f70ca4accd7f722ceb Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Mon, 15 Jun 2020 15:49:37 -0300 Subject: New memory-tag commands Add new commands under the "memory-tag" prefix to allow users to inspect, modify and check memory tags in different ways. The available subcommands are the following: - memory-tag print-logical-tag : Prints the logical tag for a particular address. - memory-tag withltag : Prints the address tagged with the logical tag . - memory-tag print-allocation-tag : Prints the allocation tag for a particular address. - memory-tag setatag : Sets one or more allocation tags to the specified tags. - memory-tag check : Checks if the logical tag in
matches its allocation tag. These commands make use of the memory tagging gdbarch methods, and are still available, but disabled, when memory tagging is not supported by the architecture. I've pondered about a way to make these commands invisible when memory tagging is not available, but given the check is at runtime (and support may come and go based on a process' configuration), that is a bit too late in the process to either not include the commands or get rid of them. Ideas are welcome. gdb/ChangeLog: 2021-03-24 Luis Machado * printcmd.c: Include gdbsupport/rsp-low.h. (memory_tag_list): New static global. (process_print_command_args): Factored out of print_command_1. (print_command_1): Use process_print_command_args. (show_addr_not_tagged, show_memory_tagging_unsupported) (memory_tag_command, memory_tag_print_tag_command) (memory_tag_print_logical_tag_command) (memory_tag_print_allocation_tag_command, parse_with_logical_tag_input) (memory_tag_with_logical_tag_command, parse_set_allocation_tag_input) (memory_tag_set_allocation_tag_command, memory_tag_check_command): New functions. (_initialize_printcmd): Add "memory-tag" prefix and subcommands. gdbsupport/ChangeLog: 2021-03-24 Luis Machado * rsp-low.cc (fromhex, hex2bin): Move to ... * common-utils.cc: ... here. (fromhex) Change error message text to not be RSP-specific. * rsp-low.h (fromhex, hex2bin): Move to ... * common-utils.h: ... here. --- gdbsupport/common-utils.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gdbsupport/common-utils.h') diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h index 1de747f186d..224e1f31222 100644 --- a/gdbsupport/common-utils.h +++ b/gdbsupport/common-utils.h @@ -22,6 +22,7 @@ #include #include +#include "gdbsupport/byte-vector.h" #include "poison.h" @@ -191,4 +192,18 @@ in_inclusive_range (T value, T low, T high) extern ULONGEST align_up (ULONGEST v, int n); extern ULONGEST align_down (ULONGEST v, int n); +/* Convert hex digit A to a number, or throw an exception. */ +extern int fromhex (int a); + +/* HEX is a string of characters representing hexadecimal digits. + Convert pairs of hex digits to bytes and store sequentially into + BIN. COUNT is the maximum number of characters to convert. This + will convert fewer characters if the number of hex characters + actually seen is odd, or if HEX terminates before COUNT characters. + Returns the number of characters actually converted. */ +extern int hex2bin (const char *hex, gdb_byte *bin, int count); + +/* Like the above, but return a gdb::byte_vector. */ +gdb::byte_vector hex2bin (const char *hex); + #endif /* COMMON_COMMON_UTILS_H */ -- cgit v1.2.1