aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
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/testsuite
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/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/options.exp1
-rw-r--r--gdb/testsuite/gdb.base/with.exp2
3 files changed, 7 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 848e089..8513f32 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-24 Luis Machado <luis.machado@linaro.org>
+
+ * gdb.base/options.exp: Adjust for new print options.
+ * gdb.base/with.exp: Likewise.
+
2021-03-22 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.dwarf2/dw2-missing-cu-tag.c: New file.
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index 44c773c..78ec545 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -165,6 +165,7 @@ proc_with_prefix test-print {{prefix ""}} {
"-array-indexes"
"-elements"
"-max-depth"
+ "-memory-tag-violations"
"-null-stop"
"-object"
"-pretty"
diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp
index 0e83ad4..0d53dbe 100644
--- a/gdb/testsuite/gdb.base/with.exp
+++ b/gdb/testsuite/gdb.base/with.exp
@@ -238,7 +238,7 @@ with_test_prefix "errors" {
gdb_test "with w" \
"Ambiguous set command \"w\": watchdog, width, write\\."
gdb_test "with print m" \
- "Ambiguous set print command \"m\": max-depth, max-symbolic-offset\\."
+ "Ambiguous set print command \"m\": max-depth, max-symbolic-offset, memory-tag-violations\\."
gdb_test "with variable xxx=1" \
"Cannot use this setting with the \"with\" command"