* patch for dwarf2read.c
@ 2008-11-17 20:42 Gaius Mulley
2008-11-17 21:02 ` Gaius Mulley
2008-11-17 22:01 ` Daniel Jacobowitz
0 siblings, 2 replies; 4+ messages in thread
From: Gaius Mulley @ 2008-11-17 20:42 UTC (permalink / raw)
To: gdb-patches
Hi,
here is a patch for dwarf2read.c which fixes a cyclic recursive bug
when gdb is asked to resolve the following Modula-2 procedure type:
ScanClass = (padding, valid, invalid, terminator);
ScanState = PROCEDURE (CHAR, VAR ScanClass, VAR ScanState);
when compiled by gm2.
regards,
Gaius
--- orig/src/gdb/dwarf2read.c 2008-11-16 23:51:59.000000000 +0000
+++ modified/src/gdb/dwarf2read.c 2008-11-16 23:47:51.000000000 +0000
@@ -769,6 +769,9 @@
static void add_partial_enumeration (struct partial_die_info *enum_pdi,
struct dwarf2_cu *cu);
+static void add_partial_subroutine_type (struct partial_die_info *enum_pdi,
+ struct dwarf2_cu *cu);
+
static void add_partial_subprogram (struct partial_die_info *pdi,
CORE_ADDR *lowpc, CORE_ADDR *highpc,
struct dwarf2_cu *cu);
@@ -2287,6 +2290,32 @@
}
}
+/* Read a partial die corresponding to a subroutine type. */
+
+static void
+add_partial_subroutine_type (struct partial_die_info *subroutine_type_pdi,
+ struct dwarf2_cu *cu)
+{
+ struct objfile *objfile = cu->objfile;
+ bfd *abfd = objfile->obfd;
+ struct partial_die_info *pdi;
+
+ if (subroutine_type_pdi->name != NULL)
+ add_partial_symbol (subroutine_type_pdi, cu);
+
+ pdi = subroutine_type_pdi->die_child;
+ while (pdi)
+ {
+ if (pdi->tag != DW_TAG_formal_parameter
+ || pdi->tag != DW_TAG_unspecified_parameters
+ || pdi->name == NULL)
+ complaint (&symfile_complaints, _("malformed parameter DIE ignored"));
+ else
+ add_partial_symbol (pdi, cu);
+ pdi = pdi->die_sibling;
+ }
+}
+
/* Read the initial uleb128 in the die at INFO_PTR in compilation unit CU.
Return the corresponding abbrev, or NULL if the number is zero (indicating
an empty DIE). In either case *BYTES_READ will be set to the length of
@@ -4946,7 +4975,16 @@
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;
-
+
+ TYPE_STUB_SUPPORTED (ftype) = 1;
+ if (die_is_declaration (die, cu))
+ TYPE_STUB (ftype) = 1;
+
+ /* We need to add the type field 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)
{
struct die_info *child_die;
@@ -4993,7 +5031,7 @@
}
}
- return set_die_type (die, ftype, cu);
+ return ftype;
}
static struct type *
@@ -5598,8 +5636,8 @@
case DW_TAG_ptr_to_member_type:
case DW_TAG_set_type:
case DW_TAG_string_type:
- case DW_TAG_subroutine_type:
#endif
+ case DW_TAG_subroutine_type:
case DW_TAG_base_type:
case DW_TAG_class_type:
case DW_TAG_interface_type:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: patch for dwarf2read.c
2008-11-17 20:42 patch for dwarf2read.c Gaius Mulley
@ 2008-11-17 21:02 ` Gaius Mulley
2008-11-17 22:01 ` Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Gaius Mulley @ 2008-11-17 21:02 UTC (permalink / raw)
To: gdb-patches
Gaius Mulley <gaius@glam.ac.uk> writes:
> Hi,
>
> here is a patch for dwarf2read.c which fixes a cyclic recursive bug
> when gdb is asked to resolve the following Modula-2 procedure type:
>
> ScanClass = (padding, valid, invalid, terminator);
> ScanState = PROCEDURE (CHAR, VAR ScanClass, VAR ScanState);
>
> when compiled by gm2.
>
> regards,
> Gaius
ps. oops I forgot to say that no more regression tests fail if the
patch is applied on the x86_64 Debian GNU/Linux platform
>
>
>
> --- orig/src/gdb/dwarf2read.c 2008-11-16 23:51:59.000000000 +0000
> +++ modified/src/gdb/dwarf2read.c 2008-11-16 23:47:51.000000000 +0000
> @@ -769,6 +769,9 @@
> static void add_partial_enumeration (struct partial_die_info *enum_pdi,
> struct dwarf2_cu *cu);
>
> +static void add_partial_subroutine_type (struct partial_die_info *enum_pdi,
> + struct dwarf2_cu *cu);
> +
> static void add_partial_subprogram (struct partial_die_info *pdi,
> CORE_ADDR *lowpc, CORE_ADDR *highpc,
> struct dwarf2_cu *cu);
> @@ -2287,6 +2290,32 @@
> }
> }
>
> +/* Read a partial die corresponding to a subroutine type. */
> +
> +static void
> +add_partial_subroutine_type (struct partial_die_info *subroutine_type_pdi,
> + struct dwarf2_cu *cu)
> +{
> + struct objfile *objfile = cu->objfile;
> + bfd *abfd = objfile->obfd;
> + struct partial_die_info *pdi;
> +
> + if (subroutine_type_pdi->name != NULL)
> + add_partial_symbol (subroutine_type_pdi, cu);
> +
> + pdi = subroutine_type_pdi->die_child;
> + while (pdi)
> + {
> + if (pdi->tag != DW_TAG_formal_parameter
> + || pdi->tag != DW_TAG_unspecified_parameters
> + || pdi->name == NULL)
> + complaint (&symfile_complaints, _("malformed parameter DIE ignored"));
> + else
> + add_partial_symbol (pdi, cu);
> + pdi = pdi->die_sibling;
> + }
> +}
> +
> /* Read the initial uleb128 in the die at INFO_PTR in compilation unit CU.
> Return the corresponding abbrev, or NULL if the number is zero (indicating
> an empty DIE). In either case *BYTES_READ will be set to the length of
> @@ -4946,7 +4975,16 @@
> 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;
> -
> +
> + TYPE_STUB_SUPPORTED (ftype) = 1;
> + if (die_is_declaration (die, cu))
> + TYPE_STUB (ftype) = 1;
> +
> + /* We need to add the type field 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)
> {
> struct die_info *child_die;
> @@ -4993,7 +5031,7 @@
> }
> }
>
> - return set_die_type (die, ftype, cu);
> + return ftype;
> }
>
> static struct type *
> @@ -5598,8 +5636,8 @@
> case DW_TAG_ptr_to_member_type:
> case DW_TAG_set_type:
> case DW_TAG_string_type:
> - case DW_TAG_subroutine_type:
> #endif
> + case DW_TAG_subroutine_type:
> case DW_TAG_base_type:
> case DW_TAG_class_type:
> case DW_TAG_interface_type:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: patch for dwarf2read.c
2008-11-17 20:42 patch for dwarf2read.c Gaius Mulley
2008-11-17 21:02 ` Gaius Mulley
@ 2008-11-17 22:01 ` Daniel Jacobowitz
2008-11-20 1:56 ` Gaius Mulley
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-11-17 22:01 UTC (permalink / raw)
To: Gaius Mulley; +Cc: gdb-patches
On Mon, Nov 17, 2008 at 09:28:07AM +0000, Gaius Mulley wrote:
>
> Hi,
>
> here is a patch for dwarf2read.c which fixes a cyclic recursive bug
> when gdb is asked to resolve the following Modula-2 procedure type:
>
> ScanClass = (padding, valid, invalid, terminator);
> ScanState = PROCEDURE (CHAR, VAR ScanClass, VAR ScanState);
>
> when compiled by gm2.
Patches should include a changelog entry, please. What's
add_partial_subroutine_type about? It has a few bugs in it, but it's
also not called.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: patch for dwarf2read.c
2008-11-17 22:01 ` Daniel Jacobowitz
@ 2008-11-20 1:56 ` Gaius Mulley
0 siblings, 0 replies; 4+ messages in thread
From: Gaius Mulley @ 2008-11-20 1:56 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz <drow@false.org> writes:
> Patches should include a changelog entry, please. What's
> add_partial_subroutine_type about? It has a few bugs in it, but it's
> also not called.
Hi Daniel,
thanks for the feedback.. yes you are right the
add_partial_subroutine_type was not needed. Here is the tidied up
patch together with a ChangeLog entry. I've run the regression tests
on LP64 GNU/Linux Debian Stable and also i686 GNU/Linux Debian Stable.
On the i686 platform there are no more regression test failures if
this patch is applied. On the LP64 platform the failures sometimes
increase and sometimes decrease.. I'm not sure whether this is
expected? The instability appears to be in the region of the:
< PASS: gdb.mi/mi-nonstop.exp: update varobj, 2
< PASS: gdb.mi/mi-nonstop.exp: stacktrace of stopped thread
< PASS: gdb.mi/mi-nonstop.exp: select first worker thread
< PASS: gdb.mi/mi-nonstop.exp: ask the second thread to exit
< PASS: gdb.mi/mi-nonstop.exp: wait for thread exit
< PASS: gdb.mi/mi-nonstop.exp: stacktrace of stopped thread
tests - which, time this passed on the patched version and failed on
the unpatched version - very odd. Anyhow it would be great if a
dwarf-2 guru could eyeball the patch below as this is my first foray
into dwarf2read.c
regards,
Gaius
--- orig/src/gdb/dwarf2read.c 2008-11-15 18:49:50.000000000 +0000
+++ modified/src/gdb/dwarf2read.c 2008-11-19 19:03:27.000000000 +0000
@@ -4953,7 +4953,12 @@
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)
{
struct die_info *child_die;
@@ -5000,7 +5005,7 @@
}
}
- return set_die_type (die, ftype, cu);
+ return ftype;
}
static struct type *
2008-11-19 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] 4+ messages in thread
end of thread, other threads:[~2008-11-19 20:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-17 20:42 patch for dwarf2read.c Gaius Mulley
2008-11-17 21:02 ` Gaius Mulley
2008-11-17 22:01 ` Daniel Jacobowitz
2008-11-20 1:56 ` Gaius Mulley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox