From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30985 invoked by alias); 25 Nov 2013 18:52:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30973 invoked by uid 89); 25 Nov 2013 18:52:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_20,RDNS_NONE,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Nov 2013 18:50:06 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAPInwib008330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Nov 2013 13:49:58 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAPInuwg014950; Mon, 25 Nov 2013 13:49:57 -0500 Message-ID: <52939BD4.4090803@redhat.com> Date: Mon, 25 Nov 2013 21:41:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Andrew Burgess CC: gdb-patches@sourceware.org Subject: [PATCH] Print entirely unavailable struct/union values as a single . (Re: [PATCH 06/12] Delete value_bits_valid.) References: <5208D1DF.1090201@broadcom.com> <5208D495.9080806@broadcom.com> In-Reply-To: <5208D495.9080806@broadcom.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-11/txt/msg00793.txt.bz2 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 "" 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 . When printing an entirely optimized out structure/class/union, we print a single instead of printing for each field. This patch makes an entirely unavailable structure/class/union be likewise displayed with a single "" rather than the whole object with all fields . 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 Pedro Alves * valprint.c (value_check_printable): If the value is entirely unavailable, print a single "" instead of printing all subfields. gdb/testsuite/ 2013-11-25 Andrew Burgess * 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 = , memberi = , memberf = , memberd = \}" + gdb_test "print argstruct" " = " gdb_test "print argstruct.memberc" " = " gdb_test "print argstruct.memberi" " = " gdb_test "print argstruct.memberf" " = " gdb_test "print argstruct.memberd" " = " - gdb_test "print argarray" " = \\(int \\*\\) " + gdb_test "print argarray" " = " 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 = ${cr}" set r "${r}argf = ${cr}" set r "${r}argd = ${cr}" - set r "${r}argstruct = {memberc = , memberi = , memberf = , memberd = }${cr}" + set r "${r}argstruct = ${cr}" set r "${r}argarray = ${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 = ${cr}" set r "${r}locd = ${cr}" - set r "${r}locst = {memberc = , memberi = , memberf = , memberd = }${cr}" - set r "${r}locar = {, , , }${cr}" + set r "${r}locst = ${cr}" + set r "${r}locar = ${cr}" set r "${r}i = ${cr}" if { $func == "local_test_func" } { - set r "${r}locdefst = {}${cr}" + set r "${r}locdefst = ${cr}" } set r "${r}locc = ${cr}" set r "${r}loci = ${cr}" @@ -398,8 +397,7 @@ proc gdb_collect_globals_test { } { gdb_test "print globalstruct.memberf" " = " gdb_test "print globalstruct.memberd" " = " - gdb_test "print globalstruct" \ - " = {memberc = , memberi = , memberf = , memberd = }" + gdb_test "print globalstruct" " = " 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 = , b = , array = { }, ptr = , bitfield = }" + gdb_test "print struct_b.static_struct_a" " = " # Bitfields @@ -468,8 +465,7 @@ proc gdb_collect_globals_test { } { "\\$\[0-9\]+ = $cr" \ "referenced integer was not collected (taking address of reference)" - gdb_test "print *g_structref_p" \ - " = {d = , ref = }" + gdb_test "print *g_structref_p" " = " # Strings @@ -483,7 +479,7 @@ proc gdb_collect_globals_test { } { "printing constant string through collected pointer" gdb_test "print g_string_unavail" \ - " = \{ \}" \ + " = " \ "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 = \\}" + gdb_test "print g_smallstruct" " = " gdb_test "print \$.member" " = " # Cast to baseclass, checking the unavailable-ness is propagated. - gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = \\}" + gdb_test "print (small_struct) g_smallstruct_b" " = " # Same cast, but starting from a non-lazy, value. - gdb_test "print g_smallstruct_b" " = \\{ = \\{member = \\}, \\}" - gdb_test "print (small_struct) \$" " = \\{member = \\}" + gdb_test "print g_smallstruct_b" " = " + gdb_test "print (small_struct) \$" " = " 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 \\*\\) " + gdb_test "print virtualp" " = " # no vtable pointer available - gdb_test "print derived_unavail" \ - " = { = , _vptr.Derived = , z = }" + gdb_test "print derived_unavail" " = " # 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 \\*\\) " + gdb_test "print virtualp" " = " # no vtable pointer available gdb_test "print derived_unavail" \ - " = { = , _vptr.Derived = , z = }" + " = " # 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, _(""),