Jan Kratochvil 29d49d9
Comments from Sergio Durigan Junior:
Jan Kratochvil 29d49d9
Jan Kratochvil 29d49d9
  The "proper" fix for this whole problem would be to backport the
Jan Kratochvil 29d49d9
  "ambiguous linespec" patch series.  However, it is really not
Jan Kratochvil 29d49d9
  recommended to do that for RHEL GDB, because the patch series is too
Jan Kratochvil 29d49d9
  big and could introduce unwanted regressions.  Instead, what we
Jan Kratochvil 29d49d9
  chose to do was to replace the gdb_assert call by a warning (which
Jan Kratochvil 29d49d9
  allows the user to continue the debugging session), and tell the
Jan Kratochvil 29d49d9
  user that, although more than one location was found for his/her
Jan Kratochvil 29d49d9
  breakpoint, only one will be used.
Jan Kratochvil 29d49d9
Jan Kratochvil 29d49d9
Index: gdb-7.12/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc
Jan Kratochvil 29d49d9
===================================================================
Jan Kratochvil 29d49d9
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 29d49d9
+++ gdb-7.12/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set-main.cc	2016-10-20 21:06:31.849854180 +0200
Jan Kratochvil 29d49d9
@@ -0,0 +1,22 @@
Jan Kratochvil 29d49d9
+/* This testcase is part of GDB, the GNU debugger.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   Copyright 2015 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+   (at your option) any later version.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+   GNU General Public License for more details.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+int
Jan Kratochvil 29d49d9
+main (int argc, char *argv[])
Jan Kratochvil 29d49d9
+{
Jan Kratochvil 29d49d9
+  return 0;
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
Index: gdb-7.12/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc
Jan Kratochvil 29d49d9
===================================================================
Jan Kratochvil 29d49d9
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 29d49d9
+++ gdb-7.12/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.cc	2016-10-20 21:06:31.850854188 +0200
Jan Kratochvil 29d49d9
@@ -0,0 +1,26 @@
Jan Kratochvil 29d49d9
+/* This testcase is part of GDB, the GNU debugger.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   Copyright 2015 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+   (at your option) any later version.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+   GNU General Public License for more details.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+class C
Jan Kratochvil 29d49d9
+  {
Jan Kratochvil 29d49d9
+    public:
Jan Kratochvil 29d49d9
+      C () {}
Jan Kratochvil 29d49d9
+      C (int x) {}
Jan Kratochvil 29d49d9
+  };
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+C a;
Jan Kratochvil 29d49d9
+C b (1);
Jan Kratochvil 29d49d9
Index: gdb-7.12/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp
Jan Kratochvil 29d49d9
===================================================================
Jan Kratochvil 29d49d9
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 29d49d9
+++ gdb-7.12/gdb/testsuite/gdb.cp/gdb-rhbz1186476-internal-error-unqualified-name-re-set.exp	2016-10-20 21:09:33.408270526 +0200
Jan Kratochvil 29d49d9
@@ -0,0 +1,51 @@
Jan Kratochvil 29d49d9
+# Copyright 2015 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+# (at your option) any later version.
Jan Kratochvil 29d49d9
+#
Jan Kratochvil 29d49d9
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+# GNU General Public License for more details.
Jan Kratochvil 29d49d9
+#
Jan Kratochvil 29d49d9
+# You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+if { [skip_cplus_tests] } { continue }
Jan Kratochvil 29d49d9
+if { [skip_shlib_tests] } { continue }
Jan Kratochvil 29d49d9
+if { [is_remote target] } { continue }
Jan Kratochvil 29d49d9
+if { [target_info exists use_gdb_stub] } { continue }
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+set testfile gdb-rhbz1186476-internal-error-unqualified-name-re-set-main
Jan Kratochvil 29d49d9
+set srcfile $testfile.cc
Jan Kratochvil 29d49d9
+set executable $testfile
Jan Kratochvil 29d49d9
+set binfile [standard_output_file $executable]
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+set libtestfile gdb-rhbz1186476-internal-error-unqualified-name-re-set
Jan Kratochvil 29d49d9
+set libsrcfile $libtestfile.cc
Jan Kratochvil 29d49d9
+set sofile [standard_output_file lib$libtestfile.so]
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+# Create and source the file that provides information about the compiler
Jan Kratochvil 29d49d9
+# used to compile the test case.
Jan Kratochvil 29d49d9
+if [get_compiler_info "c++"] {
Jan Kratochvil 29d49d9
+    return -1
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++ "additional_flags=-fPIC"}] != ""
Jan Kratochvil 29d49d9
+     || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list additional_flags=-Wl,-rpath,[file dirname ${sofile}] "c++" shlib=${sofile} ]] != ""} {
Jan Kratochvil 29d49d9
+    untested $libtestfile.exp
Jan Kratochvil 29d49d9
+    return -1
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+clean_restart $executable
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+gdb_test_no_output "set breakpoint pending on"
Jan Kratochvil 29d49d9
+# gdb_breakpoint would print a failure because of some warning messages
Jan Kratochvil 29d49d9
+gdb_test "break C::C" "Breakpoint $decimal \\(C::C\\) pending."
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+#gdb_test "run" "warning: Found more than one location for breakpoint #$decimal; only the first location will be used.(\r\n)+Breakpoint $decimal, C::C.*"
Jan Kratochvil 29d49d9
+gdb_test "run"
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+gdb_test "info break" " in C::C\\(\\) at .* in C::C\\(int\\) at .*"