From: Doug Evans <dje@google.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Print nonexisting/optimized out static fields gracefully.
Date: Tue, 15 Oct 2013 23:45:00 -0000 [thread overview]
Message-ID: <21085.54173.143927.913006@ruffy.mtv.corp.google.com> (raw)
In-Reply-To: <1381429510-14825-1-git-send-email-palves@redhat.com>
Pedro Alves writes:
> With:
>
> struct static_struct { static int aaa; };
> struct static_struct sss;
> int main () { return 0; }
>
> We get:
>
> (gdb) p sss
> $1 = {static aaa = <optimized out>}
> (gdb) p sss.aaa
> field aaa is nonexistent or has been optimized out
>
> Note that the "field aaa ..." message is an error being thrown.
>
> GDB is graceful everywhere else when printing optimized out values.
> IOW it usually prints an <optimized out> value and puts that in the
> value history. I see no reason for here to be different, more so that
> when the print the whole "containing" object (well, it's a static
> field, so it's not really a container), we already print <optimized
> out>.
>
> After the patch:
>
> (gdb) p sss
> $1 = {static aaa = <optimized out>}
> (gdb) p sss.aaa
> field aaa is nonexistent or has been optimized out
> (gdb) p sss.aaa
> $2 = <optimized out>
>
> The value_entirely_optimized_out checks are there to preserve
> behavior. Without those, if the static field is a struct/union, GDB
> would go and print its fields one by one (and print <optimized out>
> for each).
>
> Tested on x86_64 Fedora 17.
>
> gdb/
> 2013-10-10 Pedro Alves <palves@redhat.com>
>
> * cp-valprint.c (cp_print_value_fields): No longer handle a NULL
> static field value.
> (cp_print_static_field): If the value is entirely optimized out,
> print <optimized out> here.
> * jv-valprint.c (java_print_value_fields): No longer handle a NULL
> static field value.
> * p-valprint.c (pascal_object_print_static_field): If the value is
> entirely optimized out, print <optimized out> here.
> * valops.c (do_search_struct_field)
> (value_struct_elt_for_reference): No longer handle a NULL static
> field value.
> * value.c (value_static_field): Return an optimized out value
> instead of NULL.
>
> gdb/testsuite/
> 2013-10-10 Pedro Alves <palves@redhat.com>
>
> * gdb.cp/m-static.exp: Adjust expected output of printing a
> nonexistent or optimized out static field. Also test printing the
> the "container" object.
"works for me"
[modulo nit noticed by Yao]
prev parent reply other threads:[~2013-10-15 23:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-10 18:25 Pedro Alves
2013-10-15 1:07 ` Yao Qi
2013-10-15 9:48 ` Pedro Alves
2013-10-15 23:45 ` Doug Evans [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=21085.54173.143927.913006@ruffy.mtv.corp.google.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/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