From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13714 invoked by alias); 8 Apr 2010 20:40:38 -0000 Received: (qmail 13671 invoked by uid 22791); 8 Apr 2010 20:40:34 -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.152) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 08 Apr 2010 20:40:25 +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 o38KeK0i010776 for ; Thu, 8 Apr 2010 22:40:20 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms3.u-strasbg.fr [IPv6:2001:660:2402:d::12]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o38KeKf7073142 for ; Thu, 8 Apr 2010 22:40:20 +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 o38KeJl8082759 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 8 Apr 2010 22:40:20 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [RFC] Fix bug report 11479 Date: Thu, 08 Apr 2010 20:40:00 -0000 Message-ID: <000f01cad75b$b53278a0$1f9769e0$@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/msg00190.txt.bz2 I finally for once decide to use the bug database. I reported bug 11479, with a simple test case. http://sourceware.org/bugzilla/show_bug.cgi?id=11479 Here is the patch that fixes the problem for me. This is not a direct RFA for two reasons: 1) I don't remember how the ChangeLog should reflect the fact that the commit is related to this bug. 2) concerning the fix in stabsread.c, this chain of different types that all point to the same main type could apparently be something else than just a simple 'const' or 'volatile' modifier. But I don't think that I know enough about the other possibilities to know if I should exclude them from my patch by checking if only TYPE_CONST and TYPE_VOLATILE are different. Pierre 2010-04-08 Pierre Muller * stabsread.c (read_struct_type): Also set length of other types in the chain. Testsuite ChangeLog entry: 2010-04-08 Pierre Muller Test for bug 11479. * gdb.stabs/gdb11479.exp: New file. * gdb.stabs/gdb11479.c: New file. Index: src/gdb/stabsread.c =================================================================== RCS file: /cvs/src/src/gdb/stabsread.c,v retrieving revision 1.124 diff -u -p -r1.124 stabsread.c --- src/gdb/stabsread.c 5 Apr 2010 22:43:47 -0000 1.124 +++ src/gdb/stabsread.c 8 Apr 2010 16:35:24 -0000 @@ -3448,9 +3448,17 @@ read_struct_type (char **pp, struct type { int nbits; + struct type *ntype; TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits, 0); if (nbits != 0) return error_type (pp, objfile); + ntype = TYPE_CHAIN (type); + while (ntype != type) + { + if (TYPE_LENGTH(ntype) == 0) + TYPE_LENGTH (ntype) = TYPE_LENGTH (type); + ntype = TYPE_CHAIN (ntype); + } } /* Now read the baseclasses, if any, read the regular C struct or C++ Index: src/gdb/testsuite/gdb.stabs/gdb11479.exp =================================================================== RCS file: testsuite/gdb.stabs/gdb11479.exp diff -N testsuite/gdb.stabs/gdb11479.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/testsuite/gdb.stabs/gdb11479.exp 8 Apr 2010 16:35:24 -0000 @@ -0,0 +1,51 @@ +# 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 . + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# Test GDB stabs problem with qualified parameter of forward types. + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile "gdb11479" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "couldn't compile ${srcdir}/${subdir}/${srcfile}" + return -1 +} + +# Start with a fresh gdb. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# Regression test for a cleanup bug in the charset code. +gdb_test "rb test" "" "Set breakpoints" +gdb_test "run" "Breakpoint .* test2 .*" "Stop at first breakpoint" +gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" "Inspect t in test2" +gdb_test "continue" "Breakpoint .* test .*" "Stop at first breakpoint" +gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" "Inspect t in test" + +gdb_exit Index: src/gdb/testsuite/gdb.stabs/gdb11479.c =================================================================== RCS file: testsuite/gdb.stabs/gdb11479.c diff -N testsuite/gdb.stabs/gdb11479.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/testsuite/gdb.stabs/gdb11479.c 8 Apr 2010 16:35:24 -0000 @@ -0,0 +1,61 @@ +/* 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +/* Qualifiers of forward types are not resolved correctly with stabs. */ + +struct dummy; + +const void * +test (const struct dummy *t) +{ + const struct dummy *tt; + tt = t; + return t; +} + +void * +test2 (struct dummy *t) +{ + struct dummy *tt; + tt = t; + return t; +} + + +struct dummy { + int x; + int y; + double b; +} tag_dummy; + + +int +main () +{ + struct dummy tt; + tt.x = 5; + tt.y = 25; + tt.b = 2.5; + test2 (&tt); + test (&tt); + return 0; +}