]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/i386-pkru.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-pkru.exp
1 # Copyright 2015-2023 Free Software Foundation, Inc.
2 #
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.
7 #
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.
12 #
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/>.
15
16 standard_testfile
17
18 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
19 unsupported "skipping x86 PKEYS tests."
20 return
21 }
22
23 set default_pkru_re 0x0
24 if { [istarget *-*-linux*] } {
25 # Starting with v4.9, the linux kernel contains commit acd547b29880
26 # ("x86/pkeys: Default to a restrictive init PKRU"), which sets the
27 # pkru register to 0x55555554 by default.
28 set default_pkru_re (0x0|0x55555554)
29 }
30
31
32 set comp_flags "-I${srcdir}/../nat/"
33
34 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
35 [list debug additional_flags=${comp_flags}]] } {
36 untested "failed to compile x86 PKEYS test."
37 return -1
38 }
39
40 if ![runto_main] {
41 return -1
42 }
43
44 set supports_pkru 0
45 set test "probe PKRU support"
46 gdb_test_multiple "print have_pkru()" $test {
47 -re ".. = 1\r\n$gdb_prompt $" {
48 pass $test
49 set supports_pkru 1
50 }
51 -re ".. = 0\r\n$gdb_prompt $" {
52 pass $test
53 }
54 }
55
56 if { !$supports_pkru } {
57 unsupported "processor does not support protection key feature."
58 return
59 }
60
61 # Test pkru register at startup
62 gdb_test "print /x \$pkru" "= $default_pkru_re" "pkru register"
63
64 # Read values from pseudo registers.
65 gdb_breakpoint [ gdb_get_line_number "break here 1" ]
66 gdb_continue_to_breakpoint "break here 1" ".*break here 1.*"
67
68 gdb_test "info register pkru" ".*pkru.*0x12345678.*" "read pkru register"
69 gdb_test "print /x \$pkru = 0x44444444" "= 0x44444444" "set pkru value"
70 gdb_test "info register pkru" ".*pkru.*0x44444444.*" "read value after setting value"
71
72 gdb_breakpoint [ gdb_get_line_number "break here 2" ]
73 gdb_continue_to_breakpoint "break here 2" ".*break here 2.*"
74
75 gdb_test "print /x rd_value" "= 0x44444444" "variable after reading pkru"