]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/stack-protector.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / stack-protector.exp
1 # Copyright (C) 2019-2024 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 if {![runto_main]} {
48 return -1
49 }
50
51 # Break on function foo and ensure it stops on the first line of code.
52 gdb_breakpoint "foo"
53
54 if { $protection == "-fstack-protector-all"
55 && [test_compiler_info "gcc-*"] } {
56 setup_xfail "gcc/88432" "*-*-linux*"
57 }
58 gdb_continue_to_breakpoint "foo" ".*break here.*"
59
60 return 1
61 }
62
63 foreach_with_prefix protection $protector_options {
64 simple_func_break_test $protection
65 }