]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp
bb3b4f8d3bfb891e24c1a79ac87c87967dda194b
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-mpx-sigsegv.exp
1 # Copyright (C) 2015-2017 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
19 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
20 verbose "Skipping x86 MPX tests."
21 return
22 }
23
24 standard_testfile
25
26 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
27
28 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
29 [list debug nowarnings additional_flags=${comp_flags}]] } {
30 return -1
31 }
32
33 if ![runto_main] {
34 untested "could not run to main"
35 return -1
36 }
37
38 gdb_test_multiple "print have_mpx ()" "have mpx" {
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 }
47
48 set u_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \
49 "Upper bound violation while accessing address $hex" \
50 "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
51
52 set l_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \
53 "Lower bound violation while accessing address $hex" \
54 "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
55
56 for {set i 0} {$i < 15} {incr i} {
57 set message "MPX signal segv Upper: ${i}"
58
59 if {[gdb_test "continue" "$u_fault.*" $message] != 0} {
60 break
61 }
62
63 gdb_test "where" ".*#0 $hex in upper.*"\
64 "$message: should be in upper"
65 }
66
67 for {set i 0} {$i < 15} {incr i} {
68 set message "MPX signal segv Lower: ${i}"
69
70 if {[gdb_test "continue" "$l_fault.*" $message] != 0} {
71 break
72 }
73
74 gdb_test "where" ".*#0 $hex in lower.*"\
75 "$message: should be in lower"
76 }