From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29537 invoked by alias); 29 Apr 2010 21:50:23 -0000 Received: (qmail 29528 invoked by uid 22791); 29 Apr 2010 21:50:22 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=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.157) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Apr 2010 21:50:18 +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 o3TLoEpJ034682 for ; Thu, 29 Apr 2010 23:50:15 +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 o3TLoELH034366 for ; Thu, 29 Apr 2010 23:50:14 +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 o3TLoD1U017975 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 29 Apr 2010 23:50:14 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [RFA] PR 11530: Fix and test case Date: Thu, 29 Apr 2010 21:50:00 -0000 Message-ID: <001b01cae7e5$f46d47d0$dd47d770$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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-04/txt/msg00965.txt.bz2 This is a problem reported by Jan Kratochvil http://sourceware.org/bugzilla/show_bug.cgi?id=11530 After some debugging, I found this fix, and wrote a test case. Tested on gcc16 2 FAIL within gdb11530.exp with pristine disappear with patched versions. No other change (apart from the tests that are unstable, like: ext-run.exp (I often get an 'internal buffer is full' error for that test) attach-into-signal.exp and watchthreads2.exp Is this patch OK? Pierre Muller Pascal language support maintainer for GDB 2010-04-29 Pierre Muller PR exp/11530. * gdbtypes.c (lookup_struct_elt_type): Also lookup names of unnamed structures or unions. testsuite ChangeLog entry: 2010-04-29 Pierre Muller PR exp/11530. * testsuite/gdb.base/gdb11530.c: New file. * testsuite/gdb.base/gdb11530.exp: New file. Index: src/gdb/gdbtypes.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.c,v retrieving revision 1.189 diff -u -p -r1.189 gdbtypes.c --- src/gdb/gdbtypes.c 21 Apr 2010 23:21:03 -0000 1.189 +++ src/gdb/gdbtypes.c 29 Apr 2010 21:23:35 -0000 @@ -1246,6 +1246,13 @@ lookup_struct_elt_type (struct type *typ { return TYPE_FIELD_TYPE (type, i); } + else if (!t_field_name || *t_field_name == '\0') + { + struct type *subtype = lookup_struct_elt_type ( + TYPE_FIELD_TYPE (type, i), name, 1); + if (subtype != NULL) + return subtype; + } } /* OK, it's not in this class. Recursively check the baseclasses. */ Index: src/gdb/testsuite/gdb.base/gdb11530.c =================================================================== RCS file: testsuite/gdb.base/gdb11530.c diff -N testsuite/gdb.base/gdb11530.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/testsuite/gdb.base/gdb11530.c 29 Apr 2010 21:23:37 -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: src/gdb/testsuite/gdb.base/gdb11530.exp =================================================================== RCS file: testsuite/gdb.base/gdb11530.exp diff -N testsuite/gdb.base/gdb11530.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/testsuite/gdb.base/gdb11530.exp 29 Apr 2010 21:23:37 -0000 @@ -0,0 +1,44 @@ +# 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 11531. +# This is a problem related to CANNOT_STEP_HW_WATCHPOINTS macro. +# It affects Solaris native targets. + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile "gdb11530" + +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" " = 0" +gdb_test "print sizeof (a.i)" " = \[0-9\]+" +gdb_test "print sizeof (a.i) == sizeof (int)" " = 1" +