* [patch] Fix C++ demangling of minsyms with symver
@ 2011-06-02 15:33 Jan Kratochvil
2011-06-02 18:04 ` Tom Tromey
2011-06-02 21:45 ` Jan Kratochvil
0 siblings, 2 replies; 4+ messages in thread
From: Jan Kratochvil @ 2011-06-02 15:33 UTC (permalink / raw)
To: gdb-patches
Hi,
this is not for any regressions, just while playing with breakpoints I have
noticed GDB cannot break on some libstdc++ versioned symbols because the
demangler fails due to the `@...' suffix:
00000000000607d0 T std::istream::ignore()@@GLIBCXX_3.4.5
00000000000607d0 T std::istream::ignore()@GLIBCXX_3.4
(gdb) b 'std::istream::ignore()@GLIBCXX_3.4'
Breakpoint 1 at 0x607d0: file /usr/src/debug/gcc-4.6.0-20110509/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/istream.tcc, line 461.
(gdb) b 'std::istream::ignore()@@GLIBCXX_3.4.5'
Note: breakpoint 1 also set at pc 0x607d0.
Breakpoint 2 at 0x607d0: file /usr/src/debug/gcc-4.6.0-20110509/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/istream.tcc, line 461.
(gdb) b 'std::istream::ignore()'
Function "std::istream::ignore()" not defined.
This is not exactly reproducible with FSF GDB HEAD + this patch as it needs
other patches (such as removing DMGL_VERBOSE and others). But it is
independent enough with a clear testcase so posting it separately for
simplicity.
One can see the default resolving to the @@ variant is not implemented. Not
sure if it should be but let that be a possible incremental patch in the
future.
No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu. I will check
it in (not for 7.3) in some time if no comments appear.
Thanks,
Jan
gdb/
2011-06-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* symtab.c (symbol_find_demangled_name): New parameter objfile. Always
call bfd_demangle, not cplus_demangle.
(symbol_set_names): Pass OBJFILE.
gdb/testsuite/
2011-06-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.cp/cp-symver.cc: New file.
* gdb.cp/cp-symver.exp: New file.
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -478,7 +478,7 @@ create_demangled_names_hash (struct objfile *objfile)
static char *
symbol_find_demangled_name (struct general_symbol_info *gsymbol,
- const char *mangled)
+ const char *mangled, struct objfile *objfile)
{
char *demangled = NULL;
@@ -499,8 +499,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
if (gsymbol->language == language_cplus
|| gsymbol->language == language_auto)
{
- demangled =
- cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
+ demangled = bfd_demangle (objfile->obfd, mangled,
+ DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
if (demangled != NULL)
{
gsymbol->language = language_cplus;
@@ -509,9 +509,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
}
if (gsymbol->language == language_java)
{
- demangled =
- cplus_demangle (mangled,
- DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
+ demangled = bfd_demangle (objfile->obfd, mangled,
+ DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
if (demangled != NULL)
{
gsymbol->language = language_java;
@@ -651,7 +650,8 @@ symbol_set_names (struct general_symbol_info *gsymbol,
if (*slot == NULL)
{
char *demangled_name = symbol_find_demangled_name (gsymbol,
- linkage_name_copy);
+ linkage_name_copy,
+ objfile);
int demangled_len = demangled_name ? strlen (demangled_name) : 0;
/* Suppose we have demangled_name==NULL, copy_name==0, and
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cp-symver.cc
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 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 a () {} /* at-func-a */
+
+/* Give `a' external name `v()' requiring version `VER_A'. */
+asm (".symver _Z1av, _Z1vv@VER_A");
+
+void b () {} /* at-func-b */
+
+/* Give `b' external name `v()' with default version `VER_B'. */
+asm (".symver _Z1bv, _Z1vv@@VER_B");
+
+int
+main ()
+{
+ a ();
+ b ();
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cp-symver.exp
@@ -0,0 +1,38 @@
+# Copyright 2011 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/>.
+
+# Test C++ demangling of versioned symbols.
+
+set testfile cp-symver
+set srcfile ${testfile}.cc
+if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+ return -1
+}
+
+if ![runto_main] {
+ untested ${testfile}.exp
+ return -1
+}
+
+gdb_test_no_output "set breakpoint pending off"
+
+gdb_breakpoint {'v()@VER_A'}
+gdb_breakpoint {'v()@@VER_B'}
+
+# GDB currently does not support the default version assumption.
+gdb_test "break v()" {Function "v\(\)" not defined\.}
+
+gdb_continue_to_breakpoint "a" ".* at-func-a .*"
+gdb_continue_to_breakpoint "b" ".* at-func-b .*"
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] Fix C++ demangling of minsyms with symver
2011-06-02 15:33 [patch] Fix C++ demangling of minsyms with symver Jan Kratochvil
@ 2011-06-02 18:04 ` Tom Tromey
2011-06-02 18:24 ` Jan Kratochvil
2011-06-02 21:45 ` Jan Kratochvil
1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2011-06-02 18:04 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> * symtab.c (symbol_find_demangled_name): New parameter objfile. Always
Jan> call bfd_demangle, not cplus_demangle.
Jan> (symbol_set_names): Pass OBJFILE.
The patch looks reasonable in itself, but I wonder about the other
untouched calls to cplus_demangle.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix C++ demangling of minsyms with symver
2011-06-02 18:04 ` Tom Tromey
@ 2011-06-02 18:24 ` Jan Kratochvil
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2011-06-02 18:24 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Thu, 02 Jun 2011 20:03:45 +0200, Tom Tromey wrote:
> I wonder about the other untouched calls to cplus_demangle.
I think all the other calls are either for full symtab like
TYPE_FN_FIELD_PHYSNAME - which is no longer ever mangled after physname - or
for user entered mangled name which will (after the patchset being posted) be
found as a fallback in the mangled minsym tables.
Just for non-DWARF debug info readers the full symtab can still contain the
mangled names. And for DWARF there will be needed some way to find the
mangled names anyway (regression PR symtab/12707).
So the fix is incomplete for non-DWARF readers but there would be needed first
some conclusion on how to fix symtab/12707.
Thanks,
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix C++ demangling of minsyms with symver
2011-06-02 15:33 [patch] Fix C++ demangling of minsyms with symver Jan Kratochvil
2011-06-02 18:04 ` Tom Tromey
@ 2011-06-02 21:45 ` Jan Kratochvil
1 sibling, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2011-06-02 21:45 UTC (permalink / raw)
To: gdb-patches
Hi,
just a testcase fixup due to a different patches order.
Jan
gdb/
2011-06-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* symtab.c (symbol_find_demangled_name): New parameter objfile. Always
call bfd_demangle, not cplus_demangle.
(symbol_set_names): Pass OBJFILE.
gdb/testsuite/
2011-06-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.cp/cp-symver.cc: New file.
* gdb.cp/cp-symver.exp: New file.
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -478,7 +478,7 @@ create_demangled_names_hash (struct objfile *objfile)
static char *
symbol_find_demangled_name (struct general_symbol_info *gsymbol,
- const char *mangled)
+ const char *mangled, struct objfile *objfile)
{
char *demangled = NULL;
@@ -499,8 +499,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
if (gsymbol->language == language_cplus
|| gsymbol->language == language_auto)
{
- demangled =
- cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
+ demangled = bfd_demangle (objfile->obfd, mangled,
+ DMGL_PARAMS | DMGL_ANSI);
if (demangled != NULL)
{
gsymbol->language = language_cplus;
@@ -509,9 +509,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
}
if (gsymbol->language == language_java)
{
- demangled =
- cplus_demangle (mangled,
- DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
+ demangled = bfd_demangle (objfile->obfd, mangled,
+ DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
if (demangled != NULL)
{
gsymbol->language = language_java;
@@ -651,7 +650,8 @@ symbol_set_names (struct general_symbol_info *gsymbol,
if (*slot == NULL)
{
char *demangled_name = symbol_find_demangled_name (gsymbol,
- linkage_name_copy);
+ linkage_name_copy,
+ objfile);
int demangled_len = demangled_name ? strlen (demangled_name) : 0;
/* Suppose we have demangled_name==NULL, copy_name==0, and
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cp-symver.cc
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 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 a () {} /* at-func-a */
+
+/* Give `a' external name `v()' requiring version `VER_A'. */
+asm (".symver _Z1av, _Z1vv@VER_A");
+
+void b () {} /* at-func-b */
+
+/* Give `b' external name `v()' with default version `VER_B'. */
+asm (".symver _Z1bv, _Z1vv@@VER_B");
+
+int
+main ()
+{
+ a ();
+ b ();
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cp-symver.exp
@@ -0,0 +1,38 @@
+# Copyright 2011 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/>.
+
+# Test C++ demangling of versioned symbols.
+
+set testfile cp-symver
+set srcfile ${testfile}.cc
+if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+ return -1
+}
+
+if ![runto_main] {
+ untested ${testfile}.exp
+ return -1
+}
+
+gdb_test_no_output "set breakpoint pending off"
+
+gdb_breakpoint {'v()@VER_A'}
+gdb_breakpoint {'v()@@VER_B'}
+
+# GDB currently does not support the default version assumption.
+gdb_test "break v()" {Function "v\(\)" not defined\.}
+
+gdb_continue_to_breakpoint "a" ".* at-func-a .*"
+gdb_continue_to_breakpoint "b" ".* at-func-b .*"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-02 21:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-02 15:33 [patch] Fix C++ demangling of minsyms with symver Jan Kratochvil
2011-06-02 18:04 ` Tom Tromey
2011-06-02 18:24 ` Jan Kratochvil
2011-06-02 21:45 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox