aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/memtag.exp
blob: 7938488bd0c035b1d0159c81f6b7126ce25648e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2021 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Smoke testing for the various memory tagging commands in GDB.

set u_msg "Memory tagging not supported or disabled by the current architecture\."

standard_testfile
if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
    return -1
}

if {[target_info gdb_protocol] == "extended-remote"} {
    # Make sure we're disconnected, in case we're testing with an
    # extended-remote board, therefore already connected.
    gdb_test "disconnect" ".*"
}

# Test commands without running the program.
with_test_prefix "before program execution" {
    # These commands should all fails without a running program.
    foreach subcmd {"with-logical-tag" "print-logical-tag" \
		    "set-allocation-tag" "print-allocation-tag" "check"} {
	gdb_test "memory-tag $subcmd" $u_msg
    }
}

clean_restart $testfile

if ![runto_main] {
    return -1
}

# Targets that don't support memory tagging should not execute the
# runtime memory tagging tests.
if {![supports_memtag]} {
    unsupported "memory tagging unsupported"
    return -1
}

# With the program running, try to use the memory tagging commands.
with_test_prefix "during program execution" {
    set msg "Argument required \\(address or pointer\\)\."

    # Test the various memory-tag commands again.
    gdb_test "memory-tag print-logical-tag" $msg
    gdb_test "memory-tag print-allocation-tag" $msg
    gdb_test "memory-tag with-logical-tag" \
	     "Argument required \\(<address> <tag>\\)\."
    gdb_test "memory-tag set-allocation-tag" \
	     "Argument required \\(<starting address> <length> <tag bytes>\\)\."
    gdb_test "memory-tag check" $msg
}