]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/testsuite/ChangeLog
Extend "x" and "print" commands to support memory tagging
authorLuis Machado <luis.machado@linaro.org>
Mon, 15 Jun 2020 18:50:55 +0000 (15:50 -0300)
committerLuis Machado <luis.machado@linaro.org>
Wed, 24 Mar 2021 17:59:19 +0000 (14:59 -0300)
commitbef382e61aeff32e46ce987e2af9b7c636dcf038
tree02de46a5bda21cd0e3ee49f49594acc86c2d83dc
parent362a07001900888b37d54523aa010806bd754e18
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.
gdb/ChangeLog
gdb/printcmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/options.exp
gdb/testsuite/gdb.base/with.exp
gdb/valprint.c
gdb/valprint.h