From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [RFA] c++/11734
Date: Tue, 22 Jun 2010 01:22:00 -0000 [thread overview]
Message-ID: <4C20103B.1080906@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]
Hi,
c++/11734 involves being unable to set a breakpoint at a method defined
in a different CU from the class declaration. This regression occurs
because the dwarf2_physname patch removes the use of
DW_AT_MIPS_linkage_name.
[You might ask why this is. I refer you to c++/11734 for a more detailed
explanation of how gdb "appeared" to work prior to the dwarf2_physname
patch.]
The attached patch fixes this regression. While testing, I also noticed
a related issue with overloaded methods defined in multiple CUs, and
I've fixed that, too.
Questions/comments/concerns?
Keith
ChangeLog
2010-06-21 Keith Seitz <keiths@redhat.com>
c++/11734
* linespec.c (decode_compound): If saved_arg is surrounded
in single quotes, strip them.
* psymtab.c (lookup_partial_symbol): If the search name
contains overload information, expand any psymtabs that
match the un-overoaded name.
testsuite/ChangeLog
2010-06-21 Keith Seitz <keiths@redhat.com>
c++/11734
* gdb.cp/pr11734.exp: New test.
* gdb.cp/pr11734-1.cc, gdb.cp/pr11734-2.cc, gdb.cp/pr11734-3.cc,
gdb.cp/pr11734-4.cc, gdb.cp/pr11734.h: New files.
[-- Attachment #2: pr11734.patch --]
[-- Type: text/plain, Size: 10927 bytes --]
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.103
diff -u -p -r1.103 linespec.c
--- linespec.c 14 May 2010 23:41:04 -0000 1.103
+++ linespec.c 22 Jun 2010 01:19:12 -0000
@@ -1217,6 +1217,19 @@ decode_compound (char **argptr, int funf
struct type *t;
char *saved_java_argptr = NULL;
+ /* Strip single quotes from SAVED_ARG. This interferes with this function
+ which might, e.g., later call strcmp_iw with SYMBOL_LINKAGE_NAME
+ (which never contains quotes). */
+ if (*saved_arg == '\'')
+ {
+ char *close = strrchr (saved_arg, '\'');
+ if (close)
+ {
+ ++saved_arg;
+ *close = '\0';
+ }
+ }
+
/* First check for "global" namespace specification, of the form
"::foo". If found, skip over the colons and jump to normal
symbol processing. I.e. the whole line specification starts with
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.4
diff -u -p -r1.4 psymtab.c
--- psymtab.c 16 May 2010 01:27:02 -0000 1.4
+++ psymtab.c 22 Jun 2010 01:19:12 -0000
@@ -476,12 +476,39 @@ lookup_partial_symbol (struct partial_sy
if (!(top == bottom))
internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
- while (top <= real_top
- && SYMBOL_MATCHES_SEARCH_NAME (*top, name))
+ while (top <= real_top)
{
- if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
- SYMBOL_DOMAIN (*top), domain))
- return (*top);
+ if (SYMBOL_MATCHES_SEARCH_NAME (*top, name))
+ {
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
+ SYMBOL_DOMAIN (*top), domain))
+ return (*top);
+ }
+ else
+ {
+ char *paren = strchr (name, '(');
+
+ if (paren)
+ {
+ char *new;
+
+ /* NAME has overload information. Partial symbols, however,
+ do not. This is a case of mistaken identity.
+
+ Although hacky, this is fixed by expanding this psymtab,
+ which will allow any subsequent symtab search to succeed.
+
+ For more details/test case, please refer to c++/11734. */
+
+ new = alloca (strlen (name));
+ memcpy (new, name, paren - name);
+ new[name - paren] = '\0';
+ if (SYMBOL_MATCHES_SEARCH_NAME (*top, new))
+ PSYMTAB_TO_SYMTAB (pst);
+ }
+ else
+ break;
+ }
top++;
}
}
Index: testsuite/gdb.cp/pr11734-1.cc
===================================================================
RCS file: testsuite/gdb.cp/pr11734-1.cc
diff -N testsuite/gdb.cp/pr11734-1.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/pr11734-1.cc 22 Jun 2010 01:19:14 -0000
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 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/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+#include "pr11734.h"
+
+int
+main ()
+{
+ pr11734 *p = new pr11734;
+ p->foo ();
+ return 0;
+}
+
Index: testsuite/gdb.cp/pr11734-2.cc
===================================================================
RCS file: testsuite/gdb.cp/pr11734-2.cc
diff -N testsuite/gdb.cp/pr11734-2.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/pr11734-2.cc 22 Jun 2010 01:19:14 -0000
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 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/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+#include "pr11734.h"
+
+void
+pr11734::foo(void)
+{
+}
+
Index: testsuite/gdb.cp/pr11734-3.cc
===================================================================
RCS file: testsuite/gdb.cp/pr11734-3.cc
diff -N testsuite/gdb.cp/pr11734-3.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/pr11734-3.cc 22 Jun 2010 01:19:14 -0000
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 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/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+#include "pr11734.h"
+
+void
+pr11734::foo (int a)
+{
+}
+
Index: testsuite/gdb.cp/pr11734-4.cc
===================================================================
RCS file: testsuite/gdb.cp/pr11734-4.cc
diff -N testsuite/gdb.cp/pr11734-4.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/pr11734-4.cc 22 Jun 2010 01:19:14 -0000
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 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/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+#include "pr11734.h"
+
+void
+pr11734::foo (char *a)
+{
+}
+
Index: testsuite/gdb.cp/pr11734.exp
===================================================================
RCS file: testsuite/gdb.cp/pr11734.exp
diff -N testsuite/gdb.cp/pr11734.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/pr11734.exp 22 Jun 2010 01:19:14 -0000
@@ -0,0 +1,67 @@
+# Copyright 2010 Free Software Foundation, Inc.
+#
+# Contributed by Red Hat, originally written by Keith Seitz.
+#
+# 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/>.
+
+# This file is part of the gdb testsuite.
+
+if { [skip_cplus_tests] } { continue }
+
+set testfile "pr11734"
+set class $testfile
+set binfile [file join $objdir $subdir $testfile]
+
+set srcfiles {}
+for {set i 1} {$i < 5} {incr i} {
+ lappend srcfiles [file join $srcdir $subdir $testfile-$i.cc]
+}
+if {[gdb_compile $srcfiles $binfile executable {debug c++}] != "" } {
+ untested pr11734.exp
+ return -1
+}
+
+if {[get_compiler_info $binfile "c++"]} {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+if {![runto_main]} {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+# An array holding the overload types for the method pr11734::foo. The
+# first element is the overloaded method parameter. The second element
+# is the expected source file number, e.g. "pr11734-?.cc".
+array set tests {
+ "char*" 4
+ "int" 3
+ "" 2
+}
+
+# Test each overload instance twice: once quoted, once unquoted
+foreach ovld [array names tests] {
+ set method "${class}::foo\($ovld\)"
+ set result "Breakpoint (\[0-9\]).*file .*/$class-$tests($ovld).*"
+ gdb_test "break $method" $result
+ gdb_test "break '$method'" $result
+}
+
+gdb_exit
+return 0
Index: testsuite/gdb.cp/pr11734.h
===================================================================
RCS file: testsuite/gdb.cp/pr11734.h
diff -N testsuite/gdb.cp/pr11734.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/pr11734.h 22 Jun 2010 01:19:14 -0000
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 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/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+class pr11734
+{
+ public:
+ void foo ();
+ void foo (int);
+ void foo (char *);
+};
+
next reply other threads:[~2010-06-22 1:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-22 1:22 Keith Seitz [this message]
2010-06-22 9:45 ` Pedro Alves
2010-06-22 15:43 ` Keith Seitz
2010-06-23 17:33 ` Keith Seitz
2010-06-24 2:25 ` Doug Evans
2010-06-24 11:39 ` Matt Rice
2010-06-24 16:05 ` Doug Evans
2010-06-24 20:01 ` Tom Tromey
2010-06-24 20:49 ` Doug Evans
2010-06-24 20:51 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C20103B.1080906@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox