]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-mpx-simple_segv.exp
CommitLineData
e2882c85 1# Copyright (C) 2015-2018 Free Software Foundation, Inc.
012b3a21
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# Testing handle setup together with boundary violation signals.
19#
20# Some states are not allowed as reported on the manual, as noprint
21# implies nostop, but nostop might print.
22#
23# Caveat: Setting the handle to nopass, ends up in a endless loop.
24
25if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
26 verbose "Skipping x86 MPX tests."
27 return
28}
29
30standard_testfile
31
32set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
33
5b362f04 34if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
012b3a21
WT
35 [list debug nowarnings additional_flags=${comp_flags}]] } {
36 return -1
37}
38
39if ![runto_main] {
40 untested "could not run to main"
41 return -1
42}
43
44gdb_test_multiple "print have_mpx ()" "have mpx" {
45 -re ".. = 1\r\n$gdb_prompt " {
46 pass "check whether processor supports MPX"
47 }
48 -re ".. = 0\r\n$gdb_prompt " {
49 verbose "processor does not support MPX; skipping MPX tests"
50 return
51 }
52}
53
54set violation [multi_line "Program received signal SIGSEGV, Segmentation fault" \
55 "Upper bound violation while accessing address $hex" \
56 "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
57
58set segv_with_exit "Program received signal SIGSEGV,\
59 Segmentation fault.*$inferior_exited_re.*"
60
61
62# Test handler for segmentation fault for:
63# print pass stop
64#
65set parameters "print pass stop"
66with_test_prefix "$parameters" {
67 if ![runto_main] {
68 fail "could not run to main"
69 return -1
70 }
71
72 gdb_test "handle SIGSEGV $parameters"\
73 ".*SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault.*"\
74 "set parameters"
75
cdc7edd7 76 gdb_test "continue" ".*$violation.*" "display"
012b3a21
WT
77
78 gdb_test "where" ".*#0 $hex in upper.*"\
79 "should be in upper"
80}
81
82# Test handler for segmentation fault for:
83# print pass nostop
84#
85set parameters "print pass nostop"
86with_test_prefix "$parameters" {
87 if ![runto_main] {
88 fail "could not run to main"
89 return -1
90 }
91
92 gdb_test "handle SIGSEGV $parameters"\
93 ".*SIGSEGV.*No.*Yes.*Yes.*Segmentation fault.*"\
94 "set parameters"
95
cdc7edd7 96 gdb_test "continue" ".*$segv_with_exit.*" "display"
012b3a21
WT
97
98 gdb_test "where" "No stack." "no inferior"
99}
100
101# Test handler for segmentation fault for:
102# print nopass stop
103#
104set parameters "print nopass stop"
105with_test_prefix "$parameters" {
106 if ![runto_main] {
107 fail "could not run to main"
108 return -1
109 }
110
111 gdb_test "handle SIGSEGV $parameters"\
112 ".*SIGSEGV.*Yes.*Yes.*No.*Segmentation fault.*"\
113 "set parameters"
114
cdc7edd7 115 gdb_test "continue" ".*$violation.*" "display"
012b3a21
WT
116
117 gdb_test "where" ".*#0 $hex in upper.*"\
118 "should be in upper"
119}
120
121# Test handler for segmentation fault for:
122# print nopass stop
123#
124set parameters "noprint pass nostop"
125with_test_prefix "$parameters" {
126 if ![runto_main] {
127 fail "could not run to main"
128 return -1
129 }
130
131 gdb_test "handle SIGSEGV $parameters"\
132 ".*SIGSEGV.*No.*No.*Yes.*Segmentation fault.*"\
133 "set parameters"
134
135 gdb_test "continue" "Continuing\..*$inferior_exited_re.*"\
136 "Display"
137
138 gdb_test "where" "No stack." "no inferior"
139}
140