Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: recursive bug in dwarf2read.c
       [not found] ` <20091209185157.GA29691@caradoc.them.org>
@ 2009-12-10 19:39   ` Gaius Mulley
  2009-12-11 19:29     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Gaius Mulley @ 2009-12-10 19:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: drow


Daniel Jacobowitz <drow@false.org> writes:

> On Wed, Dec 09, 2009 at 10:55:30AM +0000, Gaius Mulley wrote:
>> 
>> Hi,
>> 
>> I think there is a bug in dwarf2read.c which can be exposed by
>> attempting to set a break point at RealIO_WriteFixed in this
>> executable.
>> 
>> I acknowledge the (gnu modula-2 generated executable) could probably
>> be at fault, nevertheless it does contain cyclic data structures which
>> are not explicitly created in the same way as C.  For example:
>> 
>> 
>> TYPE
>>   ScanState =  PROCEDURE (CHAR, VAR ScanClass, VAR ScanState);
>
> See e.g. this from read_structure_type:
>
>   /* We need to add the type field to the die immediately so we don't
>      infinitely recurse when dealing with pointers to the structure
>      type within the structure itself. */
>   set_die_type (die, type, cu);
>
> It looks as if read_subroutine_type does not do that, but now has to.

Hi Daniel,

here is a patch which fixes the bug above.  Embarrassingly after
checking my private gdb directories I found I fixed this last year
and sat on and forgot the patch.  Guess there is a moral here
somewhere..


2009-12-10  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.


--- src-orig/gdb/dwarf2read.c	2009-12-10 16:41:40.000000000 +0000
+++ src/gdb/dwarf2read.c	2009-12-10 17:04:16.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)
     {


I've ran the testsuite on a AMD64 debian stable (lenny) system and and
it doesn't appear to cause any regression.  I've also some minor
Modula-2 language support improvement patches which I wrote in Sept
which I'll now push out to the mailing list..

regards,
Gaius


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

* Re: recursive bug in dwarf2read.c
  2009-12-10 19:39   ` recursive bug in dwarf2read.c Gaius Mulley
@ 2009-12-11 19:29     ` Tom Tromey
  2009-12-11 20:56       ` Gaius Mulley
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2009-12-11 19:29 UTC (permalink / raw)
  To: Gaius Mulley; +Cc: gdb-patches, drow

>>>>> "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.

Tom


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

* Re: recursive bug in dwarf2read.c
  2009-12-11 19:29     ` Tom Tromey
@ 2009-12-11 20:56       ` Gaius Mulley
  2009-12-11 21:06         ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Gaius Mulley @ 2009-12-11 20:56 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches, drow

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


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

* Re: recursive bug in dwarf2read.c
  2009-12-11 20:56       ` Gaius Mulley
@ 2009-12-11 21:06         ` Tom Tromey
  2009-12-16 15:14           ` Gaius Mulley
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2009-12-11 21:06 UTC (permalink / raw)
  To: Gaius Mulley; +Cc: gdb-patches, drow

>>>>> "Gaius" == Gaius Mulley <gaius@glam.ac.uk> writes:

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

Thanks, this is ok.

Tom


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

* Re: recursive bug in dwarf2read.c
  2009-12-11 21:06         ` Tom Tromey
@ 2009-12-16 15:14           ` Gaius Mulley
  0 siblings, 0 replies; 5+ messages in thread
From: Gaius Mulley @ 2009-12-16 15:14 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches, drow

Tom Tromey <tromey@redhat.com> writes:

>>>>>> "Gaius" == Gaius Mulley <gaius@glam.ac.uk> writes:
>
> Gaius> ahh yes - true, here is the modified patch without the redundant
> Gaius> second call:
>
> Thanks, this is ok.
>
> Tom

Hi Tom,

many thanks, now committed to the head cvs,

regards,
Gaius

2009-12-15  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.


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

end of thread, other threads:[~2009-12-16 15:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <878wdcto0t.fsf@j228-gm.comp.glam.ac.uk>
     [not found] ` <20091209185157.GA29691@caradoc.them.org>
2009-12-10 19:39   ` recursive bug in dwarf2read.c Gaius Mulley
2009-12-11 19:29     ` Tom Tromey
2009-12-11 20:56       ` Gaius Mulley
2009-12-11 21:06         ` Tom Tromey
2009-12-16 15:14           ` Gaius Mulley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox