keiths / rpms / gdb

Forked from rpms/gdb 18 days ago
Clone
f056ae4
gdb/
f056ae4
2009-12-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
f056ae4
f056ae4
	Fix compatibility with G++-4.1.
f056ae4
	* dwarf2read.c (partial_die_parent_scope): New variable PARENT_NAME.
f056ae4
	Ignore parent namespaces with name "::".
f056ae4
	(physname_prefix_1): Ignore namespaces with name "::".
f056ae4
f056ae4
gdb/testsuite/
f056ae4
2009-12-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
f056ae4
f056ae4
	* gdb.dwarf2/dw2-empty-namespace.exp, gdb.dwarf2/dw2-empty-namespace.S:
f056ae4
	New.
f056ae4
f056ae4
--- a/gdb/dwarf2read.c
f056ae4
+++ b/gdb/dwarf2read.c
f056ae4
@@ -2355,11 +2355,18 @@ partial_die_parent_scope (struct partial_die_info *pdi,
f056ae4
       || parent->tag == DW_TAG_interface_type
f056ae4
       || parent->tag == DW_TAG_union_type)
f056ae4
     {
f056ae4
+      char *parent_name = parent->name;
f056ae4
+
f056ae4
+      /* G++ 4.1 produced DW_TAG_namespace with DW_AT_name "::".  */
f056ae4
+      if (parent->tag == DW_TAG_namespace && parent_name != NULL
f056ae4
+          && strcmp (parent_name, "::") == 0)
f056ae4
+	parent_name = NULL;
f056ae4
+
f056ae4
       if (grandparent_scope == NULL)
f056ae4
-	parent->scope = parent->name;
f056ae4
+	parent->scope = parent_name;
f056ae4
       else
f056ae4
 	parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope,
f056ae4
-					 parent->name, cu);
f056ae4
+					 parent_name, cu);
f056ae4
     }
f056ae4
   else if (parent->tag == DW_TAG_enumeration_type)
f056ae4
     /* Enumerators should not get the name of the enumeration as a prefix.  */
f056ae4
@@ -9008,6 +9015,9 @@ physname_prefix_1 (struct ui_file *buf, struct die_info *die,
f056ae4
 	  name = dwarf2_name (die, cu);
f056ae4
 	  if (name == NULL)
f056ae4
 	    name = "(anonymous namespace)";
f056ae4
+	  /* G++ 4.1 produced DW_TAG_namespace with DW_AT_name "::".  */
f056ae4
+	  else if (strcmp (name, "::") == 0)
f056ae4
+	    name = NULL;
f056ae4
 	  break;
f056ae4
 
f056ae4
 	case DW_TAG_class_type:
f056ae4
--- /dev/null
f056ae4
+++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S
f056ae4
@@ -0,0 +1,108 @@
f056ae4
+/* This testcase is part of GDB, the GNU debugger.
f056ae4
+
f056ae4
+   Copyright 2009 Free Software Foundation, Inc.
f056ae4
+
f056ae4
+   This program is free software; you can redistribute it and/or modify
f056ae4
+   it under the terms of the GNU General Public License as published by
f056ae4
+   the Free Software Foundation; either version 3 of the License, or
f056ae4
+   (at your option) any later version.
f056ae4
+
f056ae4
+   This program is distributed in the hope that it will be useful,
f056ae4
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
f056ae4
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f056ae4
+   GNU General Public License for more details.
f056ae4
+
f056ae4
+   You should have received a copy of the GNU General Public License
f056ae4
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
f056ae4
+
f056ae4
+/* Test G++ 4.1 producing DW_TAG_namespace with DW_AT_name "::".  */
f056ae4
+
f056ae4
+	.data
f056ae4
+var:	.4byte	1
f056ae4
+
f056ae4
+	.section .debug_info
f056ae4
+.Lcu1_begin:
f056ae4
+	/* CU header */
f056ae4
+	.4byte	.Lcu1_end - .Lcu1_start		/* Length of Compilation Unit */
f056ae4
+.Lcu1_start:
f056ae4
+	.2byte	2				/* DWARF Version */
f056ae4
+	.4byte	.Labbrev1_begin			/* Offset into abbrev section */
f056ae4
+	.byte	4				/* Pointer size */
f056ae4
+
f056ae4
+	/* CU die */
f056ae4
+	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
f056ae4
+	.ascii	"file1.txt\0"			/* DW_AT_name */
f056ae4
+	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
f056ae4
+	.byte	4				/* DW_LANG_C_plus_plus (C++) */
f056ae4
+
f056ae4
+.Ltype_int:
f056ae4
+	.uleb128	2			/* Abbrev: DW_TAG_base_type */
f056ae4
+	.ascii		"int\0"			/* DW_AT_name */
f056ae4
+	.byte		4			/* DW_AT_byte_size */
f056ae4
+	.byte		5			/* DW_AT_encoding */
f056ae4
+
f056ae4
+	.uleb128	3			/* Abbrev: DW_TAG_namespace */
f056ae4
+	.ascii		"::\0"			/* DW_AT_name */
f056ae4
+
f056ae4
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
f056ae4
+	.ascii		"var\0"			/* DW_AT_name */
f056ae4
+	.byte		2f - 1f			/* DW_AT_location */
f056ae4
+1:	.byte		3			/*   DW_OP_addr */
f056ae4
+	.4byte		var			/*   <addr> */
f056ae4
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
f056ae4
+
f056ae4
+	.byte		0			/* End of children of DW_TAG_namespace */
f056ae4
+
f056ae4
+	.byte		0			/* End of children of CU */
f056ae4
+
f056ae4
+.Lcu1_end:
f056ae4
+
f056ae4
+/* Abbrev table */
f056ae4
+	.section .debug_abbrev
f056ae4
+.Labbrev1_begin:
f056ae4
+	.uleb128	1			/* Abbrev code */
f056ae4
+	.uleb128	0x11			/* DW_TAG_compile_unit */
f056ae4
+	.byte		1			/* has_children */
f056ae4
+	.uleb128	0x3			/* DW_AT_name */
f056ae4
+	.uleb128	0x8			/* DW_FORM_string */
f056ae4
+	.uleb128	0x25			/* DW_AT_producer */
f056ae4
+	.uleb128	0x8			/* DW_FORM_string */
f056ae4
+	.uleb128	0x13			/* DW_AT_language */
f056ae4
+	.uleb128	0xb			/* DW_FORM_data1 */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+
f056ae4
+	.uleb128	2			/* Abbrev code */
f056ae4
+	.uleb128	0x24			/* DW_TAG_base_type */
f056ae4
+	.byte		0			/* has_children */
f056ae4
+	.uleb128	0x3			/* DW_AT_name */
f056ae4
+	.uleb128	0x8			/* DW_FORM_string */
f056ae4
+	.uleb128	0xb			/* DW_AT_byte_size */
f056ae4
+	.uleb128	0xb			/* DW_FORM_data1 */
f056ae4
+	.uleb128	0x3e			/* DW_AT_encoding */
f056ae4
+	.uleb128	0xb			/* DW_FORM_data1 */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+
f056ae4
+	.uleb128	3			/* Abbrev code */
f056ae4
+	.uleb128	0x39			/* DW_TAG_namespace */
f056ae4
+	.byte		1			/* has_children */
f056ae4
+	.uleb128	0x3			/* DW_AT_name */
f056ae4
+	.uleb128	0x8			/* DW_FORM_string */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+
f056ae4
+	.uleb128	7			/* Abbrev code (location) */
f056ae4
+	.uleb128	0x34			/* DW_TAG_variable */
f056ae4
+	.byte		0			/* has_children */
f056ae4
+	.uleb128	0x3			/* DW_AT_name */
f056ae4
+	.uleb128	0x8			/* DW_FORM_string */
f056ae4
+	.uleb128	0x2			/* DW_AT_location */
f056ae4
+	.uleb128	0xa			/* DW_FORM_block1 */
f056ae4
+	.uleb128	0x49			/* DW_AT_type */
f056ae4
+	.uleb128	0x13			/* DW_FORM_ref4 */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
+	.byte		0x0			/* Terminator */
f056ae4
--- /dev/null
f056ae4
+++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.exp
f056ae4
@@ -0,0 +1,43 @@
f056ae4
+# Copyright 2009 Free Software Foundation, Inc.
f056ae4
+
f056ae4
+# This program is free software; you can redistribute it and/or modify
f056ae4
+# it under the terms of the GNU General Public License as published by
f056ae4
+# the Free Software Foundation; either version 3 of the License, or
f056ae4
+# (at your option) any later version.
f056ae4
+#
f056ae4
+# This program is distributed in the hope that it will be useful,
f056ae4
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f056ae4
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f056ae4
+# GNU General Public License for more details.
f056ae4
+#
f056ae4
+# You should have received a copy of the GNU General Public License
f056ae4
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
f056ae4
+
f056ae4
+# Test G++ 4.1 producing DW_TAG_namespace with DW_AT_name "::".
f056ae4
+
f056ae4
+# This test can only be run on targets which support DWARF-2 and use gas.
f056ae4
+# For now pick a sampling of likely targets.
f056ae4
+if {![istarget *-*-linux*]
f056ae4
+    && ![istarget *-*-gnu*]
f056ae4
+    && ![istarget *-*-elf*]
f056ae4
+    && ![istarget *-*-openbsd*]
f056ae4
+    && ![istarget arm-*-eabi*]
f056ae4
+    && ![istarget powerpc-*-eabi*]} {
f056ae4
+    return 0  
f056ae4
+}
f056ae4
+
f056ae4
+set testfile "dw2-empty-namespace"
f056ae4
+set srcfile ${testfile}.S
f056ae4
+set executable ${testfile}.x
f056ae4
+
f056ae4
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${executable}" object {nodebug}] != "" } {
f056ae4
+    return -1
f056ae4
+}
f056ae4
+
f056ae4
+clean_restart $executable
f056ae4
+
f056ae4
+# `p var' below can work without identified DWARF DIE just based on its ELF symbol.
f056ae4
+# Catch it here as `type = <data variable, no debug info>'.
f056ae4
+gdb_test "ptype var" "type = int"
f056ae4
+
f056ae4
+gdb_test "p var" " = 1"