Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-mpx-simple_segv.exp
CommitLineData
88b9d363 1# Copyright (C) 2015-2022 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
5beb4d17
TV
32if { ![supports_mpx_check_pointer_bounds] } {
33 return -1
34}
35
3f94e588
TV
36if { ![have_mpx] } {
37 unsupported "processor does not support MPX"
38 return -1
39}
40
012b3a21
WT
41set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
42
5b362f04 43if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
012b3a21
WT
44 [list debug nowarnings additional_flags=${comp_flags}]] } {
45 return -1
46}
47
48if ![runto_main] {
49 untested "could not run to main"
50 return -1
51}
52
012b3a21
WT
53set violation [multi_line "Program received signal SIGSEGV, Segmentation fault" \
54 "Upper bound violation while accessing address $hex" \
55 "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
56
57set segv_with_exit "Program received signal SIGSEGV,\
58 Segmentation fault.*$inferior_exited_re.*"
59
60
61# Test handler for segmentation fault for:
62# print pass stop
63#
64set parameters "print pass stop"
65with_test_prefix "$parameters" {
66 if ![runto_main] {
67 fail "could not run to main"
68 return -1
69 }
70
71 gdb_test "handle SIGSEGV $parameters"\
72 ".*SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault.*"\
73 "set parameters"
74
cdc7edd7 75 gdb_test "continue" ".*$violation.*" "display"
012b3a21
WT
76
77 gdb_test "where" ".*#0 $hex in upper.*"\
78 "should be in upper"
79}
80
81# Test handler for segmentation fault for:
82# print pass nostop
83#
84set parameters "print pass nostop"
85with_test_prefix "$parameters" {
86 if ![runto_main] {
87 fail "could not run to main"
88 return -1
89 }
90
91 gdb_test "handle SIGSEGV $parameters"\
92 ".*SIGSEGV.*No.*Yes.*Yes.*Segmentation fault.*"\
93 "set parameters"
94
cdc7edd7 95 gdb_test "continue" ".*$segv_with_exit.*" "display"
012b3a21
WT
96
97 gdb_test "where" "No stack." "no inferior"
98}
99
100# Test handler for segmentation fault for:
101# print nopass stop
102#
103set parameters "print nopass stop"
104with_test_prefix "$parameters" {
105 if ![runto_main] {
106 fail "could not run to main"
107 return -1
108 }
109
110 gdb_test "handle SIGSEGV $parameters"\
111 ".*SIGSEGV.*Yes.*Yes.*No.*Segmentation fault.*"\
112 "set parameters"
113
cdc7edd7 114 gdb_test "continue" ".*$violation.*" "display"
012b3a21
WT
115
116 gdb_test "where" ".*#0 $hex in upper.*"\
117 "should be in upper"
118}
119
120# Test handler for segmentation fault for:
121# print nopass stop
122#
123set parameters "noprint pass nostop"
124with_test_prefix "$parameters" {
125 if ![runto_main] {
126 fail "could not run to main"
127 return -1
128 }
129
130 gdb_test "handle SIGSEGV $parameters"\
131 ".*SIGSEGV.*No.*No.*Yes.*Segmentation fault.*"\
132 "set parameters"
133
134 gdb_test "continue" "Continuing\..*$inferior_exited_re.*"\
135 "Display"
136
137 gdb_test "where" "No stack." "no inferior"
138}
139
This page took 0.701601 seconds and 4 git commands to generate.