]>
Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2013-2015 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 | ||
18 | if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } { | |
19 | verbose "Skipping x86 MPX tests." | |
20 | return | |
21 | } | |
22 | ||
23 | standard_testfile | |
24 | ||
25 | set comp_flags "-fmpx -I${srcdir}/../common" | |
26 | ||
27 | if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ | |
28 | [list debug nowarnings additional_flags=${comp_flags}]] } { | |
29 | return -1 | |
30 | } | |
31 | ||
32 | if ![runto_main] { | |
33 | untested "could not run to main" | |
34 | return -1 | |
35 | } | |
36 | ||
37 | send_gdb "print have_mpx ()\r" | |
38 | gdb_expect { | |
39 | -re ".. = 1\r\n$gdb_prompt " { | |
40 | pass "check whether processor supports MPX" | |
41 | } | |
42 | -re ".. = 0\r\n$gdb_prompt " { | |
43 | verbose "processor does not support MPX; skipping MPX tests" | |
44 | return | |
45 | } | |
46 | -re ".*$gdb_prompt $" { | |
47 | fail "check whether processor supports MPX" | |
48 | } | |
49 | timeout { | |
50 | fail "check whether processor supports MPX (timeout)" | |
51 | } | |
52 | } | |
53 | ||
54 | # Test bndcfg register and bndstatus at startup | |
55 | set test_string "\\\{raw = 0x\[0-9a-f\]+, config = \\\{base = \[0-9\]+,\ | |
56 | reserved = \[0-9\]+, preserved = \[0-9\]+, enabled = \[0-9\]+\\\}\\\}" | |
57 | ||
58 | gdb_test "print \$bndcfgu" $test_string "bndcfgu formating" | |
59 | gdb_test "print \$bndcfgu.config.enabled" "= 1" "test if bndstatus is enabled" | |
60 | gdb_test "print \$bndstatus" "\\\{raw = 0x0, status = \\\{bde = 0, error = 0\\\}\\\}" \ | |
61 | "bndstatus formating" | |
62 | gdb_test "print \$bndstatus.raw" "= \\\(void \\\*\\\) 0x0" "bndstatus is zero by startup" | |
63 | ||
64 | # Read values from pseudo registers. | |
65 | gdb_breakpoint [ gdb_get_line_number "break here" ] | |
66 | gdb_continue_to_breakpoint "break here" ".*break here.*" | |
67 | ||
68 | set test_string ".*\\\{lbound = 0xa, ubound = 0x13\\\}.*" | |
69 | gdb_test "info register bnd0" ".*bnd0$test_string" "Pure bnd0 register" | |
70 | ||
71 | set test_string ".*\\\{lbound = 0x14, ubound = 0x1d\\\}.*" | |
72 | gdb_test "info register bnd1" ".*bnd1$test_string" "Pure bnd1 register" | |
73 | ||
74 | set test_string ".*\\\{lbound = 0x1e, ubound = 0x27\\\}.*" | |
75 | gdb_test "info register bnd2" ".*bnd2$test_string" "Pure bnd2 register" | |
76 | ||
77 | set test_string ".*\\\{lbound = 0x28, ubound = 0x31\\\}.*" | |
78 | gdb_test "info register bnd3" ".*bnd3$test_string" "Pure bnd3 register" | |
79 | ||
80 | # Read value from registers bndrs. | |
81 | ||
82 | set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+ec\\\}.*" | |
83 | gdb_test "info register bnd0raw" ".*bnd0$test_string" "Pure bnd0r register" | |
84 | ||
85 | set test_string ".*\\\{lbound = 0x14, ubound_raw = 0x\[f\]+e2\\\}.*" | |
86 | gdb_test "info register bnd1raw" ".*bnd1$test_string" "Pure bnd1r register" | |
87 | ||
88 | set test_string ".*\\\{lbound = 0x1e, ubound_raw = 0x\[f\]+d8\\\}.*" | |
89 | gdb_test "info register bnd2raw" ".*bnd2$test_string" "Pure bnd2r register" | |
90 | ||
91 | set test_string ".*\\\{lbound = 0x28, ubound_raw = 0x\[f\]+ce\\\}.*" | |
92 | gdb_test "info register bnd3raw" ".*bnd3$test_string" "Pure bnd3r register" | |
93 | ||
94 | # Setting fields on bnds | |
95 | set test_string ".*\\\{lbound = 0xa, ubound = 0x400\\\}.*" | |
96 | gdb_test "print \$bnd0.ubound = 0x400" "= \\\(void \\\*\\\) 0x400" "set value for bnd0.ubound" | |
97 | gdb_test "print \$bnd0" "$test_string" "after setting bnd0.ubound" | |
98 | set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+bff\\\}.*" | |
99 | gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.ubound" | |
100 | ||
101 | set test_string ".*\\\{lbound = 0x1, ubound = 0x400\\\}.*" | |
102 | gdb_test "print \$bnd0.lbound = 0x1" "= \\\(void \\\*\\\) 0x1" "set value for bnd0.lbound" | |
103 | gdb_test "print \$bnd0" "$test_string" "after setting bnd0.lbound" | |
104 | set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x\[f\]+bff\\\}.*" | |
105 | gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.lbound" | |
106 | ||
107 | # Setting fields on bnd0raw. | |
108 | set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x600\\\}.*" | |
109 | gdb_test "print /x \$bnd0raw.ubound_raw = 0x600" "= 0x600" "set value for bnd0raw.ubound" | |
110 | gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.ubound" | |
111 | set test_string ".*\\\{lbound = 0x1, ubound = 0x\[f\]+9ff\\\}.*" | |
112 | gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.ubound" | |
113 | ||
114 | set test_string ".*\\\{lbound = 0x100, ubound_raw = 0x600\\\}.*" | |
115 | gdb_test "print /x \$bnd0raw.lbound = 0x100" "= 0x100" "set value for bnd0raw.lbound" | |
116 | gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.lbound" | |
117 | set test_string ".*\\\{lbound = 0x100, ubound = 0x\[f\]+9ff\\\}.*" | |
118 | gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.lbound" | |
119 | ||
120 | # Set full value bnd raw | |
121 | set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*" | |
122 | gdb_test "print /x \$bnd0raw = {0x10, ~0x300}" "$test_string" "set full value for bnd0raw" | |
123 | set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*" | |
124 | gdb_test "print /x \$bnd0" "$test_string" "bnd0raw after setting full bnd0raw" | |
125 | ||
126 | # Set full value bnd | |
127 | set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*" | |
128 | gdb_test "print /x \$bnd0 = {0x10, 0x300}" "$test_string" "set full value for bnd0" | |
129 | set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*" | |
130 | gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting full bnd0" | |
131 | ||
132 | # Test bndcfg register and bndstatus after a failure on bndstr | |
133 | gdb_test "print \$bndstatus.status.error" "= 2" "bndstatus error is 2\ | |
134 | after a failure on allocating an entry" | |
135 | ||
136 | # Going to test the python extension for lenght. | |
137 | if { [skip_python_tests] } { continue } | |
138 | # Verify if size is right | |
139 | set test_string ".*\\\: size 17.*" | |
140 | gdb_test "print /x \$bnd0 = {0x10, 0x20}" "$test_string" "verify size for bnd0" | |
141 | ||
142 | send_gdb "quit\n" |