This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: bokenness of nested pretty printers
- From: "Paul Pluzhnikov" <ppluzhnikov at google dot com>
- To: "Tom Tromey" <tromey at redhat dot com>
- Cc: archer at sourceware dot org
- Date: Thu, 16 Oct 2008 13:33:03 -0700
- Subject: Re: bokenness of nested pretty printers
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1224189195; bh=55zM//fh3ANu88tWaN1U/AIkov0=;h=DomainKey-Signature:Message-ID:Date:From:To:Subject:Cc: In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-Disposition:References; b=qGGXuvYguttChqqV/49eOjcJhYTqHoLZhktQp/64fyMukNazwJxySIqrlcPnWylZlZNLZQfndk6p+2OWsG4cXg==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;b=KiZ0Jvm7K6usWW+KxY6O8Ts8T2pbzBqXBiz0ie1MYxiyPdiV2wUj+AC97WkT4r0dh8wuqGH3L4mDSs2lNEhD4A==
- References: <20081016184635.E2BF03A6AF6@localhost> <m3iqrs73pm.fsf@fleche.redhat.com>
On Thu, Oct 16, 2008 at 12:13 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
>
> Paul> I think fixing this requires either that we pass down 'value' itself,
> Paul> or at least 'value->offset'.
>
> Thanks. Nice analysis.
>
> Paul> Comments?
>
> I notice c-valprint.c does:
>
> return val_print (type, value_contents_all (val),
> value_embedded_offset (val),
> VALUE_ADDRESS (val) + value_offset (val),
>
> That last line seems to indicate the answer.
Yes, I forgot to mention the 'adjust address when calling
val_print()' alternative.
> Strangely, many calls to val_print do not do this.
I think this may just be a 'problem waiting to happen' (see below).
> I wonder why VALUE_ADDRESS does not do this addition itself.
I don't quite understand why 'offset' is even needed (and GDB
internals is silent on the whole 'what are values' subject :(
> The appended fixes this particular instance of the problem for me.
> Of course, we'd have to audit all the calls to make sure the problem
> is fully fixed.
Indeed.
Here is a modification to the original which shows that
val_print_array_elements() is similarly broken:
int
main ()
{
struct ss ss;
struct ss ssa[2];
init_ss(&ss, 1, 2);
init_ss(ssa+0, 3, 4);
init_ss(ssa+1, 5, 6);
return 0; /* break to inspect struct and union */
}
With your patch, 'print ssa[0]' and 'print ssa[1]' work fine, but
'print ssa' results in:
(gdb) p ssa
$4 = {Traceback (most recent call last):
File "<string>", line 6, in pp_s
Exception: &a(0x0) != b(0x7fffffffe5d0)
Traceback (most recent call last):
File "<string>", line 6, in pp_s
Exception: &a(0x10) != b(0x7fffffffe5e0)
a={{a = 3, b = 0x7fffffffe5d0}} b={{a = 4, b = 0x7fffffffe5e0}},
Traceback (most recent call last):
File "<string>", line 6, in pp_s
Exception: &a(0x0) != b(0x7fffffffe5f0)
Traceback (most recent call last):
File "<string>", line 6, in pp_s
Exception: &a(0x10) != b(0x7fffffffe600)
a={{a = 5, b = 0x7fffffffe5f0}} b={{a = 6, b = 0x7fffffffe600}}}
> What do you think of this approach?
I don't understand 'values' enough to have an opinion,
but it seems pretty error-prone to require every user to do this...
If 'offset' is really necessary, then I think VALUE_ADDRESS()
or something similar ought to add 'offset' automatically.
Thanks,
--
Paul Pluzhnikov