aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.cp/except-multi-location-lib.cc25
-rw-r--r--gdb/testsuite/gdb.cp/except-multi-location-main.cc36
-rw-r--r--gdb/testsuite/gdb.cp/except-multi-location.exp87
4 files changed, 155 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3df5e58..46a1647 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-09 Pedro Alves <palves@redhat.com>
+
+ PR c++/15468
+ * gdb.cp/except-multi-location-lib.cc: New.
+ * gdb.cp/except-multi-location-main.cc: New.
+ * gdb.cp/except-multi-location.exp: New.
+
2019-07-09 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/printcmds.exp (test_printf_convenience_var): Set
diff --git a/gdb/testsuite/gdb.cp/except-multi-location-lib.cc b/gdb/testsuite/gdb.cp/except-multi-location-lib.cc
new file mode 100644
index 0000000..8767d75
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/except-multi-location-lib.cc
@@ -0,0 +1,25 @@
+/* Copyright 2019 Free Software Foundation, Inc.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+void
+trycatch_lib ()
+{
+ try
+ {
+ throw 1;
+ }
+ catch (...)
+ {
+ }
+}
diff --git a/gdb/testsuite/gdb.cp/except-multi-location-main.cc b/gdb/testsuite/gdb.cp/except-multi-location-main.cc
new file mode 100644
index 0000000..161897a
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/except-multi-location-main.cc
@@ -0,0 +1,36 @@
+/* Copyright 2019 Free Software Foundation, Inc.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+extern void trycatch_lib ();
+
+void
+trycatch_main ()
+{
+ try
+ {
+ throw 1;
+ }
+ catch (...)
+ {
+ }
+}
+
+int
+main ()
+{
+ trycatch_lib ();
+ trycatch_main ();
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/except-multi-location.exp b/gdb/testsuite/gdb.cp/except-multi-location.exp
new file mode 100644
index 0000000..60d6d0b
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/except-multi-location.exp
@@ -0,0 +1,87 @@
+# Copyright 2019 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Regression test for a GDB internal error that would trigger if a
+# "catch catch" catchpoint ended up with multiple locations. This
+# testcase exercises that scenario by building the binary with
+# -static-libgcc/-static-libstdc++ and a shared library that depends
+# on the libstc++.so DSO (which is how GDB was built and revealed the
+# bug), and vice versa.
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+# STATIC_BIN indicates whether to build the main binary with
+# -static-libgcc/-static-libstdc++. STATIC_LIB is the same, but for
+# the shared library.
+proc test_multi_libstdcpp {static_bin static_lib} {
+ global srcdir subdir
+ global decimal hex
+
+ # Library file.
+ set libname "except-multi-location-lib"
+ set srcfile_lib ${srcdir}/${subdir}/${libname}.cc
+ set binfile_lib [standard_output_file ${libname}-$static_bin-$static_lib.so]
+ set lib_flags {debug c++}
+ if {$static_lib} {
+ lappend lib_flags additional_flags=-static-libgcc additional_flags=-static-libstdc++
+ }
+
+ # Binary file.
+ set testfile "except-multi-location-main"
+ set srcfile ${srcdir}/${subdir}/${testfile}.cc
+ set binfile [standard_output_file ${testfile}-$static_bin-$static_lib]
+ set bin_flags [list debug c++ shlib=${binfile_lib}]
+ if {$static_bin} {
+ lappend bin_flags additional_flags=-static-libgcc additional_flags=-static-libstdc++
+ }
+
+ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
+ || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
+ untested "failed to compile"
+ return -1
+ }
+
+ clean_restart
+
+ gdb_load ${binfile}
+ gdb_load_shlib $binfile_lib
+
+ if ![runto_main] {
+ fail "can't run to main"
+ return 0
+ }
+
+ gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \
+ "catch catch"
+ gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
+ "catch throw"
+ gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" \
+ "catch rethrow"
+
+ set ws "\[ \t\]*"
+ gdb_test "info breakpoints" \
+ [multi_line \
+ "${decimal}${ws}breakpoint${ws}keep${ws}y${ws}${hex}${ws}exception catch" \
+ "${decimal}${ws}breakpoint${ws}keep${ws}y${ws}${hex}${ws}exception throw" \
+ "${decimal}${ws}breakpoint${ws}keep${ws}y${ws}${hex}${ws}exception rethrow"]
+}
+
+# Try different static/not-static combinations.
+foreach_with_prefix static_lib {"0" "1"} {
+ foreach_with_prefix static_bin {"0" "1"} {
+ test_multi_libstdcpp $static_lib $static_bin
+ }
+}