| # 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 |
| } |