1 # Copyright 2015-2019 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
19 unsupported "skipping x86 PKEYS tests."
23 set comp_flags "-I${srcdir}/../nat/"
25 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
26 [list debug additional_flags=${comp_flags}]] } {
27 untested "failed to compile x86 PKEYS test.
32 untested "could not run to main"
37 set test "probe PKRU support"
38 gdb_test_multiple "print have_pkru()" $test {
39 -re ".. = 1\r\n$gdb_prompt $" {
43 -re ".. = 0\r\n$gdb_prompt $" {
48 if { !$supports_pkru } {
49 unsupported "processor does not support protection key feature."
53 # Test pkru register at startup
56 gdb_test "print \$pkru" "= 0" "pkru register"
58 # Read values from pseudo registers.
59 gdb_breakpoint [ gdb_get_line_number "break here 1" ]
60 gdb_continue_to_breakpoint "break here 1" ".*break here 1.*"
62 gdb_test "info register pkru" ".*pkru.*0x12345678.*" "read pkru register"
63 gdb_test "print /x \$pkru = 0x44444444" "= 0x44444444" "set pkru value"
64 gdb_test "info register pkru" ".*pkru.*0x44444444.*" "read value after setting value"
66 gdb_breakpoint [ gdb_get_line_number "break here 2" ]
67 gdb_continue_to_breakpoint "break here 2" ".*break here 2.*"
69 gdb_test "print /x rd_value" "= 0x44444444" "variable after reading pkru"