1 # Copyright (C) 2015-2021 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 if { ![supports_mpx_check_pointer_bounds] } {
37 unsupported "processor does not support MPX"
41 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
43 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
44 [list debug nowarnings additional_flags=${comp_flags}]] } {
49 untested "could not run to main"
53 set violation [multi_line "Program received signal SIGSEGV, Segmentation fault" \
54 "Upper bound violation while accessing address $hex" \
55 "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
57 set segv_with_exit "Program received signal SIGSEGV,\
58 Segmentation fault.*$inferior_exited_re.*"
61 # Test handler for segmentation fault for:
64 set parameters "print pass stop"
65 with_test_prefix "$parameters" {
67 fail "could not run to main"
71 gdb_test "handle SIGSEGV $parameters"\
72 ".*SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault.*"\
75 gdb_test "continue" ".*$violation.*" "display"
77 gdb_test "where" ".*#0 $hex in upper.*"\
81 # Test handler for segmentation fault for:
84 set parameters "print pass nostop"
85 with_test_prefix "$parameters" {
87 fail "could not run to main"
91 gdb_test "handle SIGSEGV $parameters"\
92 ".*SIGSEGV.*No.*Yes.*Yes.*Segmentation fault.*"\
95 gdb_test "continue" ".*$segv_with_exit.*" "display"
97 gdb_test "where" "No stack." "no inferior"
100 # Test handler for segmentation fault for:
103 set parameters "print nopass stop"
104 with_test_prefix "$parameters" {
106 fail "could not run to main"
110 gdb_test "handle SIGSEGV $parameters"\
111 ".*SIGSEGV.*Yes.*Yes.*No.*Segmentation fault.*"\
114 gdb_test "continue" ".*$violation.*" "display"
116 gdb_test "where" ".*#0 $hex in upper.*"\
120 # Test handler for segmentation fault for:
123 set parameters "noprint pass nostop"
124 with_test_prefix "$parameters" {
126 fail "could not run to main"
130 gdb_test "handle SIGSEGV $parameters"\
131 ".*SIGSEGV.*No.*No.*Yes.*Segmentation fault.*"\
134 gdb_test "continue" "Continuing\..*$inferior_exited_re.*"\
137 gdb_test "where" "No stack." "no inferior"