Bug 17976 - ptype (anonymous namespace) doesn't work
Summary: ptype (anonymous namespace) doesn't work
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-13 19:40 UTC by dje
Modified: 2015-05-21 17:39 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dje 2015-02-13 19:40:13 UTC
This is an extension of the research into PR 17821.
ptype (anonymous namespace) should work just like any "ptype namespace_foo".

(gdb) ptype '(anonymous namespace)'
No symbol "(anonymous namespace)" in current context.

Working on a fix ...
Comment 1 Sourceware Commits 2015-02-22 06:01:12 UTC
The master branch has been updated by Doug Evans <devans@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=96553a0cffb30d2ac6068eb71bed38ea7432073b

commit 96553a0cffb30d2ac6068eb71bed38ea7432073b
Author: Doug Evans <dje@google.com>
Date:   Sat Feb 21 21:58:31 2015 -0800

    PR c++/17976, symtab/17821
    
    This patch addresses two issues.
    
    The basic problem is that "(anonymous namespace)" doesn't get entered
    into the symbol table because when dwarf2read.c:new_symbol_full is called
    the DIE has no name (dwarf2_name returns NULL).
    
    PR 17976: ptype '(anonymous namespace)' should work like any namespace
    
    PR 17821: perf issue looking up (anonymous namespace)
    
    bash$ gdb monster-program
    (gdb) mt set per on
    (gdb) mt set symbol-cache-size 0
    (gdb) break (anonymous namespace)::foo
    
    Before:
    
    Command execution time: 3.266289 (cpu), 6.169030 (wall)
    Space used: 811429888 (+12910592 for this command)
    
    After:
    
    Command execution time: 1.264076 (cpu), 4.057408 (wall)
    Space used: 798781440 (+0 for this command)
    
    gdb/ChangeLog:
    
    	PR c++/17976, symtab/17821
    	* cp-namespace.c (cp_search_static_and_baseclasses): New parameter
    	is_in_anonymous.  All callers updated.
    	(find_symbol_in_baseclass): Ditto.
    	(cp_lookup_nested_symbol_1): Ditto.  Don't search all static blocks
    	for symbols in an anonymous namespace.
    	* dwarf2read.c (namespace_name): Don't call dwarf2_name, fetch
    	DW_AT_name directly.
    	(dwarf2_name): Convert missing namespace name to
    	CP_ANONYMOUS_NAMESPACE_STR.
    
    gdeb/testsuite/ChangeLog:
    
    	* gdb.cp/anon-ns.exp: Add test for ptype '(anonymous namespace)'.
Comment 2 dje 2015-05-21 17:39:50 UTC
patch committed