Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-mpx.exp
CommitLineData
88b9d363 1# Copyright 2013-2022 Free Software Foundation, Inc.
60650f2e
WT
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
18if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
19 verbose "Skipping x86 MPX tests."
20 return
21}
22
23standard_testfile
24
547a646d
WT
25if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
26 verbose "Skipping x86 MPX tests."
27 return
28}
29
5beb4d17
TV
30if { ![supports_mpx_check_pointer_bounds] } {
31 return -1
32}
33
3f94e588
TV
34if { ![have_mpx] } {
35 unsupported "processor does not support MPX"
36 return -1
37}
38
1a2ccd2e 39set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
60650f2e 40
5b362f04 41if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
422d944b 42 [list debug nowarnings additional_flags=${comp_flags}]] } {
60650f2e
WT
43 return -1
44}
45
46if ![runto_main] {
47 untested "could not run to main"
48 return -1
49}
50
60650f2e
WT
51# Test bndcfg register and bndstatus at startup
52set test_string "\\\{raw = 0x\[0-9a-f\]+, config = \\\{base = \[0-9\]+,\
53reserved = \[0-9\]+, preserved = \[0-9\]+, enabled = \[0-9\]+\\\}\\\}"
54
55gdb_test "print \$bndcfgu" $test_string "bndcfgu formating"
56gdb_test "print \$bndcfgu.config.enabled" "= 1" "test if bndstatus is enabled"
57gdb_test "print \$bndstatus" "\\\{raw = 0x0, status = \\\{bde = 0, error = 0\\\}\\\}" \
58 "bndstatus formating"
59gdb_test "print \$bndstatus.raw" "= \\\(void \\\*\\\) 0x0" "bndstatus is zero by startup"
60
61# Read values from pseudo registers.
62gdb_breakpoint [ gdb_get_line_number "break here" ]
63gdb_continue_to_breakpoint "break here" ".*break here.*"
64
65set test_string ".*\\\{lbound = 0xa, ubound = 0x13\\\}.*"
cdc7edd7 66gdb_test "info register bnd0" ".*bnd0$test_string" "pure bnd0 register"
60650f2e
WT
67
68set test_string ".*\\\{lbound = 0x14, ubound = 0x1d\\\}.*"
cdc7edd7 69gdb_test "info register bnd1" ".*bnd1$test_string" "pure bnd1 register"
60650f2e
WT
70
71set test_string ".*\\\{lbound = 0x1e, ubound = 0x27\\\}.*"
cdc7edd7 72gdb_test "info register bnd2" ".*bnd2$test_string" "pure bnd2 register"
60650f2e
WT
73
74set test_string ".*\\\{lbound = 0x28, ubound = 0x31\\\}.*"
cdc7edd7 75gdb_test "info register bnd3" ".*bnd3$test_string" "pure bnd3 register"
60650f2e
WT
76
77# Read value from registers bndrs.
78
79set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+ec\\\}.*"
cdc7edd7 80gdb_test "info register bnd0raw" ".*bnd0$test_string" "pure bnd0r register"
60650f2e
WT
81
82set test_string ".*\\\{lbound = 0x14, ubound_raw = 0x\[f\]+e2\\\}.*"
cdc7edd7 83gdb_test "info register bnd1raw" ".*bnd1$test_string" "pure bnd1r register"
60650f2e
WT
84
85set test_string ".*\\\{lbound = 0x1e, ubound_raw = 0x\[f\]+d8\\\}.*"
cdc7edd7 86gdb_test "info register bnd2raw" ".*bnd2$test_string" "pure bnd2r register"
60650f2e
WT
87
88set test_string ".*\\\{lbound = 0x28, ubound_raw = 0x\[f\]+ce\\\}.*"
cdc7edd7 89gdb_test "info register bnd3raw" ".*bnd3$test_string" "pure bnd3r register"
60650f2e
WT
90
91# Setting fields on bnds
92set test_string ".*\\\{lbound = 0xa, ubound = 0x400\\\}.*"
93gdb_test "print \$bnd0.ubound = 0x400" "= \\\(void \\\*\\\) 0x400" "set value for bnd0.ubound"
94gdb_test "print \$bnd0" "$test_string" "after setting bnd0.ubound"
95set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+bff\\\}.*"
96gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.ubound"
97
98set test_string ".*\\\{lbound = 0x1, ubound = 0x400\\\}.*"
99gdb_test "print \$bnd0.lbound = 0x1" "= \\\(void \\\*\\\) 0x1" "set value for bnd0.lbound"
100gdb_test "print \$bnd0" "$test_string" "after setting bnd0.lbound"
101set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x\[f\]+bff\\\}.*"
102gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.lbound"
103
104# Setting fields on bnd0raw.
105set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x600\\\}.*"
106gdb_test "print /x \$bnd0raw.ubound_raw = 0x600" "= 0x600" "set value for bnd0raw.ubound"
107gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.ubound"
108set test_string ".*\\\{lbound = 0x1, ubound = 0x\[f\]+9ff\\\}.*"
109gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.ubound"
110
111set test_string ".*\\\{lbound = 0x100, ubound_raw = 0x600\\\}.*"
112gdb_test "print /x \$bnd0raw.lbound = 0x100" "= 0x100" "set value for bnd0raw.lbound"
113gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.lbound"
114set test_string ".*\\\{lbound = 0x100, ubound = 0x\[f\]+9ff\\\}.*"
115gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.lbound"
116
117# Set full value bnd raw
118set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*"
119gdb_test "print /x \$bnd0raw = {0x10, ~0x300}" "$test_string" "set full value for bnd0raw"
120set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*"
121gdb_test "print /x \$bnd0" "$test_string" "bnd0raw after setting full bnd0raw"
122
123# Set full value bnd
124set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*"
125gdb_test "print /x \$bnd0 = {0x10, 0x300}" "$test_string" "set full value for bnd0"
126set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*"
127gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting full bnd0"
128
129# Test bndcfg register and bndstatus after a failure on bndstr
130gdb_test "print \$bndstatus.status.error" "= 2" "bndstatus error is 2\
131after a failure on allocating an entry"
132
133# Going to test the python extension for lenght.
134if { [skip_python_tests] } { continue }
135# Verify if size is right
136set test_string ".*\\\: size 17.*"
137gdb_test "print /x \$bnd0 = {0x10, 0x20}" "$test_string" "verify size for bnd0"
138
139send_gdb "quit\n"
This page took 1.097018 seconds and 4 git commands to generate.