Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Andrew Burgess <aburgess@broadcom.com>
Cc: gdb-patches@sourceware.org
Subject: [PATCH] Print entirely unavailable struct/union values as a single <unavailable>. (Re: [PATCH 06/12] Delete value_bits_valid.)
Date: Mon, 25 Nov 2013 21:41:00 -0000	[thread overview]
Message-ID: <52939BD4.4090803@redhat.com> (raw)
In-Reply-To: <5208D495.9080806@broadcom.com>

On 08/12/2013 01:27 PM, Andrew Burgess wrote:
> There are a few updates required to the expected results of the
> gdb.trace/unavailable.exp test, the output is now more like the output
> you would get if the values were optimized out.  I personally think this
> is a good thing, but if most people disagree then we could change the
> output for optimized out to be unavailable like, I do think the style of
> output should match.  The reason I prefer this style is that a fully
> unavailable structure is displayed with a single "<unavailable>" rather
> than the full structure with lots of unavailables throughout.

I'd like to get this part out of the way; I don't have a problem with
it.

We don't really need the whole series for this though.  Any
objections?

-------
Print entirely unavailable struct/union values as a single <unavailable>.

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 new check is added to value_check_printable, where we already do
the equivalent check for entirely optimized out values.

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

Tested on x86_64 Fedora 17, native gdbserver.

gdb/
2013-11-25  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-25  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/testsuite/gdb.trace/unavailable.exp |   41 ++++++++++++++-----------------
 gdb/valprint.c                          |    9 +++++++
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index ed14798..40319d5 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -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" \
diff --git a/gdb/valprint.c b/gdb/valprint.c
index ecc3411..0124934 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -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>"),


  reply	other threads:[~2013-11-25 18:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-12 12:15 [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-08-12 12:16 ` [PATCH 01/12] Introduce is_unavailable_error Andrew Burgess
2013-08-12 12:18 ` [PATCH 02/12]: Remove set_value_optimized_out Andrew Burgess
2013-08-12 12:20 ` [PATCH 03/12] Mark optimized out values as non-lazy Andrew Burgess
2013-11-26 16:38   ` Pedro Alves
2013-11-26 19:19     ` Andrew Burgess
2013-08-12 12:22 ` [PATCH 04/12] Introduce OPTIMIZED_OUT_ERROR Andrew Burgess
2013-08-12 12:24 ` [PATCH 05/12] Convert the unavailable to be bit based Andrew Burgess
2013-08-12 12:27 ` [PATCH 06/12] Delete value_bits_valid Andrew Burgess
2013-11-25 21:41   ` Pedro Alves [this message]
2013-11-26 10:13     ` [PATCH] Print entirely unavailable struct/union values as a single <unavailable>. (Re: [PATCH 06/12] Delete value_bits_valid.) Andrew Burgess
2013-11-28 20:14       ` Pedro Alves
2013-08-12 12:28 ` [PATCH 07/12] Generic print unavailable or optimized out function Andrew Burgess
2013-08-12 12:29 ` [PATCH 08/12] Replace some value_optimized_out with value_entirely_available Andrew Burgess
2013-11-27 17:52   ` [COMMITTED PATCH 0/2] "set debug frame 1" and not saved registers (was: Re: [PATCH 08/12] Replace some value_optimized_out with value_entirely_available) Pedro Alves
2013-11-27 18:14     ` [PATCH 1/2] Make "set debug frame 1" use the standard print routine for optimized out values Pedro Alves
2013-11-27 18:35     ` [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out> Pedro Alves
2013-11-27 18:41       ` Pedro Alves
2013-11-27 18:53         ` [pushed] Fix type of not saved registers. (was: Re: [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out>.) Pedro Alves
2013-08-12 12:30 ` [PATCH 09/12] DWARF value, mark unavailable in bits not bytes Andrew Burgess
2013-08-12 12:31 ` [PATCH 10/12] Merge optimized_out into unavailable vector Andrew Burgess
2013-08-12 12:32 ` [PATCH 11/12] Add test mechanism for value " Andrew Burgess
2013-08-12 12:33 ` [PATCH 12/12] Remove old lval check valid functions Andrew Burgess
2013-08-29 17:21 ` PING: Re: [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-11-12  9:37   ` Andrew Burgess
2013-11-29 22:31 ` Pedro Alves
2013-12-04 14:54   ` Andrew Burgess

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=52939BD4.4090803@redhat.com \
    --to=palves@redhat.com \
    --cc=aburgess@broadcom.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