Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / stack-protector.exp
blob75fc56a92fc233600a343af5c2cd9159cc905d93
1 # Copyright (C) 2019-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test breakpoints work correctly when stack protector is used.
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.
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
30 standard_testfile
32 set protector_options { "-fno-stack-protector" "-fstack-protector" \
33 "-fstack-protector-all" "-fstack-protector-strong" }
35 proc simple_func_break_test { protection } {
36 global testfile
37 global srcfile
38 global binfile
40 set options debug
41 lappend options additional_flags=$protection
43 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options]} {
44 return -1
47 if {![runto_main]} {
48 return -1
51 # Break on function foo and ensure it stops on the first line of code.
52 gdb_breakpoint "foo"
54 if { $protection == "-fstack-protector-all"
55 && [test_compiler_info "gcc-*"] } {
56 setup_xfail "gcc/88432" "*-*-linux*"
58 gdb_continue_to_breakpoint "foo" ".*break here.*"
60 return 1
63 foreach_with_prefix protection $protector_options {
64 simple_func_break_test $protection