public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Delayed physnames, revisited
@ 2010-07-20 21:01 Keith Seitz
  2010-08-19 19:36 ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Keith Seitz @ 2010-07-20 21:01 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

Hi,

I have finally gotten around to revisiting this patch and rebasing it on 
top of all the recent churn in dwarf2read.c. I have also (finally) 
developed a test case for the "trivial" obstack leak that I previously 
reported. [It was trivial, but also very dependent on compiler and STL 
implementation. That made it very non-trivial. :-)]

For additional background information:
http://sourceware.org/ml/gdb-patches/2010-04/msg00641.html
http://sourceware.org/bugzilla/show_bug.cgi?id=11465

Other than twiddling the const correctness of some of the APIs (not 
changed/patched/updated by this patch), I believe I have addressed all 
of the outstanding issues raised by maintainers.

Aside1: A patch similar to this has been in Fedora for some time now...
Aside2: I've merged the "obstack leak" patch into the delayed physname 
patch, since you cannot trigger this failure without the delayed 
physname patch.

Keith

ChangeLog
2010-07-20  Keith Seitz  <keiths@redhat.com>

	PR symtab/11465:
  	* dwarf2read.c (struct delayed_method_info): New struct.
	(struct dwarf2_cu): Add vector method_list.
	(scan_partial_symbols): Count methods for union, class, structure,
	and interface types.
	(add_to_method_list): New function.
	(free_delayed_list): New function.
	(compute_delayed_physnames): New function.
	(process_full_comp_unit): Make a cleanup for the CU's delayed
	physname list, compute the delayed physnames, and free the
	the list.
	(dwarf2_add_member_fn): For C++ and Java, delay the computation
	of the physname until after the CU is read.

	* dwarf2read.c (read_structure_type): Check if the current
	DIE's type was already completed after dwarf2_full_name
	was called.

testsuite/ChangeLog
2010-07-20  Keith Seitz  <keiths@redhat.com>

	PR symtab/11465:
	* gdb.dwarf2/pr11465.exp: New test.
	* gdb.dwarf2/pr11465.S: New file.
	* gdb.dwarf2/dw2-double-set-die-type.S: New file.
	* gdb.dwarf2/dw2-double-set-die-type.exp: New test.

[-- Attachment #2: delayed_physnames-3.patch --]
[-- Type: text/plain, Size: 40250 bytes --]

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.420
diff -u -p -r1.420 dwarf2read.c
--- dwarf2read.c	16 Jul 2010 19:23:56 -0000	1.420
+++ dwarf2read.c	20 Jul 2010 20:30:17 -0000
@@ -252,6 +252,28 @@ struct comp_unit_head
   unsigned int first_die_offset;
 };
 
+/* Type used for delaying computation of method physnames.
+   See comments for compute_delayed_physnames.  */
+struct delayed_method_info
+{
+  /* The type to which the method is attached, i.e., its parent class.  */
+  struct type *type;
+
+  /* The index of the method in the type's function fieldlists.  */
+  int fnfield_index;
+
+  /* The index of the method in the fieldlist.  */
+  int index;
+
+  /* The name of the DIE.  */
+  const char *name;
+
+  /*  The DIE associated with this method.  */
+  struct die_info *die;
+};
+typedef struct delayed_method_info delayed_method_info;
+DEF_VEC_O (delayed_method_info);
+
 /* Internal state when decoding a particular compilation unit.  */
 struct dwarf2_cu
 {
@@ -330,6 +352,10 @@ struct dwarf2_cu
   /* Header data from the line table, during full symbol processing.  */
   struct line_header *line_header;
 
+  /* A list of methods which need to have physnames computed
+     after all type information has been read.  */
+  VEC (delayed_method_info) *method_list;
+
   /* Mark used when releasing cached dies.  */
   unsigned int mark : 1;
 
@@ -1253,6 +1279,9 @@ byte_swap (offset_type value)
 /* The suffix for an index file.  */
 #define INDEX_SUFFIX ".gdb-index"
 
+static const char *dwarf2_physname (char *name, struct die_info *die,
+				    struct dwarf2_cu *cu);
+
 /* Try to locate the sections we need for DWARF 2 debugging
    information and return true if we have enough to do something.  */
 
@@ -4090,6 +4119,53 @@ load_full_comp_unit (struct dwarf2_per_c
   discard_cleanups (free_cu_cleanup);
 }
 
+/* Add a DIE to the delayed physname list.  */
+static void
+add_to_method_list (struct type *type, int fnfield_index, int index,
+		    const char *name, struct die_info *die,
+		    struct dwarf2_cu *cu)
+{
+  struct delayed_method_info mi;
+  mi.type = type;
+  mi.fnfield_index = fnfield_index;
+  mi.index = index;
+  mi.name = name;
+  mi.die = die;
+  VEC_safe_push (delayed_method_info, cu->method_list, &mi);
+}
+
+/* A cleanup for freeing the delayed method list.  */
+static void
+free_delayed_list (void *ptr)
+{
+  struct dwarf2_cu *cu = (struct dwarf2_cu *) ptr;
+  if (cu->method_list != NULL)
+    {
+      VEC_free (delayed_method_info, cu->method_list);
+      cu->method_list = NULL;
+    }
+}
+
+/* Compute the physnames of any methods on the CU's method list.
+
+   The computation of method physnames is delayed in order to avoid the
+   (bad) condition that one of the method's formal parameters is of an as yet
+   incomplete type.  */
+static void
+compute_delayed_physnames (struct dwarf2_cu *cu)
+{
+  int i;
+  struct delayed_method_info *mi;
+  for (i = 0; VEC_iterate (delayed_method_info, cu->method_list, i, mi) ; ++i)
+    {
+      char *physname;
+      struct fn_fieldlist *fn_flp
+	= &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index);
+      physname = (char *) dwarf2_physname ((char *) mi->name, mi->die, cu);
+      fn_flp->fn_fields[mi->index].physname = physname ? physname : "";
+    }
+}
+
 /* Generate full symbol information for PST and CU, whose DIEs have
    already been loaded into memory.  */
 
@@ -4100,13 +4176,14 @@ process_full_comp_unit (struct dwarf2_pe
   struct objfile *objfile = per_cu->objfile;
   CORE_ADDR lowpc, highpc;
   struct symtab *symtab;
-  struct cleanup *back_to;
+  struct cleanup *back_to, *delayed_list_cleanup;
   CORE_ADDR baseaddr;
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   buildsym_init ();
   back_to = make_cleanup (really_free_pendings, NULL);
+  delayed_list_cleanup = make_cleanup (free_delayed_list, cu);
 
   cu->list_in_scope = &file_symbols;
 
@@ -4115,6 +4192,12 @@ process_full_comp_unit (struct dwarf2_pe
   /* Do line number decoding in read_file_scope () */
   process_die (cu->dies, cu);
 
+  /* Now that we have processed all the DIEs in the CU, all the types 
+     should be complete, and it should now be safe to compute all of the
+     physnames.  */
+  compute_delayed_physnames (cu);
+  do_cleanups (delayed_list_cleanup);
+
   /* Some compilers don't define a DW_AT_high_pc attribute for the
      compilation unit.  If the DW_AT_high_pc is missing, synthesize
      it, by scanning the DIE's below the compilation unit.  */
@@ -5823,7 +5906,6 @@ dwarf2_add_member_fn (struct field_info 
   int i;
   struct fn_field *fnp;
   char *fieldname;
-  char *physname;
   struct nextfnfield *new_fnfield;
   struct type *this_type;
 
@@ -5835,9 +5917,6 @@ dwarf2_add_member_fn (struct field_info 
   if (fieldname == NULL)
     return;
 
-  /* Get the mangled name.  */
-  physname = (char *) dwarf2_physname (fieldname, die, cu);
-
   /* Look up member function name in fieldlist.  */
   for (i = 0; i < fip->nfnfields; i++)
     {
@@ -5863,7 +5942,7 @@ dwarf2_add_member_fn (struct field_info 
       flp->name = fieldname;
       flp->length = 0;
       flp->head = NULL;
-      fip->nfnfields++;
+      i = fip->nfnfields++;
     }
 
   /* Create a new member function field and chain it to the field list
@@ -5877,9 +5956,19 @@ dwarf2_add_member_fn (struct field_info 
 
   /* Fill in the member function field info.  */
   fnp = &new_fnfield->fnfield;
-  /* The name is already allocated along with this objfile, so we don't
-     need to duplicate it for the type.  */
-  fnp->physname = physname ? physname : "";
+
+  /* Delay processing of the physname until later.  */
+  if (cu->language == language_cplus || cu->language == language_java)
+    {
+      add_to_method_list (type, i, flp->length - 1, fieldname,
+			  die, cu);
+    }
+  else
+    {
+      char *physname = (char *) dwarf2_physname (fieldname, die, cu);
+      fnp->physname = physname ? physname : "";
+    }
+
   fnp->type = alloc_type (objfile);
   this_type = read_type_die (die, cu);
   if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC)
@@ -5905,7 +5994,7 @@ dwarf2_add_member_fn (struct field_info 
     }
   else
     complaint (&symfile_complaints, _("member function type missing for '%s'"),
-	       physname);
+	       dwarf2_full_name (fieldname, die, cu));
 
   /* Get fcontext from DW_AT_containing_type if present.  */
   if (dwarf2_attr (die, DW_AT_containing_type, cu) != NULL)
@@ -6153,7 +6242,14 @@ read_structure_type (struct die_info *di
       if (cu->language == language_cplus
 	  || cu->language == language_java)
 	{
-	  TYPE_TAG_NAME (type) = (char *) dwarf2_full_name (name, die, cu);
+	  char *full_name = (char *) dwarf2_full_name (name, die, cu);
+
+	  /* dwarf2_full_name might have already finished building the DIE's
+	     type.  If so, there is no need to continue.  */
+	  if (get_die_type (die, cu) != NULL)
+	    return get_die_type (die, cu);
+
+	  TYPE_TAG_NAME (type) = full_name;
 	  if (die->tag == DW_TAG_structure_type
 	      || die->tag == DW_TAG_class_type)
 	    TYPE_NAME (type) = TYPE_TAG_NAME (type);
Index: testsuite/gdb.dwarf2/dw2-double-set-die-type.S
===================================================================
RCS file: testsuite/gdb.dwarf2/dw2-double-set-die-type.S
diff -N testsuite/gdb.dwarf2/dw2-double-set-die-type.S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.dwarf2/dw2-double-set-die-type.S	20 Jul 2010 20:30:18 -0000
@@ -0,0 +1,632 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* This tests triggers a complaint when gdb attempts to set a DIE's
+   type twice.  The test was derived from the following source code:
+
+   #include <vector>
+
+   class a
+   {
+   private:
+     class b
+     {
+     public:
+       b () { }
+     };
+
+     std::vector<b> list_;
+   };
+
+  What follows below is a much simplified version of the debug info generated
+  by gcc from the above code.  */
+
+#define OFFSET(LBL) .Ldie_ ## LBL - .Lcu1_begin
+
+	.section	.debug_info
+.Lcu1_begin:
+	.4byte	.Lcu1_end - .Lcu1_start	# Length of Compilation Unit Info
+.Lcu1_start:
+	.value	0x3	# DWARF version number
+	.long	.Labbrev1_begin	# Offset Into Abbrev. Section
+	.byte	0x4	# Pointer Size (in bytes)
+
+.Ldie_b:
+	.uleb128 0x1	# (DIE (0xb) DW_TAG_compile_unit)
+	.ascii	"GNU C++ 4.4.3 20100127 (Red Hat 4.4.3-4)\0"	# DW_AT_producer
+	.byte	0x4	# DW_AT_language
+	.ascii	"duplicate-type.cc\0"	# DW_AT_name
+	.long	.Ldebug_line0	# DW_AT_stmt_list
+
+.Ldie_38:
+	.uleb128 0x3	# (DIE (0x38) DW_TAG_typedef)
+	.ascii	"size_t\0"	# DW_AT_name
+	.long	OFFSET (43)	# DW_AT_type
+
+.Ldie_43:
+	.uleb128 0x2	# (DIE (0x43) DW_TAG_base_type)
+	.byte	0x4	# DW_AT_byte_size
+	.byte	0x7	# DW_AT_encoding
+	.ascii	"long unsigned int\0" # DW_AT_name
+
+.Ldie_4a:
+	.uleb128 0x4	# (DIE (0x4a) DW_TAG_namespace)
+	.ascii "std\0"	# DW_AT_name
+	.long	OFFSET (143)	# DW_AT_sibling
+
+.Ldie_70:
+	.uleb128 0x8	# (DIE (0x70) DW_TAG_class_type)
+	.ascii	"allocator<a::b>\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+
+.Ldie_76:
+	.uleb128 0x9	# (DIE (0x76) DW_TAG_structure_type)
+	.ascii	"_Vector_base<a::b, std::allocator<a::b> >\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+	.long	OFFSET (f7)	# DW_AT_sibling
+
+.Ldie_80:
+	.uleb128 0xa	# (DIE (0x80) DW_TAG_structure_type)
+	.ascii	"_Vector_impl\0"	# DW_AT_name
+	.byte	0x18	# DW_AT_byte_size
+
+.Ldie_88:
+	.uleb128 0xb	# (DIE (0x88) DW_TAG_inheritance)
+	.long	OFFSET (3e0)	# DW_AT_type
+	.sleb128 0	# DW_AT_data_member_location
+	.byte	0x1	# DW_AT_accessibility
+	.byte	0x0	# end of children of DIE 0x80
+	.byte	0x0	# end of children of DIE 0x76
+
+.Ldie_f7:
+	.uleb128 0x8	# (DIE (0xf7) DW_TAG_class_type)
+	.ascii	"vector<a::b, std::allocator<a::b> >\0" # DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+	.byte	0x0	# end of children of DIE 0x4a
+
+.Ldie_143:
+	.uleb128 0x13	# (DIE (0x143) DW_TAG_base_type)
+	.byte	0x4	# DW_AT_byte_size
+	.byte	0x5	# DW_AT_encoding
+
+.Ldie_162:
+	.uleb128 0x8	# (DIE (0x162) DW_TAG_class_type)
+	.ascii	"new_allocator<a::b>\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+
+.Ldie_19f:
+	.uleb128 0x2	# (DIE (0x19f) DW_TAG_base_type)
+	.byte	0x4	# DW_AT_byte_size
+	.byte	0x5	# DW_AT_encoding
+	.ascii "int\0"	# DW_AT_name
+
+.Ldie_1c6:
+	.uleb128 0x17	# (DIE (0x1c6) DW_TAG_pointer_type)
+	.byte	0x8	# DW_AT_byte_size
+	.long	OFFSET (1cc)	# DW_AT_type
+
+.Ldie_1cc:
+	.uleb128 0x18	# (DIE (0x1cc) DW_TAG_const_type)
+
+.Ldie_1cd:
+	.uleb128 0x2	# (DIE (0x1cd) DW_TAG_base_type)
+	.byte	0x1	# DW_AT_byte_size
+	.byte	0x6	# DW_AT_encoding
+	.ascii	"char\0"	# DW_AT_name
+
+.Ldie_221:
+	.uleb128 0x1b	# (DIE (0x221) DW_TAG_class_type)
+	.ascii "a\0"	# DW_AT_name
+	.byte	0x18	# DW_AT_byte_size
+	.long	OFFSET (277)	# DW_AT_sibling
+
+.Ldie_22b:
+	.uleb128 0x1b	# (DIE (0x22b) DW_TAG_class_type)
+	.ascii "b\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_byte_size
+	.long	OFFSET (244)	# DW_AT_sibling
+
+.Ldie_235:
+	.uleb128 0x1c	# (DIE (0x235) DW_TAG_subprogram)
+	.byte	0x1	# DW_AT_external
+	.ascii "b\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+
+.Ldie_23c:
+	.uleb128 0xe	# (DIE (0x23c) DW_TAG_formal_parameter)
+	.long	OFFSET (277)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+	.byte	0x0	# end of children of DIE 0x235
+	.byte	0x0	# end of children of DIE 0x22b
+
+.Ldie_244:
+	.uleb128 0x1d	# (DIE (0x244) DW_TAG_member)
+	.ascii	"list\0"	# DW_AT_name
+	.long	OFFSET (59d)	# DW_AT_type
+	.sleb128 0	# DW_AT_data_member_location
+	.byte	0x3	# DW_AT_accessibility
+
+.Ldie_251:
+	.uleb128 0x1e	# (DIE (0x251) DW_TAG_subprogram)
+	.byte	0x1	# DW_AT_external
+	.ascii "a\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_artificial
+	.byte	0x1	# DW_AT_declaration
+	.long	OFFSET (262)	# DW_AT_sibling
+
+.Ldie_25b:
+	.uleb128 0xe	# (DIE (0x25b) DW_TAG_formal_parameter)
+	.long	OFFSET (b61)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+	.byte	0x0	# end of children of DIE 0x251
+
+.Ldie_262:
+	.uleb128 0x1f	# (DIE (0x262) DW_TAG_subprogram)
+	.byte	0x1	# DW_AT_external
+	.ascii "~a\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_artificial
+	.byte	0x1	# DW_AT_declaration
+
+.Ldie_269:
+	.uleb128 0xe	# (DIE (0x269) DW_TAG_formal_parameter)
+	.long	OFFSET (b61)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+
+.Ldie_26f:
+	.uleb128 0xe	# (DIE (0x26f) DW_TAG_formal_parameter)
+	.long	OFFSET (19f)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+	.byte	0x0	# end of children of DIE 0x262
+	.byte	0x0	# end of children of DIE 0x221
+
+.Ldie_277:
+	.uleb128 0x17	# (DIE (0x277) DW_TAG_pointer_type)
+	.byte	0x4	# DW_AT_byte_size
+	.long	OFFSET (22b)	# DW_AT_type
+
+.Ldie_27d:
+	.uleb128 0x20	# (DIE (0x27d) DW_TAG_class_type)
+	.long	OFFSET (162)	# DW_AT_specification
+	.byte	0x1	# DW_AT_byte_size
+	.long	OFFSET (3b2)	# DW_AT_sibling
+
+.Ldie_2d0:
+	.uleb128 0x21	# (DIE (0x2d0) DW_TAG_subprogram)
+	.byte	0x1	# DW_AT_external
+	.ascii	"address\0"	# DW_AT_name
+	.long	OFFSET (277)	# DW_AT_type
+	.byte	0x1	# DW_AT_declaration
+	.long	OFFSET (3b2)	# DW_AT_sibling
+
+.Ldie_2e5:
+	.uleb128 0xe	# (DIE (0x2e5) DW_TAG_formal_parameter)
+	.long	OFFSET (3da)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+
+.Ldie_2eb:
+	.uleb128 0xf	# (DIE (0x2eb) DW_TAG_formal_parameter)
+	.long	OFFSET (3bd)	# DW_AT_type
+	.byte	0x0	# end of children of DIE 0x2d0
+	.byte	0x0	# end of children of DIE 0x27d
+
+.Ldie_3b2:
+	.uleb128 0x17	# (DIE (0x3b2) DW_TAG_pointer_type)
+	.byte	0x4	# DW_AT_byte_size
+	.long	OFFSET (3b8)	# DW_AT_type
+
+.Ldie_3b8:
+	.uleb128 0x19	# (DIE (0x3b8) DW_TAG_const_type)
+	.long	OFFSET (22b)	# DW_AT_type
+
+.Ldie_3bd:
+	.uleb128 0x22	# (DIE (0x3bd) DW_TAG_reference_type)
+	.byte	0x4	# DW_AT_byte_size
+	.long	OFFSET (22b)	# DW_AT_type
+
+.Ldie_3d5:
+	.uleb128 0x19	# (DIE (0x3d5) DW_TAG_const_type)
+	.long	OFFSET (27d)	# DW_AT_type
+
+.Ldie_3da:
+	.uleb128 0x17	# (DIE (0x3da) DW_TAG_pointer_type)
+	.byte	0x4	# DW_AT_byte_size
+	.long	OFFSET (3d5)	# DW_AT_type
+
+.Ldie_3e0:
+	.Uleb128 0x20	# (DIE (0x3e0) DW_TAG_class_type)
+	.long	OFFSET (70)	# DW_AT_specification
+	.byte	0x1	# DW_AT_byte_size
+	.long	OFFSET (44e)	# DW_AT_sibling
+
+.Ldie_3ec:
+	.uleb128 0xb	# (DIE (0x3ec) DW_TAG_inheritance)
+	.long	OFFSET (27d)	# DW_AT_type
+	.sleb128 0	# DW_AT_data_member_location
+	.byte	0x1	# DW_AT_accessibility
+	.byte	0x0	# end of children of DIE 0x3e0
+
+.Ldie_44e:
+	.uleb128 0x1a	# (DIE (0x44e) DW_TAG_structure_type)
+	.long	OFFSET (76)	# DW_AT_specification
+	.byte	0x18	# DW_AT_byte_size
+	.long	OFFSET (505)	# DW_AT_sibling
+
+.Ldie_505:
+	.uleb128 0x11	# (DIE (0x505) DW_TAG_subprogram)
+	.ascii	"~_Vector_base\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+	.long	OFFSET (51f)	# DW_AT_sibling
+
+.Ldie_512:
+	.uleb128 0xe	# (DIE (0x512) DW_TAG_formal_parameter)
+	.long	OFFSET (58c)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+
+.Ldie_518:
+	.uleb128 0xf	# (DIE (0x518) DW_TAG_formal_parameter)
+	.long	OFFSET (19f)	# DW_AT_type
+	.byte	0x0	# end of children of DIE 0x505
+
+.Ldie_51f:
+	.uleb128 0x21	# (DIE (0x51f) DW_TAG_subprogram)
+	.byte	0x1	# DW_AT_external
+	.ascii	"_M_allocate\0"	# DW_AT_name
+	.long	OFFSET (277)	# DW_AT_type
+	.byte	0x1	# DW_AT_declaration
+	.long	OFFSET (540)	# DW_AT_sibling
+
+.Ldie_540:
+	.uleb128 0x11	# (DIE (0x540) DW_TAG_subprogram)
+	.ascii	"_M_deallocate\0"	# DW_AT_name
+	.byte	0x1	# DW_AT_declaration
+	.long	OFFSET (562)	# DW_AT_sibling
+
+.Ldie_551:
+	.uleb128 0xe	# (DIE (0x551) DW_TAG_formal_parameter)
+	.long	OFFSET (58c)	# DW_AT_type
+	.byte	0x1	# DW_AT_artificial
+
+.Ldie_557:
+	.uleb128 0xf	# (DIE (0x557) DW_TAG_formal_parameter)
+	.long	OFFSET (277)	# DW_AT_type
+
+.Ldie_55c:
+	.uleb128 0xf	# (DIE (0x55c) DW_TAG_formal_parameter)
+	.long	OFFSET (43)	# DW_AT_type
+	.byte	0x0	# end of children of DIE 0x540
+
+.Ldie_562:
+	.uleb128 0x5	# (DIE (0x562) DW_TAG_imported_declaration)
+	.long	OFFSET (51f)	# DW_AT_import
+	.byte	0x0	# end of children of DIE 0x44e
+
+.Ldie_586:
+	.uleb128 0x22	# (DIE (0x586) DW_TAG_reference_type)
+	.byte	0x4	# DW_AT_byte_size
+	.long	OFFSET (3e0)	# DW_AT_type
+
+.Ldie_58c:
+	.uleb128 0x17	# (DIE (0x58c) DW_TAG_pointer_type)
+	.byte	0x8	# DW_AT_byte_size
+	.long	OFFSET (44e)	# DW_AT_type
+
+.Ldie_59d:
+	.uleb128 0x20	# (DIE (0x59d) DW_TAG_class_type)
+	.long	OFFSET (f7)	# DW_AT_specification
+	.byte	0x18	# DW_AT_byte_size
+	.long	OFFSET (b44)	# DW_AT_sibling
+
+.Ldie_5a9:
+	.uleb128 0xb	# (DIE (0x5a9) DW_TAG_inheritance)
+	.long	OFFSET (44e)	# DW_AT_type
+	.sleb128 0	# DW_AT_data_member_location
+	.byte	0x2	# DW_AT_accessibility
+	.byte	0x0	# end of children of DIE 0x59d
+
+.Ldie_b44:
+	.uleb128 0x17	# (DIE (0xb44) DW_TAG_pointer_type)
+	.byte	0x8	# DW_AT_byte_size
+	.long	OFFSET (59d) # DW_AT_type
+
+.Ldie_b61:
+	.uleb128 0x17	# (DIE (0xb61) DW_TAG_pointer_type)
+	.byte	0x4	# DW_AT_byte_size
+	.long	OFFSET (221) # DW_AT_type
+	.byte	0x0	# end of children of DIE 0xb
+.Lcu1_end:
+
+/* Abbrev table */
+	.section	.debug_abbrev
+	.uleb128 0x1	# (abbrev code)
+	.uleb128 0x11	# (TAG: DW_TAG_compile_unit)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x25	# (DW_AT_producer)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x13	# (DW_AT_language)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_sting)
+	.uleb128 0x10	# (DW_AT_stmt_list)
+	.uleb128 0x6	# (DW_FORM_data4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x2	# (abbrev code)
+	.uleb128 0x24	# (DW_TAG_base_type)
+	.byte	0x0	# DW_children_no
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x3e	# (DW_AT_encoding)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x3	# (abbrev code)
+	.uleb128 0x16	# (TAG: DW_TAG_typedef)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x4	# (abbrev code)
+	.uleb128 0x39	# (TAG: DW_TAG_namespace)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x5	# (abbrev code)
+	.uleb128 0x8	# (TAG: DW_TAG_imported_declaration)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x18	# (DW_AT_import)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x8	# (abbrev code)
+	.uleb128 0x2	# (TAG: DW_TAG_class_type)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x9	# (abbrev code)
+	.uleb128 0x13	# (TAG: DW_TAG_structure_type)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0xa	# (abbrev code)
+	.uleb128 0x13	# (TAG: DW_TAG_structure_type)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0xb	# (abbrev code)
+	.uleb128 0x1c	# (TAG: DW_TAG_inheritance)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0x38	# (DW_AT_data_member_location)
+	.uleb128 0xd	# (DW_FORM_sdata)
+	.uleb128 0x32	# (DW_AT_accessibility)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0xe	# (abbrev code)
+	.uleb128 0x5	# (TAG: DW_TAG_formal_parameter)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0x34	# (DW_AT_artificial)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0xf	# (abbrev code)
+	.uleb128 0x5	# (TAG: DW_TAG_formal_parameter)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x11	# (abbrev code)
+	.uleb128 0x2e	# (DW_TAG_subprogram)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x13	# (abbrev code)
+	.uleb128 0x24	# (DW_TAG_base_type)
+	.byte	0x0	# DW_children_no
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x3e	# (DW_AT_encoding)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x17	# (abbrev code)
+	.uleb128 0xf	# (TAG: DW_TAG_pointer_type)
+	.byte	0x0	# DW_children_no
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x18	# (abbrev code)
+	.uleb128 0x26	# (TAG: DW_TAG_const_type)
+	.byte	0x0	# DW_children_no
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x19	# (abbrev code)
+	.uleb128 0x26	# (TAG: DW_TAG_const_type)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x1a	# (abbrev code)
+	.uleb128 0x13	# (TAG: DW_TAG_structure_type)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x47	# (DW_AT_specification)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x1b	# (abbrev code)
+	.uleb128 0x2	# (TAG: DW_TAG_class_type)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x1c	# (abbrev code)
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3f	# (DW_AT_external)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x1d	# (abbrev code)
+	.uleb128 0xd	# (TAG: DW_TAG_member)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0x38	# (DW_AT_data_member_location)
+	.uleb128 0xd	# (DW_FORM_sdata)
+	.uleb128 0x32	# (DW_AT_accessibility)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x1e	# (abbrev code)
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3f	# (DW_AT_external)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x34	# (DW_AT_artificial)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x1f	# (abbrev code)
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3f	# (DW_AT_external)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x34	# (DW_AT_artificial)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x20	# (abbrev code)
+	.uleb128 0x2	# (TAG: DW_TAG_class_type)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x47	# (DW_AT_specification)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x21	# (abbrev code)
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
+	.byte	0x1	# DW_children_yes
+	.uleb128 0x3f	# (DW_AT_external)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.uleb128 0x22	# (abbrev code)
+	.uleb128 0x10	# (TAG: DW_TAG_reference_type)
+	.byte	0x0	# DW_children_no
+	.uleb128 0xb	# (DW_AT_byte_size)
+	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
Index: testsuite/gdb.dwarf2/dw2-double-set-die-type.exp
===================================================================
RCS file: testsuite/gdb.dwarf2/dw2-double-set-die-type.exp
diff -N testsuite/gdb.dwarf2/dw2-double-set-die-type.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.dwarf2/dw2-double-set-die-type.exp	20 Jul 2010 20:30:18 -0000
@@ -0,0 +1,41 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test DW_TAG_inheritance using constant DW_AT_data_member_location
+# introduced by GCC PR debug/40659.
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+    && ![istarget *-*-gnu*]
+    && ![istarget *-*-elf*]
+    && ![istarget *-*-openbsd*]
+    && ![istarget arm-*-eabi*]
+    && ![istarget powerpc-*-eabi*]} {
+    return 0  
+}
+
+set testfile "dw2-double-set-die-type"
+set srcfile "$testfile.S"
+set executable "$testfile.x"
+
+if  { [gdb_compile [file join $srcdir $subdir $srcfile] \
+	   [file join $objdir $subdir $executable] \
+	   object {nodebug}] != "" } {
+    return -1
+}
+
+clean_restart $executable
+gdb_test "ptype a" "type = class .*"
Index: testsuite/gdb.dwarf2/pr11465.S
===================================================================
RCS file: testsuite/gdb.dwarf2/pr11465.S
diff -N testsuite/gdb.dwarf2/pr11465.S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.dwarf2/pr11465.S	20 Jul 2010 20:30:18 -0000
@@ -0,0 +1,355 @@
+/* Copyright 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Compiled from:
+
+    namespace N
+    {
+      class C
+      {
+      public:
+        typedef void (*t) (C);
+        C (t) {}
+      };
+      typedef C::t u;
+      u f;
+      C c (f);
+    };
+
+    int
+    main ()
+    {
+      return 0;
+    }
+*/
+
+	.text
+_ZN1N1cE:	
+	.section	.debug_info
+d:
+	.long	.Ldebug_info_end - 1f /* Length of CU info */
+1:
+	.2byte	0x2		/* DWARF version number */
+	.long	.Ldebug_abbrev0	/* Abbrev offset */
+	.byte	0x4		/* Pointer size */
+dieb:	.uleb128 0x1		/* DW_TAG_compile_unit */
+	.long	.LASF4		/* DW_AT_producer */
+	.byte	0x4		/* DW_AT_language */
+	.long	.LASF5		/* DW_AT_name */
+	.long	.LASF6		/* DW_AT_comp_dir */
+	.long	0x0		/* DW_AT_low_pc */
+	.long	0x0		/* DW_AT_high_pc */
+	.long	0x0		/* DW_AT_entry_pc */
+die29:	.uleb128 0x2		/* DW_TAG_namespace */
+	.string	"N"		/* DW_AT_name */
+die32:	.uleb128 0x3		/* DW_TAG_class_type */
+	.string	"C"		/* DW_AT_name */
+	.byte	0x1		/* DW_AT_declaration */
+die36:	.uleb128 0x4		/* DW_TAG_typedef */
+	.string	"u"		/* DW_AT_name */
+	.long	die7e-d		/* DW_AT_type */
+die3f:	.uleb128 0x5		/* DW_TAG_variable */
+	.string	"f"		/* DW_AT_name */
+	.long	.LASF0		/* DW_AT_MIPS_linkage_name */
+	.long	die36-d		/* DW_AT_type */
+	.byte	0x1		/* DW_AT_external */
+	.byte	0x1		/* DW_AT_declaration */
+die4e:	.uleb128 0x5		/* DW_TAG_variable */
+	.string	"c"		/* DW_AT_name */
+	.long	.LASF1		/* DW_AT_MIPS_linkage_name */
+	.long	die5e-d		/* DW_AT_type */
+	.byte	0x1		/* DW_AT_external */
+	.byte	0x1		/* DW_AT_declaration */
+	.byte	0x0
+die5e:	.uleb128 0x6		/* DW_TAG_class_type */
+	.long	die32-d		/* DW_AT_specification */
+	.byte	0x1		/* DW_AT_byte_size */
+die6a:	.uleb128 0x7		/* DW_TAG_subprogram */
+	.byte	0x1		/* DW_AT_external */
+	.string	"C"		/* DW_AT_name */
+	.byte	0x1		/* DW_AT_declaration */
+die71:	.uleb128 0x8		/* DW_TAG_formal_parameter */
+	.long	die8f-d		/* DW_AT_type */
+	.byte	0x1		/* DW_AT_artificial */
+die77:	.uleb128 0x9		/* DW_TAG_formal_parameter */
+	.long	die7e-d		/* DW_AT_type */
+	.byte	0x0
+	.byte	0x0
+die7e:	.uleb128 0xa		/* DW_TAG_pointer_type */
+	.byte	0x4		/* DW_AT_byte_size */
+	.long	die84-d		/* DW_AT_type */
+die84:	.uleb128 0xb		/* DW_TAG_subroutine_type */
+die89:	.uleb128 0x9		/* DW_TAG_formal_parameter */
+	.long	die5e-d		/* DW_AT_type */
+	.byte	0x0
+die8f:	.uleb128 0xa		/* DW_TAG_pointer_type */
+	.byte	0x4		/* DW_AT_byte_size */
+	.long	die5e-d		/* DW_AT_type */
+die95:	.uleb128 0xc		/* DW_TAG_subprogram */
+	.long	die6a-d		/* DW_AT_specification */
+	.byte	0x2		/* DW_AT_inline */
+die9f:	.uleb128 0xd		/* DW_TAG_formal_parameter */
+	.long	.LASF7		/* DW_AT_name */
+	.long	dieaf-d		/* DW_AT_type */
+	.byte	0x1		/* DW_AT_artificial */
+diea9:	.uleb128 0x9		/* DW_TAG_formal_parameter */
+	.long	die7e-d		/* DW_AT_type */
+	.byte	0x0
+dieaf:	.uleb128 0xe		/* DW_TAG_const_type */
+	.long	die8f-d		/* DW_AT_type */
+dieb4:	.uleb128 0xf		/* DW_TAG_subprogram */
+	.long	die95-d		/* DW_AT_abstract_origin */
+	.long	_ZN1N1cE	/* DW_AT_low_pc */
+	.long	_ZN1N1cE	/* DW_AT_high_pc */
+diec9:	.uleb128 0x10		/* DW_TAG_subprogram */
+	.long	die9f-d		/* DW_AT_abstract_origin */
+	.byte	2f-1f		/* DW_AT_location */
+1:
+	.byte	0x50		/* DW_OP_reg0 */
+2:
+died1:	.uleb128 0x10		/* DW_TAG_formal_parameter */
+	.long	diea9-d		/* DW_AT_abstract_origin */
+	.byte	2f-1f		/* DW_AT_location */
+1:
+	.byte	0x51		/* DW_OP_reg1 */
+2:
+	.byte	0x0
+dieda:	.uleb128 0x11		/* DW_TAG_subprogram */
+	.byte	0x1		/* DW_AT_external */
+	.long	.LASF8		/* DW_AT_name */
+	.long	dief2-d		/* DW_AT_type */
+	.long	_ZN1N1cE	/* DW_AT_low_pc */
+	.long	_ZN1N1cE	/* DW_AT_high_pc */
+dief2:	.uleb128 0x12		/* DW_TAG_base_type */
+	.byte	0x4		/* DW_AT_byte_size */
+	.byte	0x5		/* DW_AT_encoding */
+	.string	"int"		/* DW_AT_name */
+die149:	.uleb128 0x16		/* DW_TAG_variable */
+	.long	die4e-d		/* DW_AT_specification */
+	.byte	0x5		/* DW_AT_location */
+	.byte	0x3
+	.long	_ZN1N1cE
+	.byte	0x0
+.Ldebug_info_end:
+	.section	.debug_abbrev
+.Ldebug_abbrev0:
+	.uleb128 0x1		/* abbrev code*/
+	.uleb128 0x11		/* DW_TAG_compile_unit */
+	.byte	0x1		/* DW_children_yes */
+	.uleb128 0x25		/* DW_AT_producer*/
+	.uleb128 0xe		/* DW_FORM_strp */
+	.uleb128 0x13		/* DW_AT_language */
+	.uleb128 0xb		/* DW_FORM_data1 */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0xe		/* DW_FORM_strp */
+	.uleb128 0x1b		/* DW_AT_comp_dir */
+	.uleb128 0xe		/* DW_FORM_strp */
+	.uleb128 0x11		/* DW_AT_low_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.uleb128 0x12		/* DW_AT_high_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.uleb128 0x52		/* DW_AT_entry_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x2		/* abbrev code */
+	.uleb128 0x39		/* DW_TAG_namespace */
+	.byte	0x1		/* DW_children_yes */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0x8		/* DW_FORM_string */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x3		/* abbrev code */
+	.uleb128 0x2		/* DW_TAG_class_type */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0x8		/* DW_FORM_string */
+	.uleb128 0x3c		/* DW_AT_declaration */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x4		/* abbrev code */
+	.uleb128 0x16		/* DW_TAG_typedef */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0x8		/* DW_FORM_string */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x5		/* abbrev code */
+	.uleb128 0x34		/* DW_TAG_variable */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0x8		/* DW_FORM_string */
+	.uleb128 0x2007		/* DW_AT_MIPS_linkage_name */
+	.uleb128 0xe		/* DW_FORM_strp */
+	.uleb128 0x49		/* DW_AT_TYPE */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x3f		/* DW_AT_external */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.uleb128 0x3c		/* DW_AT_declaration */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x6		/* abbrev code */
+	.uleb128 0x2		/* DW_TAG_class_type */
+	.byte	0x1		/* DW_has_children_yes */
+	.uleb128 0x47		/* DW_AT_specification */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0xb		/* DW_AT_byte_size */
+	.uleb128 0xb		/* DW_FORM_data1 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x7		/* abbrev code */
+	.uleb128 0x2e		/* DW_TAG_subprogra */
+	.byte	0x1		/* DW_has_children_yes */
+	.uleb128 0x3f		/* DW_AT_external */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0x8		/* DW_FORM_string */
+	.uleb128 0x3c		/* DW_AT_declaration */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x8		/* abbrev code */
+	.uleb128 0x5		/* DW_TAG_formal_parameter */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x34		/* DW_AT_artificial */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x9		/* abbrev code */
+	.uleb128 0x5		/* DW_TAG_formal_parameter */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0xa		/* abbrev code */
+	.uleb128 0xf		/* DW_TAG_pointer_type */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0xb		/* DW_AT_byte_size */
+	.uleb128 0xb		/* DW_FORM_data1 */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0xb		/* abbrev code */
+	.uleb128 0x15		/* DW_TAG_subroutine_type */
+	.byte	0x1		/* DW_has_children_yes */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0xc		/* abbrev code */
+	.uleb128 0x2e		/* DW_TAG_subprogram */
+	.byte	0x1		/* DW_has_children_yes */
+	.uleb128 0x47		/* DW_AT_specification */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x20		/* DW_AT_inline */
+	.uleb128 0xb		/* DW_FORM_data1 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0xd		/* abbrev code */
+	.uleb128 0x5		/* DW_TAG_formal_parameter */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0xe		/* DW_FORM_strp */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x34		/* DW_AT_artificial */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0xe		/* abbrev code */
+	.uleb128 0x26		/* DW_TAG_const_type */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0xf		/* abbrev code */
+	.uleb128 0x2e		/* DW_TAG_subprogram */
+	.byte	0x1		/* DW_has_children_yes */
+	.uleb128 0x31		/* DW_AT_abstract_origin */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x11		/* DW_AT_low_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.uleb128 0x12		/* DW_AT_high_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x10		/* abbrev code */
+	.uleb128 0x5		/* DW_TAG_formal_parameter */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x31		/* DW_AT_abstract_origin */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x2		/* DW_AT_location */
+	.uleb128 0xa		/* DW_FORM_block1 */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x11		/* abbrev code */
+	.uleb128 0x2e		/* DW_TAG_subprogram */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x3f		/* DW_AT_external */
+	.uleb128 0xc		/* DW_FORM_flag */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0xe		/* DW_FORM_strp */
+	.uleb128 0x49		/* DW_AT_type */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x11		/* DW_AT_low_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.uleb128 0x12		/* DW_AT_high_pc */
+	.uleb128 0x1		/* DW_FORM_addr */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x12		/* abbrev code */
+	.uleb128 0x24		/* DW_TAG_base_type */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0xb		/* DW_AT_byte_size */
+	.uleb128 0xb		/* DW_FORM_data1 */
+	.uleb128 0x3e		/* DW_AT_encoding */
+	.uleb128 0xb		/* DW_FORM_data1 */
+	.uleb128 0x3		/* DW_AT_name */
+	.uleb128 0x8		/* DW_FORM_string */
+	.byte	0x0
+	.byte	0x0
+	.uleb128 0x16		/* abbrev code */
+	.uleb128 0x34		/* DW_TAG_variable */
+	.byte	0x0		/* DW_has_children_no */
+	.uleb128 0x47		/* DW_AT_specification */
+	.uleb128 0x13		/* DW_FORM_ref4 */
+	.uleb128 0x2		/* DW_AT_location */
+	.uleb128 0xa		/* DW_FORM_block1 */
+	.byte	0x0
+	.byte	0x0
+	.byte	0x0
+	.section	.debug_str
+.LASF0:
+	.string	"_ZN1N1fE"
+.LASF7:
+	.string	"this"
+.LASF6:
+	.string	""
+.LASF8:
+	.string	"main"
+.LASF1:
+	.string	"_ZN1N1cE"
+.LASF5:
+	.string	"pr11465.cc"
+.LASF4:
+	.string	"GNU C++ 4.4.2"
+	.ident	"GCC: (GNU) 4.4.2"
Index: testsuite/gdb.dwarf2/pr11465.exp
===================================================================
RCS file: testsuite/gdb.dwarf2/pr11465.exp
diff -N testsuite/gdb.dwarf2/pr11465.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.dwarf2/pr11465.exp	20 Jul 2010 20:30:18 -0000
@@ -0,0 +1,40 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+    && ![istarget *-*-gnu*]
+    && ![istarget *-*-elf*]
+    && ![istarget *-*-openbsd*]
+    && ![istarget arm-*-eabi*]
+    && ![istarget powerpc-*-eabi*]} {
+    return 0  
+}
+
+set testfile "pr11465"
+set srcfile "$testfile.S"
+set executable "$testfile.x"
+set binfile [file join $objdir $subdir $executable]
+
+if  { [gdb_compile [file join $srcdir $subdir $srcfile] \
+	   $binfile object {}] != "" } {
+    return -1
+}
+
+clean_restart $executable
+
+# Test delayed physname computations
+gdb_test "p N::c.C" { = {void \(N::C \*, void \(\*\)\(N::C\)\)}.*}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA] Delayed physnames, revisited
  2010-07-20 21:01 [RFA] Delayed physnames, revisited Keith Seitz
@ 2010-08-19 19:36 ` Tom Tromey
  2010-08-19 23:26   ` Doug Evans
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-08-19 19:36 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Sorry about the long delay on this.
Please ping patches regularly, it helps embarrass us into responding ;-)

Keith> I have finally gotten around to revisiting this patch and rebasing it
Keith> on top of all the recent churn in dwarf2read.c. I have also (finally)
Keith> developed a test case for the "trivial" obstack leak that I previously
Keith> reported. [It was trivial, but also very dependent on compiler and STL
Keith> implementation. That made it very non-trivial. :-)]

This patch is ok.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA] Delayed physnames, revisited
  2010-08-19 19:36 ` Tom Tromey
@ 2010-08-19 23:26   ` Doug Evans
  2010-08-20 17:17     ` Keith Seitz
  2010-08-20 17:50     ` [RFA] Delayed physnames, revisited Thiago Jung Bauermann
  0 siblings, 2 replies; 7+ messages in thread
From: Doug Evans @ 2010-08-19 23:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Keith Seitz, gdb-patches

On Thu, Aug 19, 2010 at 12:36 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>
> Sorry about the long delay on this.
> Please ping patches regularly, it helps embarrass us into responding ;-)
>
> Keith> I have finally gotten around to revisiting this patch and rebasing it
> Keith> on top of all the recent churn in dwarf2read.c. I have also (finally)
> Keith> developed a test case for the "trivial" obstack leak that I previously
> Keith> reported. [It was trivial, but also very dependent on compiler and STL
> Keith> implementation. That made it very non-trivial. :-)]
>
> This patch is ok.  Thanks.

Not to nitpick or anything,
Well, yes to nitpick ... :-)

Folks are great at enforcing things like putting a space after the
function name in a function call, but not so good at enforcing having
a blank line between a function's comment and definition.

Keith, can you fix that?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA] Delayed physnames, revisited
  2010-08-19 23:26   ` Doug Evans
@ 2010-08-20 17:17     ` Keith Seitz
  2010-08-22 18:46       ` New UNRESOLVED testcase gdb.dwarf2/dw2-double-set-die-type.exp [Re: [RFA] Delayed physnames, revisited] Jan Kratochvil
  2010-08-20 17:50     ` [RFA] Delayed physnames, revisited Thiago Jung Bauermann
  1 sibling, 1 reply; 7+ messages in thread
From: Keith Seitz @ 2010-08-20 17:17 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, gdb-patches

On 08/19/2010 04:25 PM, Doug Evans wrote:
> Folks are great at enforcing things like putting a space after the
> function name in a function call, but not so good at enforcing having
> a blank line between a function's comment and definition.
>
> Keith, can you fix that?

Committed with that trivial change.

Thanks Tom and Doug!

Keith

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFA] Delayed physnames, revisited
  2010-08-19 23:26   ` Doug Evans
  2010-08-20 17:17     ` Keith Seitz
@ 2010-08-20 17:50     ` Thiago Jung Bauermann
  1 sibling, 0 replies; 7+ messages in thread
From: Thiago Jung Bauermann @ 2010-08-20 17:50 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, Keith Seitz, gdb-patches

On Thu, 2010-08-19 at 16:25 -0700, Doug Evans wrote:
> Not to nitpick or anything,
> Well, yes to nitpick ... :-)
> 
> Folks are great at enforcing things like putting a space after the
> function name in a function call, but not so good at enforcing having
> a blank line between a function's comment and definition.

I asked what was the convention regarding that a long time ago and the
answer was something like "there's no defined convention"...
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* New UNRESOLVED testcase gdb.dwarf2/dw2-double-set-die-type.exp  [Re: [RFA] Delayed physnames, revisited]
  2010-08-20 17:17     ` Keith Seitz
@ 2010-08-22 18:46       ` Jan Kratochvil
  2010-08-23 19:13         ` Keith Seitz
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2010-08-22 18:46 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Doug Evans, Tom Tromey, gdb-patches

On Fri, 20 Aug 2010 19:16:46 +0200, Keith Seitz wrote:
> Thanks Tom and Doug!

Getting on all distros (at least Fedora 14snapshot x86_64):
ERROR: couldn't load /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.x into /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../../gdb/gdb.
UNRESOLVED: gdb.dwarf2/dw2-double-set-die-type.exp: ptype a

due to:
Reading symbols from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.x...Dwarf Error: Could not find abbrev number 845466003 [in module /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.x]

There is one missing end-of-DIE-children at the end of .debug_info.  But I do
not know which specific DIE is not terminated before it.

Also .debug_abbrev seems to be missing its terminating entry.

(+If it is a minimized DWARF I would find DW_AT_sibling as redundant there.)


Thanks,
Jan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: New UNRESOLVED testcase gdb.dwarf2/dw2-double-set-die-type.exp  [Re: [RFA] Delayed physnames, revisited]
  2010-08-22 18:46       ` New UNRESOLVED testcase gdb.dwarf2/dw2-double-set-die-type.exp [Re: [RFA] Delayed physnames, revisited] Jan Kratochvil
@ 2010-08-23 19:13         ` Keith Seitz
  0 siblings, 0 replies; 7+ messages in thread
From: Keith Seitz @ 2010-08-23 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

On 08/22/2010 11:46 AM, Jan Kratochvil wrote:
> There is one missing end-of-DIE-children at the end of .debug_info.  But I do
> not know which specific DIE is not terminated before it.

Yes, there was. Turns out there were two *similar* abbrevs in the 
original program. I missed that one of them was marked DW_children_no 
and the other DW_children_yes. Creating a new abbrev with DW_children_no 
and using that fixes the problem.

>
> Also .debug_abbrev seems to be missing its terminating entry.

Yup. I've added that, too.

I've checked this in as obvious (and I have verified with Jan that 
everything now works).

Keith

ChangeLog
2010-08-23  Keith Seitz  <keiths@redhat.com>

	* gdb.dwarf2/dw2-double-set-die-type.S: DIE 0x51f does not
	have any children. Create a new abbrev for it.
	Add missing terminal sequence to .debug_abbrev.


[-- Attachment #2: double-die-no-children.patch --]
[-- Type: text/plain, Size: 1270 bytes --]

Index: testsuite/gdb.dwarf2/dw2-double-set-die-type.S
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S,v
retrieving revision 1.1
diff -u -p -r1.1 dw2-double-set-die-type.S
--- testsuite/gdb.dwarf2/dw2-double-set-die-type.S	20 Aug 2010 17:16:15 -0000	1.1
+++ testsuite/gdb.dwarf2/dw2-double-set-die-type.S	23 Aug 2010 19:11:48 -0000
@@ -282,7 +282,7 @@
 	.byte	0x0	# end of children of DIE 0x505
 
 .Ldie_51f:
-	.uleb128 0x21	# (DIE (0x51f) DW_TAG_subprogram)
+	.uleb128 0x23	# (DIE (0x51f) DW_TAG_subprogram)
 	.byte	0x1	# DW_AT_external
 	.ascii	"_M_allocate\0"	# DW_AT_name
 	.long	OFFSET (277)	# DW_AT_type
@@ -630,3 +630,23 @@
 	.uleb128 0x13	# (DW_FORM_ref4)
 	.byte	0x0
 	.byte	0x0
+
+	.uleb128 0x23	# (abbrev code)
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
+	.byte	0x0	# DW_children_no
+	.uleb128 0x3f	# (DW_AT_external)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x3	# (DW_AT_name)
+	.uleb128 0x8	# (DW_FORM_string)
+	.uleb128 0x49	# (DW_AT_type)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.uleb128 0x3c	# (DW_AT_declaration)
+	.uleb128 0xc	# (DW_FORM_flag)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
+	.byte	0x0
+	.byte	0x0
+
+	.byte	0x0
+	.byte	0x0
+

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-08-23 19:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-20 21:01 [RFA] Delayed physnames, revisited Keith Seitz
2010-08-19 19:36 ` Tom Tromey
2010-08-19 23:26   ` Doug Evans
2010-08-20 17:17     ` Keith Seitz
2010-08-22 18:46       ` New UNRESOLVED testcase gdb.dwarf2/dw2-double-set-die-type.exp [Re: [RFA] Delayed physnames, revisited] Jan Kratochvil
2010-08-23 19:13         ` Keith Seitz
2010-08-20 17:50     ` [RFA] Delayed physnames, revisited Thiago Jung Bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).