diff options
author | Pedro Alves <palves@redhat.com> | 2013-10-25 11:37:13 +0100 |
---|---|---|
committer | Tom Tromey <tromey@sourceware.org> | 2013-10-25 14:03:01 +0000 |
commit | 686d4defdf4a343d4b700b8b544cd40c4f16b0d1 (patch) | |
tree | 2bc3b79e49661ce780c986420177dd8f0f43eabf /gdb/testsuite | |
parent | 96691246d49443c5141ec225c7cd313ce0015850 (diff) | |
download | gdb-686d4defdf4a343d4b700b8b544cd40c4f16b0d1.zip gdb-686d4defdf4a343d4b700b8b544cd40c4f16b0d1.tar.gz gdb-686d4defdf4a343d4b700b8b544cd40c4f16b0d1.tar.bz2 |
Print nonexisting/optimized out static fields gracefully.
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
$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-25 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-25 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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/m-static.exp | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 40391c9..0c1dbef 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-10-25 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. + 2013-10-24 Maciej W. Rozycki <macro@codesourcery.com> * lib/gdb.exp (gdb_finish): Send a kill request to `gdbserver' diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp index 9b0e642..a5d388c 100644 --- a/gdb/testsuite/gdb.cp/m-static.exp +++ b/gdb/testsuite/gdb.cp/m-static.exp @@ -169,7 +169,10 @@ if {[test_compiler_info {gcc-[0-3]-*}] # and DW_AT_MIPS_linkage_name = _ZN9gnu_obj_47nowhereE . setup_xfail *-*-* } -gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimized out" "static const int initialized nowhere" +gdb_test "print test4.nowhere" "<optimized out>" "static const int initialized nowhere (print field)" + +# Same, but print the whole struct. +gdb_test "print test4" "static nowhere = <optimized out>.*" "static const int initialized nowhere (whole struct)" # static const initialized in the class definition, PR gdb/11702. if { $non_dwarf } { setup_xfail *-*-* } |