Bug 7935 - GDB doesn't know about namespace aliases
Summary: GDB doesn't know about namespace aliases
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 7.7
Assignee: Keith Seitz
URL:
Keywords:
Depends on:
Blocks: 11211
  Show dependency treegraph
 
Reported: 2002-11-15 13:58 UTC by David Carlton
Modified: 2013-11-13 22:11 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Carlton 2002-11-15 21:58:01 UTC
[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.
Comment 1 David Carlton 2002-11-15 21:58:01 UTC
Fix:
Having GCC generate the correct debugging info would be
a good first step.
Comment 2 David Carlton 2004-03-17 20:16:06 UTC
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.)
Comment 3 cvs-commit@gcc.gnu.org 2010-02-05 19:04:04 UTC
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

Comment 4 Tom Tromey 2010-03-13 00:39:47 UTC
Sami checked in the fix.
Comment 5 dje 2013-06-28 19:01:05 UTC
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.
Comment 6 Ben Longbons 2013-07-30 06:40:42 UTC
*** Bug 13384 has been marked as a duplicate of this bug. ***
Comment 7 Keith Seitz 2013-11-13 22:11:21 UTC
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.]