From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24169 invoked by alias); 14 Jun 2010 16:12:02 -0000 Received: (qmail 24158 invoked by uid 22791); 14 Jun 2010 16:12:01 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.17.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jun 2010 16:11:54 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.1/8.13.1) with ESMTP id o5EGBpdj026574 for ; Mon, 14 Jun 2010 16:11:51 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5EGBpWF1294520 for ; Mon, 14 Jun 2010 18:11:51 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o5EGBprN010747 for ; Mon, 14 Jun 2010 18:11:51 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id o5EGBoAQ010712; Mon, 14 Jun 2010 18:11:50 +0200 Message-Id: <201006141611.o5EGBoAQ010712@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Mon, 14 Jun 2010 18:11:50 +0200 Subject: Re: PR10687 Printing c++ class with static array (of same type) can produce infinite output To: cmoller@redhat.com (Chris Moller) Date: Mon, 14 Jun 2010 16:12:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <4BC524E8.404@redhat.com> from "Chris Moller" at Apr 13, 2010 10:14:00 PM 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-06/txt/msg00314.txt.bz2 Chris Moller wrote: > + if (TYPE_CODE (type) == TYPE_CODE_ARRAY) > + { > + struct type **first_dont_print; > + int i; > + struct type * target_type = TYPE_TARGET_TYPE (type); > + > + first_dont_print > + = (struct type **) obstack_base (&dont_print_stat_array_obstack); > + i = obstack_object_size (&dont_print_stat_array_obstack) > + / sizeof (CORE_ADDR); > + > + while (--i >= 0) > + { > + if (target_type == first_dont_print[i]) > + { > + fputs_filtered (" + " seen type>", > + stream); > + return; > + } > + } > + > + obstack_grow (&dont_print_stat_array_obstack, (char *) &target_type, > + sizeof (struct type *)); > + } This is broken on platforms where sizeof (CORE_ADDR) != sizeof (struct type *). As the objects stored into the dont_print_stat_array_obstack are in fact of type "struct type *", the size computations also need to use this type's size. I'm seeing this problem on a spu-elf GDB built as 32-bit PowerPC executable. Fixed by the patch below. Tested on spu-elf, committed to mainline. Bye, Ulrich ChangeLog: * cp-valprint.c (cp_print_static_field): Members of dont_print_stat_array_obstack are of type "struct type *". (_initialize_cp_valprint): Likewise. Index: gdb/cp-valprint.c =================================================================== RCS file: /cvs/src/src/gdb/cp-valprint.c,v retrieving revision 1.69 diff -u -p -r1.69 cp-valprint.c --- gdb/cp-valprint.c 11 Jun 2010 15:36:04 -0000 1.69 +++ gdb/cp-valprint.c 14 Jun 2010 16:03:53 -0000 @@ -615,7 +615,7 @@ cp_print_static_field (struct type *type first_dont_print = (struct type **) obstack_base (&dont_print_stat_array_obstack); i = obstack_object_size (&dont_print_stat_array_obstack) - / sizeof (CORE_ADDR); + / sizeof (struct type *); while (--i >= 0) { @@ -764,7 +764,7 @@ Show printing of object's derived type b show_objectprint, &setprintlist, &showprintlist); - obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR)); + obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (struct type *)); obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR)); obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *)); } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com