1 # Copyright (C) 2015-2020 Free Software Foundation, Inc.
3 # Contributed by Intel Corp. <walfred.tedeschi@intel.com>
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.
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.
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/>.
18 # Testing handle setup together with boundary violation signals.
20 # Some states are not allowed as reported on the manual, as noprint
21 # implies nostop, but nostop might print.
23 # Caveat: Setting the handle to nopass, ends up in a endless loop.
25 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
26 verbose "Skipping x86 MPX tests."
32 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
34 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
35 [list debug nowarnings additional_flags=${comp_flags}]] } {
40 untested "could not run to main"
44 gdb_test_multiple "print have_mpx ()" "have mpx" {
45 -re ".. = 1\r\n$gdb_prompt " {
46 pass "check whether processor supports MPX"
48 -re ".. = 0\r\n$gdb_prompt " {
49 verbose "processor does not support MPX; skipping MPX tests"
54 set violation [multi_line "Program received signal SIGSEGV, Segmentation fault" \
55 "Upper bound violation while accessing address $hex" \
56 "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
58 set segv_with_exit "Program received signal SIGSEGV,\
59 Segmentation fault.*$inferior_exited_re.*"
62 # Test handler for segmentation fault for:
65 set parameters "print pass stop"
66 with_test_prefix "$parameters" {
68 fail "could not run to main"
72 gdb_test "handle SIGSEGV $parameters"\
73 ".*SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault.*"\
76 gdb_test "continue" ".*$violation.*" "display"
78 gdb_test "where" ".*#0 $hex in upper.*"\
82 # Test handler for segmentation fault for:
85 set parameters "print pass nostop"
86 with_test_prefix "$parameters" {
88 fail "could not run to main"
92 gdb_test "handle SIGSEGV $parameters"\
93 ".*SIGSEGV.*No.*Yes.*Yes.*Segmentation fault.*"\
96 gdb_test "continue" ".*$segv_with_exit.*" "display"
98 gdb_test "where" "No stack." "no inferior"
101 # Test handler for segmentation fault for:
104 set parameters "print nopass stop"
105 with_test_prefix "$parameters" {
107 fail "could not run to main"
111 gdb_test "handle SIGSEGV $parameters"\
112 ".*SIGSEGV.*Yes.*Yes.*No.*Segmentation fault.*"\
115 gdb_test "continue" ".*$violation.*" "display"
117 gdb_test "where" ".*#0 $hex in upper.*"\
121 # Test handler for segmentation fault for:
124 set parameters "noprint pass nostop"
125 with_test_prefix "$parameters" {
127 fail "could not run to main"
131 gdb_test "handle SIGSEGV $parameters"\
132 ".*SIGSEGV.*No.*No.*Yes.*Segmentation fault.*"\
135 gdb_test "continue" "Continuing\..*$inferior_exited_re.*"\
138 gdb_test "where" "No stack." "no inferior"