From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19155 invoked by alias); 8 May 2010 15:33:00 -0000 Received: (qmail 19146 invoked by uid 22791); 8 May 2010 15:32:58 -0000 X-SWARE-Spam-Status: No, hits=-1.2 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.152) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 May 2010 15:32:52 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o48FWd1s078063 ; Sat, 8 May 2010 17:32:39 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [IPv6:2001:660:2402:d::10]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o48FWcWJ059474 ; Sat, 8 May 2010 17:32:38 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o48FWb6f061175 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Sat, 8 May 2010 17:32:38 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Cc: References: <36245.8778698512$1272577829@news.gmane.org> <1723.54181199825$1273097500@news.gmane.org> In-Reply-To: Subject: [RFA-v2] PR 11530: Fix and test case Date: Sat, 08 May 2010 15:33:00 -0000 Message-ID: <000001caeec3$b4068500$1c138f00$@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-05/txt/msg00212.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: Friday, May 07, 2010 7:46 PM > =C0=A0: Pierre Muller > Cc=A0: gdb-patches@sourceware.org > Objet=A0: Re: [RFA] PR 11530: Fix and test case >=20 > >>>>> "Pierre" =3D=3D Pierre Muller > writes: >=20 > Pierre> If the compiler is not gcc we should skip the test, > Pierre> is that what you want? >=20 > Pierre> if {![test_compiler_info gcc-*]} { > Pierre> return 0 > Pierre> } >=20 > Pierre> Would this fit? >=20 > Yes, thanks. It turned out that test_compiler_info needs a call to get_compiler_info before otherwise it returns unknown... Here is a new version of the patch. Tested on gcc16, adds 3 PASS (while current CVS=20 gives two failures on gdb11530.exp test). Pierre =20 2010-05-08 Pierre Muller PR exp/11530. * gdbtypes.c (lookup_struct_elt_type): Also lookup names of unnamed structures or unions. testsuite ChangeLog entry: 2010-05-08 Pierre Muller PR exp/11530. * testsuite/gdb.base/gdb11530.c: New file. * testsuite/gdb.base/gdb11530.exp: New file. =09 Index: gdbtypes.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/gdbtypes.c,v retrieving revision 1.190 diff -u -p -r1.190 gdbtypes.c --- gdbtypes.c 6 May 2010 19:41:12 -0000 1.190 +++ gdbtypes.c 8 May 2010 14:01:26 -0000 @@ -1244,6 +1244,13 @@ lookup_struct_elt_type (struct type *typ { return TYPE_FIELD_TYPE (type, i); } + else if (!t_field_name || *t_field_name =3D=3D '\0') + { + struct type *subtype =3D lookup_struct_elt_type ( + TYPE_FIELD_TYPE (type, i), name, 1); + if (subtype !=3D NULL) + return subtype; + } } =20 /* OK, it's not in this class. Recursively check the baseclasses. */ Index: testsuite/gdb.base/gdb11530.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: testsuite/gdb.base/gdb11530.c diff -N testsuite/gdb.base/gdb11530.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/gdb11530.c 8 May 2010 14:01:26 -0000 @@ -0,0 +1,35 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. + + Contributed by Pierre Muller. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Test for problem related to unnamed unions. */ + +struct a + { + union + { + int i; + }; + } a; + +int +main (void) +{ + return sizeof (a.i); +} + Index: testsuite/gdb.base/gdb11530.exp =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: testsuite/gdb.base/gdb11530.exp diff -N testsuite/gdb.base/gdb11530.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/gdb11530.exp 8 May 2010 14:01:26 -0000 @@ -0,0 +1,55 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test GDB bug report 11530. +# This is a problem related unnamed unions. + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile "gdb11530" +set binfile ${testfile}${EXEEXT} + +# Unnamed union is a GNU extension, thus we restrict the test +# to gcc compiler. + +if [get_compiler_info ${binfile}] { + return -1; +} + +if { ![test_compiler_info gcc*] } { + return 0; +} + +if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug}] } { + return -1; +} + + +if { ![runto main] } then { + fail "run to main" + return +} + +gdb_test "print a.i" " =3D 0" +gdb_test "print sizeof (a.i)" " =3D \[0-9\]+" +gdb_test "print sizeof (a.i) =3D=3D sizeof (int)" " =3D 1" +