[Converted from Gnats 830] GDB doesn't know about namespace aliases in C++. Release: GNU gdb 2002-11-15-cvs Environment: any How-To-Repeat: Compile this file: namespace A { int x = 1; } namespace B = A; int main() { B::x; return 0; } Then run GDB on it and try to print out B::x. (gdb) b main Breakpoint 1 at 0x80484a0: file aliases.cc, line 11. (gdb) run Starting program: /cartan/carlton/sync/gdb-backup/namespace/prs/aliases Breakpoint 1, main () at aliases.cc:11 11 return 0; (gdb) p B::x No symbol "B" in current context. (gdb) p 'B::x' No symbol "B::x" in current context.
Fix: Having GCC generate the correct debugging info would be a good first step.
From: David Carlton <carlton@kealia.com> To: gdb-gnats@sources.redhat.com Cc: Subject: Re: gdb/830: GDB doesn't know about namespace aliases Date: Wed, 17 Mar 2004 12:16:06 -0800 On 15 Nov 2002 21:51:26 -0000, carlton@math.Stanford.EDU said: > Having GCC generate the correct debugging info would be > a good first step. I believe GCC does now generate the appropriate debugging info. (I think GCC 3.4, maybe GCC 3.5 instead.)
Subject: Bug 7935 CVSROOT: /cvs/src Module name: src Changes by: swagiaal@sourceware.org 2010-02-05 19:03:42 Modified files: gdb : ChangeLog cp-namespace.c cp-support.h dwarf2read.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.cp: nsusing.exp Log message: 2010-02-05 Sami Wagiaalla <swagiaal@redhat.com> PR c++/7935: * gdb.cp/namespace-using.exp: Removed kfail; bug has been fixed. 2010-02-05 Sami Wagiaalla <swagiaal@redhat.com> PR c++/7935: * cp-support.h: Added char* alias element to using_direct data struct. (cp_add_using): Added char* alias argument. (cp_add_using_directive): Ditto. * cp-namespace.c: Updated with the above changes. (cp_lookup_symbol_imports): Check for aliases. * dwarf2read.c (read_import_statement): Figure out local alias for the import and pass it on to cp_add_using. (read_namespace): Pass alias argument to cp_add_using. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11330&r2=1.11331 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-namespace.c.diff?cvsroot=src&r1=1.33&r2=1.34 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-support.h.diff?cvsroot=src&r1=1.32&r2=1.33 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.354&r2=1.355 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2121&r2=1.2122 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/nsusing.exp.diff?cvsroot=src&r1=1.2&r2=1.3
Sami checked in the fix.
Here's another testcase. namespace foo { int x = 42; void baz () {} } namespace bar = foo; int main () { bar::baz (); return 0; } printing bar::x works, but setting a breakpoint on bar::baz() doesn't work.
*** Bug 13384 has been marked as a duplicate of this bug. ***
This is closely related to c++/10541, for which I have just committed a patch, so I am now closing this bug. [NOTE: When I commited the patch, I had the wrong bug# in the commit, so it didn't get attached here. Please see c++/10541 for links to patches.]