Print entirely unavailable struct/union values as a single <unavailable>.
authorAndrew Burgess <aburgess@broadcom.com>
Thu, 28 Nov 2013 18:54:20 +0000 (18:54 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 28 Nov 2013 18:54:20 +0000 (18:54 +0000)
When printing an entirely optimized out structure/class/union, we
print a single <optimized out> instead of printing <optimized out> for
each field.

This patch makes an entirely unavailable structure/class/union be
likewise displayed with a single "<unavailable>" rather than the whole
object with all fields <unavailable>.

This seems good because this way the user can quickly tell whether the
whole value is unavailable, rather than having to skim all fields.
Consistency with optimized out values also seems to be a good thing to
have.

A few updates to gdb.trace/unavailable.exp where required.

Tested on x86_64 Fedora 17, native gdbserver.

gdb/
2013-11-28  Andrew Burgess  <aburgess@broadcom.com>
    Pedro Alves  <palves@redhat.com>

* valprint.c (value_check_printable): If the value is entirely
unavailable, print a single "<unavailable>" instead of printing
all subfields.

gdb/testsuite/
2013-11-28  Andrew Burgess  <aburgess@broadcom.com>

* gdb.trace/unavailable.exp (gdb_collect_args_test): Update
expected results.
(gdb_collect_locals_test): Likewise.
(gdb_collect_globals_test): Likewise.

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.trace/unavailable.exp
gdb/valprint.c

index b15bee967670bae1bacb4997208bd7e5edd91fe2..41c43d48f58cd3d73b6e92c16033aeb414be31b1 100644 (file)
@@ -1,3 +1,10 @@
+2013-11-28  Andrew Burgess  <aburgess@broadcom.com>
+           Pedro Alves  <palves@redhat.com>
+
+       * valprint.c (value_check_printable): If the value is entirely
+       unavailable, print a single "<unavailable>" instead of printing
+       all subfields.
+
 2013-11-28  Pedro Alves  <palves@redhat.com>
 
        * frame.c (get_prev_frame_1) <stop_reason != UNWIND_NO_REASON>:
index 8697d639a99ec9204722fc13eea595d8b4ffa85f..601517253b5a10456cfffdd3d74cb9b10a6148c5 100644 (file)
@@ -1,3 +1,10 @@
+2013-11-28  Andrew Burgess  <aburgess@broadcom.com>
+
+       * gdb.trace/unavailable.exp (gdb_collect_args_test): Update
+       expected results.
+       (gdb_collect_locals_test): Likewise.
+       (gdb_collect_globals_test): Likewise.
+
 2013-11-28  Yao Qi  <yao@codesourcery.com>
 
        * lib/gdb.exp (with_gdb_prompt): New proc.
index ed14798ba7b6c86a4b7860989886018f6c50e523..40319d58c4b15f572b74c402e35ad070863c4d7e 100644 (file)
@@ -169,15 +169,14 @@ proc gdb_collect_args_test {} {
 
        # struct arg as one of several args (near end of list)
 
-       gdb_test "print argstruct" \
-           " = \{memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>\}"
+       gdb_test "print argstruct" " = <unavailable>"
 
        gdb_test "print argstruct.memberc" " = <unavailable>"
        gdb_test "print argstruct.memberi" " = <unavailable>"
        gdb_test "print argstruct.memberf" " = <unavailable>"
        gdb_test "print argstruct.memberd" " = <unavailable>"
 
-       gdb_test "print argarray" " = \\(int \\*\\) <unavailable>"
+       gdb_test "print argarray" " = <unavailable>"
 
        gdb_test "print &argarray" \
            "Can't take address of \"argarray\" which isn't an lvalue\."
@@ -190,7 +189,7 @@ proc gdb_collect_args_test {} {
        set r "${r}argi = <unavailable>${cr}"
        set r "${r}argf = <unavailable>${cr}"
        set r "${r}argd = <unavailable>${cr}"
-       set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}"
+       set r "${r}argstruct = <unavailable>${cr}"
        set r "${r}argarray = <unavailable>${cr}"
        gdb_test "info args" "$r" "info args"
 
@@ -237,11 +236,11 @@ proc gdb_collect_locals_test { func msg } {
        set r ""
        set r "${r}locf = <unavailable>${cr}"
        set r "${r}locd = <unavailable>${cr}"
-       set r "${r}locst = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}"
-       set r "${r}locar = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}${cr}"
+       set r "${r}locst = <unavailable>${cr}"
+       set r "${r}locar = <unavailable>${cr}"
        set r "${r}i = <unavailable>${cr}"
        if { $func == "local_test_func" } {
-           set r "${r}locdefst = {<No data fields>}${cr}"
+           set r "${r}locdefst = <unavailable>${cr}"
        }
        set r "${r}locc = <unavailable>${cr}"
        set r "${r}loci = <unavailable>${cr}"
@@ -398,8 +397,7 @@ proc gdb_collect_globals_test { } {
        gdb_test "print globalstruct.memberf" " = <unavailable>"
        gdb_test "print globalstruct.memberd" " = <unavailable>"
 
-       gdb_test "print globalstruct" \
-           " = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}"
+       gdb_test "print globalstruct" " = <unavailable>"
 
        gdb_test "print globalp == &globalstruct" \
            "value is not available" \
@@ -449,8 +447,7 @@ proc gdb_collect_globals_test { } {
 
        # Static fields
 
-       gdb_test "print struct_b.static_struct_a" \
-           " = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}"
+       gdb_test "print struct_b.static_struct_a" " = <unavailable>"
 
        # Bitfields
 
@@ -468,8 +465,7 @@ proc gdb_collect_globals_test { } {
            "\\$\[0-9\]+ = <unavailable>$cr" \
            "referenced integer was not collected (taking address of reference)"
 
-       gdb_test "print *g_structref_p" \
-           " = {d = <unavailable>, ref = <unavailable>}"
+       gdb_test "print *g_structref_p" " = <unavailable>"
 
        # Strings
 
@@ -483,7 +479,7 @@ proc gdb_collect_globals_test { } {
            "printing constant string through collected pointer"
 
        gdb_test "print g_string_unavail" \
-           " = \{<unavailable> <repeats 12 times>\}" \
+           " = <unavailable>" \
            "printing non collected string"
 
        # Incomplete strings print as an array.
@@ -521,15 +517,15 @@ proc gdb_collect_globals_test { } {
        # unavailable-ness is propagated.  History values are easy
        # non-lazy values, so use those.  The first test just sets up for
        # the second.
-       gdb_test "print g_smallstruct" " = \\{member = <unavailable>\\}"
+       gdb_test "print g_smallstruct" " = <unavailable>"
        gdb_test "print \$.member" " = <unavailable>"
 
        # Cast to baseclass, checking the unavailable-ness is propagated.
-       gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable>\\}"
+       gdb_test "print (small_struct) g_smallstruct_b" " = <unavailable>"
 
        # Same cast, but starting from a non-lazy, value.
-       gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavailable>\\}, <No data fields>\\}"
-       gdb_test "print (small_struct) \$" " = \\{member = <unavailable>\\}"
+       gdb_test "print g_smallstruct_b" " = <unavailable>"
+       gdb_test "print (small_struct) \$" " = <unavailable>"
 
        gdb_test_no_output "set print object on"
 
@@ -538,11 +534,10 @@ proc gdb_collect_globals_test { } {
            # the pointed-to object, to check its run-time type.  Make
            # sure that fails gracefully and transparently when the
            # pointer itself is unavailable.
-           gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>"
+           gdb_test "print virtualp" " = <unavailable>"
 
            # no vtable pointer available
-           gdb_test "print derived_unavail" \
-               " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}"
+           gdb_test "print derived_unavail" " = <unavailable>"
 
            # vtable pointer available, but nothing else
            gdb_test "print derived_partial" \
@@ -556,11 +551,11 @@ proc gdb_collect_globals_test { } {
        gdb_test_no_output "set print object off"
 
        with_test_prefix "print object off" {
-           gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>"
+           gdb_test "print virtualp" " = <unavailable>"
 
            # no vtable pointer available
            gdb_test "print derived_unavail" \
-               " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}"
+               " = <unavailable>"
 
            # vtable pointer available, but nothing else
            gdb_test "print derived_partial" \
index ecc3411b6e7dc6447fd8d12de391f098ac47e09a..0124934cb7a21d1eb9e74f173e1256797f6e1818 100644 (file)
@@ -812,6 +812,15 @@ value_check_printable (struct value *val, struct ui_file *stream,
       return 0;
     }
 
+  if (value_entirely_unavailable (val))
+    {
+      if (options->summary && !val_print_scalar_type_p (value_type (val)))
+       fprintf_filtered (stream, "...");
+      else
+       val_print_unavailable (stream);
+      return 0;
+    }
+
   if (TYPE_CODE (value_type (val)) == TYPE_CODE_INTERNAL_FUNCTION)
     {
       fprintf_filtered (stream, _("<internal function %s>"),