From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: cmoller@redhat.com (Chris Moller)
Cc: gdb-patches@sourceware.org
Subject: Re: PR10687 Printing c++ class with static array (of same type) can produce infinite output
Date: Mon, 14 Jun 2010 16:12:00 -0000 [thread overview]
Message-ID: <201006141611.o5EGBoAQ010712@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <4BC524E8.404@redhat.com> from "Chris Moller" at Apr 13, 2010 10:14:00 PM
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 ("<same as static member of an already"
> + " 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
prev parent reply other threads:[~2010-06-14 16:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-14 2:14 Chris Moller
2010-04-20 18:27 ` Tom Tromey
2010-04-20 20:24 ` Chris Moller
2010-06-14 16:12 ` Ulrich Weigand [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201006141611.o5EGBoAQ010712@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=cmoller@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox