Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.cp / except-multi-location.exp
blob02e999fdc23c510563f021d02cb4cb49c94362a7
1 # Copyright 2019-2024 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 require allow_shlib_tests
24 # STATIC_BIN indicates whether to build the main binary with
25 # -static-libgcc/-static-libstdc++.  STATIC_LIB is the same, but for
26 # the shared library.
27 proc test_multi_libstdcpp {static_bin static_lib} {
28     global srcdir subdir
29     global decimal hex
31     # Library file.
32     set libname "except-multi-location-lib"
33     set srcfile_lib ${srcdir}/${subdir}/${libname}.cc
34     set binfile_lib [standard_output_file ${libname}-$static_bin-$static_lib.so]
35     set lib_flags {debug c++}
36     if {$static_lib} {
37         lappend lib_flags additional_flags=-static-libgcc additional_flags=-static-libstdc++
38     }
40     # Binary file.
41     set testfile "except-multi-location-main"
42     set srcfile ${srcdir}/${subdir}/${testfile}.cc
43     set binfile [standard_output_file ${testfile}-$static_bin-$static_lib]
44     set bin_flags [list debug c++ shlib=${binfile_lib}]
45     if {$static_bin} {
46         lappend bin_flags additional_flags=-static-libgcc additional_flags=-static-libstdc++
47     }
49     if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
50          || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
51         untested "failed to compile"
52         return -1
53     }
55     clean_restart
57     gdb_load ${binfile}
58     gdb_load_shlib $binfile_lib
60     if ![runto_main] {
61         return 0
62     }
64     gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
65     gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)"
66     gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)"
68     set ws "\[ \t\]*"
69     gdb_test "info breakpoints" \
70         [multi_line \
71              "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception catch" \
72              "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception throw" \
73              "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception rethrow"]
76 # Try different static/not-static combinations.
77 foreach_with_prefix static_lib {"0" "1"} {
78     foreach_with_prefix static_bin {"0" "1"} {
79         test_multi_libstdcpp $static_lib $static_bin
80     }