[gdb/testsuite] Split up multi-exec test-cases
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / stack-protector.exp
1 # Copyright (C) 2019-2020 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # Test breakpoints work correctly when stack protector is used.
17
18 # Note on Debian/Ubuntu, stack protector is on by default, and is
19 # currently force disabled in gdb_compile due to the XFAIL below.
20
21 # Ensure the compiler is gcc/clang and is new enough to support stack
22 # protection.
23 if { !([test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"])
24 || [test_compiler_info {gcc-[0-3]-*}]
25 || [test_compiler_info {gcc-4-0-*}]
26 || [test_compiler_info {clang-[0-4]=*}] } {
27 return 0
28 }
29
30 standard_testfile
31
32 set protector_options { "-fno-stack-protector" "-fstack-protector" \
33 "-fstack-protector-all" "-fstack-protector-strong" }
34
35 proc simple_func_break_test { protection } {
36 global testfile
37 global srcfile
38 global binfile
39
40 set options debug
41 lappend options additional_flags=$protection
42
43 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options]} {
44 return -1
45 }
46
47 clean_restart ${binfile}
48
49 if { ![runto_main] } then {
50 fail "can't run to main"
51 return -1
52 }
53
54 # Break on function foo and ensure it stops on the first line of code.
55 gdb_breakpoint "foo"
56
57 if { $protection == "-fstack-protector-all"
58 && [test_compiler_info "gcc-*"] } {
59 setup_xfail "gcc/88432" "*-*-linux*"
60 }
61 gdb_continue_to_breakpoint "foo" ".*break here.*"
62
63 return 1
64 }
65
66 foreach_with_prefix protection $protector_options {
67 simple_func_break_test $protection
68 }
This page took 0.030959 seconds and 4 git commands to generate.