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