From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Tom Tromey'" <tromey@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: RE: [PATCH] Avoid pascal crashes for structures having fields without names
Date: Fri, 15 Oct 2010 15:44:00 -0000 [thread overview]
Message-ID: <002501cb6c7f$c9a6f680$5cf4e380$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <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;
};
}
next prev parent reply other threads:[~2010-10-15 15:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <35800.5107882947$1287069713@news.gmane.org>
2010-10-14 17:48 ` Tom Tromey
2010-10-15 15:44 ` Pierre Muller [this message]
2010-10-14 15:21 Pierre Muller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='002501cb6c7f$c9a6f680$5cf4e380$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox