[Converted from Gnats 827] GDB doesn't know about the C++ concept of 'namespace scope': if you're within a function defined in a namespace, it doesn't search for names defined in that namespace. Release: GNU gdb 2002-11-13-cvs Environment: any How-To-Repeat: Compile the following file: namespace C { int x = 1; void foo() { x; } } int main () { C::foo(); return 0; } Then run GDB on it, and do the following: (gdb) b 'C::foo' Breakpoint 1 at 0x8048493: file scope.cc, line 7. (gdb) run Starting program: /cartan/carlton/sync/gdb-backup/namespace/prs/a.out Breakpoint 1, C::foo() () at scope.cc:7 7 } (gdb) p x No symbol "x" in current context.
Fix: It works on carlton_dictionary_branch. :-)
From: carlton@sources.redhat.com To: gdb-gnats@sourceware.org Cc: Subject: c++/827 Date: 20 May 2003 03:56:29 -0000 CVSROOT: /cvs/src Module name: src Changes by: carlton@sourceware.org 2003-05-20 03:56:29 Modified files: gdb : ChangeLog Makefile.in block.c block.h c-lang.c cp-namespace.c cp-support.h gdb/config/djgpp: fnchange.lst gdb/testsuite : ChangeLog gdb/testsuite/gdb.c++: namespace.cc namespace.exp Log message: 2003-05-19 David Carlton <carlton@bactrian.org> Partial fix for PR c++/827. * cp-support.h: Include symtab.h. Declare cp_lookup_symbol_nonlocal, cp_lookup_symbol_namespace. * cp-namespace.c: Update contributors. (cp_lookup_symbol_nonlocal): New. (lookup_namespace_scope, cp_lookup_symbol_namespace) (lookup_symbol_file): Ditto. * c-lang.c (cplus_language_defn): Use cp_lookup_symbol_nonlocal. * block.h: Declare block_scope, block_using, block_global_block. * block.c (block_scope): New. (block_using, block_global_block): Ditto. * Makefile.in (cp_support_h): Depend on symtab_h. * config/djgpp/fnchange.lst: Add testsuite/gdb.c++/namespace1.cc. 2003-05-19 David Carlton <carlton@bactrian.org> * gdb.c++/namespace.exp: Add namespace scope and anonymous namespace tests. Bump copyright date. * gdb.c++/namespace.cc: Add anonymous namespace and namespace C. (main): Call C::D::marker2. * gdb.c++/namespace1.cc: New file. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.4206&r2=1.4207 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/Makefile.in.diff?cvsroot=src&r1=1.379&r2=1.380 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/block.c.diff?cvsroot=src&r1=1.4&r2=1.5 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/block.h.diff?cvsroot=src&r1=1.4&r2=1.5 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/c-lang.c.diff?cvsroot=src&r1=1.21&r2=1.22 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-namespace.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-support.h.diff?cvsroot=src&r1=1.2&r2=1.3 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/config/djgpp/fnchange.lst.diff?cvsroot=src&r1=1.48&r2=1.49 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.545&r2=1.546 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.c++/namespace.cc.diff?cvsroot=src&r1=1.1&r2=1.2 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.c++/namespace.exp.diff?cvsroot=src&r1=1.12&r2=1.13
Responsible-Changed-From-To: unassigned->carlton Responsible-Changed-Why: namespace
This works with the F11 gcc and CVS HEAD gdb. I'm closing it as fixed.