recursive bug in dwarf2read.c

Gaius Mulley gaius@glam.ac.uk
Fri Dec 11 20:56:00 GMT 2009


Tom Tromey <tromey@redhat.com> writes:

>>>>>> "Gaius" == Gaius Mulley <gaius@glam.ac.uk> writes:
>
> Gaius> 2009-12-10  Gaius Mulley  <gaius@glam.ac.uk>
> Gaius> 	* dwarf2read.c (read_subroutine_type): Add the subroutine
> Gaius> 	  type to the die immediately to allow a parameter type to be
> Gaius> 	  the same subroutine type.
>
> This seems almost ok to me.
>
> With this change, read_subroutine_type calls set_die_type twice.
> I think it would be preferable to eliminate the second call.

Hi Tom,

ahh yes - true, here is the modified patch without the redundant
second call:

--- src-orig/gdb/dwarf2read.c	2009-12-10 16:41:40.000000000 +0000
+++ src/gdb/dwarf2read.c	2009-12-11 20:31:52.000000000 +0000
@@ -5879,6 +5879,11 @@
      the default value DW_CC_normal.  */
   attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
   TYPE_CALLING_CONVENTION (ftype) = attr ? DW_UNSND (attr) : DW_CC_normal;
+
+  /* We need to add the subroutine type to the die immediately so
+     we don't infinitely recurse when dealing with parameters
+     declared as the same subroutine type. */
+  set_die_type (die, ftype, cu);
   
   if (die->child != NULL)
     {
@@ -5926,7 +5931,7 @@
 	}
     }
 
-  return set_die_type (die, ftype, cu);
+  return ftype;
 }
 
 static struct type *

2009-12-11  Gaius Mulley  <gaius@glam.ac.uk>

	* dwarf2read.c (read_subroutine_type): Add the subroutine
	  type to the die immediately to allow a parameter type to be
	  the same subroutine type.


regards,
Gaius



More information about the Gdb-patches mailing list