From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30104 invoked by alias); 15 Oct 2010 15:44:20 -0000 Received: (qmail 30095 invoked by uid 22791); 15 Oct 2010 15:44:20 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Oct 2010 15:44:14 +0000 Received: from md2.u-strasbg.fr (md2.u-strasbg.fr [IPv6:2001:660:2402::187]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o9FFhw0i078257 ; Fri, 15 Oct 2010 17:43:58 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms8.u-strasbg.fr [IPv6:2001:660:2402:d::17]) by md2.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o9FFhwPM014745 ; Fri, 15 Oct 2010 17:43:58 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o9FFhvvQ045803 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Fri, 15 Oct 2010 17:43:57 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Tom Tromey'" Cc: References: <35800.5107882947$1287069713@news.gmane.org> In-Reply-To: Subject: RE: [PATCH] Avoid pascal crashes for structures having fields without names Date: Fri, 15 Oct 2010 15:44:00 -0000 Message-ID: <002501cb6c7f$c9a6f680$5cf4e380$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00249.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Tom Tromey > Envoy=E9=A0: Thursday, October 14, 2010 7:48 PM > =C0=A0: Pierre Muller > Cc=A0: gdb-patches@sourceware.org > Objet=A0: Re: [PATCH] Avoid pascal crashes for structures having fields > without names >=20 > >>>>> "Pierre" =3D=3D Pierre Muller > writes: >=20 > Pierre> + && TYPE_FIELDS (type) [0].name >=20 > I think it is more idiomatic to use the accessors like TYPE_FIELD_NAME. >=20 > Tom Thanks for the suggestion, I changed the source to adapt to it. Patch applied, Pierre Muller Pascal language support maintainer for GDB Pierre =20 2010-10-15 Pierre Muller * p-lang.c (is_pascal_string_type): Use TYPE_FIELD_NAME accessor. Index: src/gdb/p-lang.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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) =3D=3D 2 - && TYPE_FIELDS (type) [0].name - && strcmp (TYPE_FIELDS (type)[0].name, "length") =3D=3D 0=20 - && TYPE_FIELDS (type) [1].name - && strcmp (TYPE_FIELDS (type)[1].name, "st") =3D=3D 0) + && TYPE_FIELD_NAME (type, 0) + && strcmp (TYPE_FIELD_NAME (type, 0), "length") =3D=3D 0=20 + && TYPE_FIELD_NAME (type, 1) + && strcmp (TYPE_FIELD_NAME (type, 1), "st") =3D=3D 0) { if (length_pos) *length_pos =3D TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT; @@ -120,16 +120,16 @@ is_pascal_string_type (struct type *type if (char_type) *char_type =3D TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1)); if (arrayname) - *arrayname =3D TYPE_FIELDS (type)[1].name; + *arrayname =3D TYPE_FIELD_NAME (type, 1); return 2; }; /* GNU pascal strings. */ /* Three fields: Capacity, length and schema$ or _p_schema. */ if (TYPE_NFIELDS (type) =3D=3D 3 - && TYPE_FIELDS (type) [0].name - && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") =3D=3D 0 - && TYPE_FIELDS (type) [1].name - && strcmp (TYPE_FIELDS (type)[1].name, "length") =3D=3D 0) + && TYPE_FIELD_NAME (type, 0) + && strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") =3D=3D 0 + && TYPE_FIELD_NAME (type, 1) + && strcmp (TYPE_FIELD_NAME (type, 1), "length") =3D=3D 0) { if (length_pos) *length_pos =3D TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT; @@ -146,7 +146,7 @@ is_pascal_string_type (struct type *type *char_type =3D TYPE_TARGET_TYPE (*char_type); } if (arrayname) - *arrayname =3D TYPE_FIELDS (type)[2].name; + *arrayname =3D TYPE_FIELD_NAME (type, 2); return 3; }; }