aboutsummaryrefslogtreecommitdiff
path: root/gdb/valprint.h
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@linaro.org>2020-06-15 15:50:55 -0300
committerLuis Machado <luis.machado@linaro.org>2021-03-24 14:59:19 -0300
commitbef382e61aeff32e46ce987e2af9b7c636dcf038 (patch)
tree02de46a5bda21cd0e3ee49f49594acc86c2d83dc /gdb/valprint.h
parent362a07001900888b37d54523aa010806bd754e18 (diff)
downloadgdb-bef382e61aeff32e46ce987e2af9b7c636dcf038.zip
gdb-bef382e61aeff32e46ce987e2af9b7c636dcf038.tar.gz
gdb-bef382e61aeff32e46ce987e2af9b7c636dcf038.tar.bz2
Extend "x" and "print" commands to support memory tagging
Extend the "x" and "print" commands to make use of memory tagging functionality, if supported by the architecture. The "print" command will point out any possible tag mismatches it finds when dealing with pointers, in case such a pointer is tagged. No additional modifiers are needed. Suppose we have a pointer "p" with value 0x1234 (logical tag 0x0) and that we have an allocation tag of 0x1 for that particular area of memory. This is the expected output: (gdb) p/x p Logical tag (0x0) does not match the allocation tag (0x1). $1 = 0x1234 The "x" command has a new 'm' modifier that will enable displaying of allocation tags alongside the data dump. It will display one allocation tag per line. AArch64 has a tag granule of 16 bytes, which means we can have one tag for every 16 bytes of memory. In this case, this is what the "x" command will display with the new 'm' modifier: (gdb) x/32bxm p <Allocation Tag 0x1 for range [0x1230,0x1240)> 0x1234: 0x01 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x123c: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 <Allocation Tag 0x1 for range [0x1240,0x1250)> 0x1244: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x124c: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 (gdb) x/4gxm a <Allocation Tag 0x1 for range [0x1230,0x1240)> 0x1234: 0x0000000000000201 0x0000000000000000 <Allocation Tag 0x1 for range [0x1240,0x1250)> 0x1244: 0x0000000000000000 0x0000000000000000 gdb/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * printcmd.c (decode_format): Handle the 'm' modifier. (do_examine): Display allocation tags when required/supported. (should_validate_memtags): New function. (print_command_1): Display memory tag mismatches. * valprint.c (show_memory_tag_violations): New function. (value_print_option_defs): Add new option "memory-tag-violations". (user_print_options) <memory_tag_violations>: Initialize to 1. * valprint.h (struct format_data) <print_tags>: New field. (value_print_options) <memory_tag_violations>: New field. gdb/testsuite/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * gdb.base/options.exp: Adjust for new print options. * gdb.base/with.exp: Likewise.
Diffstat (limited to 'gdb/valprint.h')
-rw-r--r--gdb/valprint.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/valprint.h b/gdb/valprint.h
index ca8ad6a..e1dae2c 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -65,6 +65,9 @@ struct value_print_options
e.g. when the user passes a format to "print". */
int format;
+ /* Print memory tag violations for pointers. */
+ bool memory_tag_violations;
+
/* Stop printing at null character? */
bool stop_print_at_null;
@@ -252,6 +255,7 @@ struct format_data
int count;
char format;
char size;
+ bool print_tags;
/* True if the value should be printed raw -- that is, bypassing
python-based formatters. */