1 # Copyright 2019-2023 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # Regression test for a GDB internal error that would trigger if a
16 # "catch catch" catchpoint ended up with multiple locations. This
17 # testcase exercises that scenario by building the binary with
18 # -static-libgcc/-static-libstdc++ and a shared library that depends
19 # on the libstc++.so DSO (which is how GDB was built and revealed the
20 # bug), and vice versa.
22 if {[skip_shlib_tests]} {
26 # STATIC_BIN indicates whether to build the main binary with
27 # -static-libgcc/-static-libstdc++. STATIC_LIB is the same, but for
29 proc test_multi_libstdcpp {static_bin static_lib} {
34 set libname "except-multi-location-lib"
35 set srcfile_lib ${srcdir}/${subdir}/${libname}.cc
36 set binfile_lib [standard_output_file ${libname}-$static_bin-$static_lib.so]
37 set lib_flags {debug c++}
39 lappend lib_flags additional_flags=-static-libgcc additional_flags=-static-libstdc++
43 set testfile "except-multi-location-main"
44 set srcfile ${srcdir}/${subdir}/${testfile}.cc
45 set binfile [standard_output_file ${testfile}-$static_bin-$static_lib]
46 set bin_flags [list debug c++ shlib=${binfile_lib}]
48 lappend bin_flags additional_flags=-static-libgcc additional_flags=-static-libstdc++
51 if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
52 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
53 untested "failed to compile"
60 gdb_load_shlib $binfile_lib
66 gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
67 gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)"
68 gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)"
71 gdb_test "info breakpoints" \
73 "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception catch" \
74 "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception throw" \
75 "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception rethrow"]
78 # Try different static/not-static combinations.
79 foreach_with_prefix static_lib {"0" "1"} {
80 foreach_with_prefix static_bin {"0" "1"} {
81 test_multi_libstdcpp $static_lib $static_bin