aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2015-02-21 21:58:31 -0800
committerDoug Evans <dje@google.com>2015-02-21 21:58:31 -0800
commit96553a0cffb30d2ac6068eb71bed38ea7432073b (patch)
tree2d5c5c815a3742d1392e3d23cdf80626b6e00ebf /gdb/dwarf2read.c
parente26473a140d91672765866857e2284e4a7f105b4 (diff)
downloadgdb-96553a0cffb30d2ac6068eb71bed38ea7432073b.zip
gdb-96553a0cffb30d2ac6068eb71bed38ea7432073b.tar.gz
gdb-96553a0cffb30d2ac6068eb71bed38ea7432073b.tar.bz2
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)'.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a764389..ac78165 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -14109,7 +14109,12 @@ namespace_name (struct die_info *die, int *is_anonymous, struct dwarf2_cu *cu)
current_die != NULL;
current_die = dwarf2_extension (die, &cu))
{
- name = dwarf2_name (current_die, cu);
+ /* We don't use dwarf2_name here so that we can detect the absence
+ of a name -> anonymous namespace. */
+ struct attribute *attr = dwarf2_attr (die, DW_AT_name, cu);
+
+ if (attr != NULL)
+ name = DW_STRING (attr);
if (name != NULL)
break;
}
@@ -19253,7 +19258,8 @@ dwarf2_canonicalize_name (const char *name, struct dwarf2_cu *cu,
return name;
}
-/* Get name of a die, return NULL if not found. */
+/* Get name of a die, return NULL if not found.
+ Anonymous namespaces are converted to their magic string. */
static const char *
dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
@@ -19262,6 +19268,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_name, cu);
if ((!attr || !DW_STRING (attr))
+ && die->tag != DW_TAG_namespace
&& die->tag != DW_TAG_class_type
&& die->tag != DW_TAG_interface_type
&& die->tag != DW_TAG_structure_type
@@ -19280,6 +19287,11 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
to canonicalize them. */
return DW_STRING (attr);
+ case DW_TAG_namespace:
+ if (attr != NULL && DW_STRING (attr) != NULL)
+ return DW_STRING (attr);
+ return CP_ANONYMOUS_NAMESPACE_STR;
+
case DW_TAG_subprogram:
/* Java constructors will all be named "<init>", so return
the class name when we see this special case. */