]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/i386-mpx.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-mpx.exp
1 # Copyright 2013-2023 Free Software Foundation, Inc.
2 #
3 # Contributed by Intel Corp. <walfred.tedeschi@intel.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
19 verbose "Skipping x86 MPX tests."
20 return
21 }
22
23 standard_testfile
24
25 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
26 verbose "Skipping x86 MPX tests."
27 return
28 }
29
30 if { ![supports_mpx_check_pointer_bounds] } {
31 return -1
32 }
33
34 if { ![have_mpx] } {
35 unsupported "processor does not support MPX"
36 return -1
37 }
38
39 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
40
41 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
42 [list debug nowarnings additional_flags=${comp_flags}]] } {
43 return -1
44 }
45
46 if ![runto_main] {
47 return -1
48 }
49
50 # Test bndcfg register and bndstatus at startup
51 set test_string "\\\{raw = 0x\[0-9a-f\]+, config = \\\{base = \[0-9\]+,\
52 reserved = \[0-9\]+, preserved = \[0-9\]+, enabled = \[0-9\]+\\\}\\\}"
53
54 gdb_test "print \$bndcfgu" $test_string "bndcfgu formating"
55 gdb_test "print \$bndcfgu.config.enabled" "= 1" "test if bndstatus is enabled"
56 gdb_test "print \$bndstatus" "\\\{raw = 0x0, status = \\\{bde = 0, error = 0\\\}\\\}" \
57 "bndstatus formating"
58 gdb_test "print \$bndstatus.raw" "= \\\(void \\\*\\\) 0x0" "bndstatus is zero by startup"
59
60 # Read values from pseudo registers.
61 gdb_breakpoint [ gdb_get_line_number "break here" ]
62 gdb_continue_to_breakpoint "break here" ".*break here.*"
63
64 set test_string ".*\\\{lbound = 0xa, ubound = 0x13\\\}.*"
65 gdb_test "info register bnd0" ".*bnd0$test_string" "pure bnd0 register"
66
67 set test_string ".*\\\{lbound = 0x14, ubound = 0x1d\\\}.*"
68 gdb_test "info register bnd1" ".*bnd1$test_string" "pure bnd1 register"
69
70 set test_string ".*\\\{lbound = 0x1e, ubound = 0x27\\\}.*"
71 gdb_test "info register bnd2" ".*bnd2$test_string" "pure bnd2 register"
72
73 set test_string ".*\\\{lbound = 0x28, ubound = 0x31\\\}.*"
74 gdb_test "info register bnd3" ".*bnd3$test_string" "pure bnd3 register"
75
76 # Read value from registers bndrs.
77
78 set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+ec\\\}.*"
79 gdb_test "info register bnd0raw" ".*bnd0$test_string" "pure bnd0r register"
80
81 set test_string ".*\\\{lbound = 0x14, ubound_raw = 0x\[f\]+e2\\\}.*"
82 gdb_test "info register bnd1raw" ".*bnd1$test_string" "pure bnd1r register"
83
84 set test_string ".*\\\{lbound = 0x1e, ubound_raw = 0x\[f\]+d8\\\}.*"
85 gdb_test "info register bnd2raw" ".*bnd2$test_string" "pure bnd2r register"
86
87 set test_string ".*\\\{lbound = 0x28, ubound_raw = 0x\[f\]+ce\\\}.*"
88 gdb_test "info register bnd3raw" ".*bnd3$test_string" "pure bnd3r register"
89
90 # Setting fields on bnds
91 set test_string ".*\\\{lbound = 0xa, ubound = 0x400\\\}.*"
92 gdb_test "print \$bnd0.ubound = 0x400" "= \\\(void \\\*\\\) 0x400" "set value for bnd0.ubound"
93 gdb_test "print \$bnd0" "$test_string" "after setting bnd0.ubound"
94 set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+bff\\\}.*"
95 gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.ubound"
96
97 set test_string ".*\\\{lbound = 0x1, ubound = 0x400\\\}.*"
98 gdb_test "print \$bnd0.lbound = 0x1" "= \\\(void \\\*\\\) 0x1" "set value for bnd0.lbound"
99 gdb_test "print \$bnd0" "$test_string" "after setting bnd0.lbound"
100 set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x\[f\]+bff\\\}.*"
101 gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.lbound"
102
103 # Setting fields on bnd0raw.
104 set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x600\\\}.*"
105 gdb_test "print /x \$bnd0raw.ubound_raw = 0x600" "= 0x600" "set value for bnd0raw.ubound"
106 gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.ubound"
107 set test_string ".*\\\{lbound = 0x1, ubound = 0x\[f\]+9ff\\\}.*"
108 gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.ubound"
109
110 set test_string ".*\\\{lbound = 0x100, ubound_raw = 0x600\\\}.*"
111 gdb_test "print /x \$bnd0raw.lbound = 0x100" "= 0x100" "set value for bnd0raw.lbound"
112 gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.lbound"
113 set test_string ".*\\\{lbound = 0x100, ubound = 0x\[f\]+9ff\\\}.*"
114 gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.lbound"
115
116 # Set full value bnd raw
117 set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*"
118 gdb_test "print /x \$bnd0raw = {0x10, ~0x300}" "$test_string" "set full value for bnd0raw"
119 set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*"
120 gdb_test "print /x \$bnd0" "$test_string" "bnd0raw after setting full bnd0raw"
121
122 # Set full value bnd
123 set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*"
124 gdb_test "print /x \$bnd0 = {0x10, 0x300}" "$test_string" "set full value for bnd0"
125 set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*"
126 gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting full bnd0"
127
128 # Test bndcfg register and bndstatus after a failure on bndstr
129 gdb_test "print \$bndstatus.status.error" "= 2" "bndstatus error is 2\
130 after a failure on allocating an entry"
131
132 # Going to test the python extension for lenght.
133 if { [skip_python_tests] } { continue }
134 # Verify if size is right
135 set test_string ".*\\\: size 0x11.*"
136 gdb_test "print /x \$bnd0 = {0x10, 0x20}" "$test_string" "verify size for bnd0"