This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH] Avoid pascal crashes for structures having fields without names
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Tom Tromey'" <tromey at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Fri, 15 Oct 2010 17:44:00 +0200
- Subject: RE: [PATCH] Avoid pascal crashes for structures having fields without names
- References: <35800.5107882947$1287069713@news.gmane.org> <m3d3rc8y3f.fsf@fleche.redhat.com>
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé?: Thursday, October 14, 2010 7:48 PM
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [PATCH] Avoid pascal crashes for structures having fields
> without names
>
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
> writes:
>
> Pierre> + && TYPE_FIELDS (type) [0].name
>
> I think it is more idiomatic to use the accessors like TYPE_FIELD_NAME.
>
> Tom
Thanks for the suggestion,
I changed the source to adapt to it.
Patch applied,
Pierre Muller
Pascal language support maintainer for GDB
Pierre
2010-10-15 Pierre Muller <muller@ics.u-strasbg.fr>
* p-lang.c (is_pascal_string_type): Use TYPE_FIELD_NAME accessor.
Index: src/gdb/p-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/p-lang.c,v
retrieving revision 1.56
diff -u -p -r1.56 p-lang.c
--- src/gdb/p-lang.c 14 Oct 2010 15:18:53 -0000 1.56
+++ src/gdb/p-lang.c 15 Oct 2010 15:20:00 -0000
@@ -106,10 +106,10 @@ is_pascal_string_type (struct type *type
/* Old Borland type pascal strings from Free Pascal Compiler. */
/* Two fields: length and st. */
if (TYPE_NFIELDS (type) == 2
- && TYPE_FIELDS (type) [0].name
- && strcmp (TYPE_FIELDS (type)[0].name, "length") == 0
- && TYPE_FIELDS (type) [1].name
- && strcmp (TYPE_FIELDS (type)[1].name, "st") == 0)
+ && TYPE_FIELD_NAME (type, 0)
+ && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
+ && TYPE_FIELD_NAME (type, 1)
+ && strcmp (TYPE_FIELD_NAME (type, 1), "st") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
@@ -120,16 +120,16 @@ is_pascal_string_type (struct type *type
if (char_type)
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
if (arrayname)
- *arrayname = TYPE_FIELDS (type)[1].name;
+ *arrayname = TYPE_FIELD_NAME (type, 1);
return 2;
};
/* GNU pascal strings. */
/* Three fields: Capacity, length and schema$ or _p_schema. */
if (TYPE_NFIELDS (type) == 3
- && TYPE_FIELDS (type) [0].name
- && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
- && TYPE_FIELDS (type) [1].name
- && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
+ && TYPE_FIELD_NAME (type, 0)
+ && strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0
+ && TYPE_FIELD_NAME (type, 1)
+ && strcmp (TYPE_FIELD_NAME (type, 1), "length") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
@@ -146,7 +146,7 @@ is_pascal_string_type (struct type *type
*char_type = TYPE_TARGET_TYPE (*char_type);
}
if (arrayname)
- *arrayname = TYPE_FIELDS (type)[2].name;
+ *arrayname = TYPE_FIELD_NAME (type, 2);
return 3;
};
}