From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9426 invoked by alias); 25 Oct 2013 10:04:33 -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 9413 invoked by uid 89); 25 Oct 2013 10:04:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,MIME_BASE64_BLANKS,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: kiruna.synopsys.com Received: from kiruna.synopsys.com (HELO kiruna.synopsys.com) (198.182.44.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Oct 2013 10:04:32 +0000 Received: from WBSNus02mta1 (us02secmta1.synopsys.com [10.12.235.96]) by kiruna.synopsys.com (Postfix) with ESMTP id C924BF2B9; Fri, 25 Oct 2013 03:04:30 -0700 (PDT) Received: from us02secmta1.internal.synopsys.com (us02secmta1.internal.synopsys.com [127.0.0.1]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id B6F884E214; Fri, 25 Oct 2013 03:04:30 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id 9A51B4E202; Fri, 25 Oct 2013 03:04:30 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 8FB48633; Fri, 25 Oct 2013 03:04:30 -0700 (PDT) Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 88F41632; Fri, 25 Oct 2013 03:04:30 -0700 (PDT) Received: from DE02WEHTCB.internal.synopsys.com (10.225.19.94) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.2.298.4; Fri, 25 Oct 2013 03:04:30 -0700 Received: from DE02WEMBXA.internal.synopsys.com ([fe80::a014:7216:77d:d55c]) by DE02WEHTCB.internal.synopsys.com ([::1]) with mapi id 14.02.0298.004; Fri, 25 Oct 2013 12:04:28 +0200 From: Anton Kolesov To: "gdb-patches@sourceware.org" CC: "Jeremy.bennett@embecosm.com" Subject: RE: [PATCH] testsuite: Fix gdb.base/bang.exp for remote stubs without exit Date: Fri, 25 Oct 2013 10:04:00 -0000 Message-ID: <39A54937CC95F24AA2F794E2D2B66B1356BDC197@de02wembxa.internal.synopsys.com> References: <1381309094-24410-1-git-send-email-Anton.Kolesov@synopsys.com> <52553DEE.5090009@redhat.com> In-Reply-To: <52553DEE.5090009@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg00792.txt.bz2 PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBQZWRybyBB bHZlcyBbbWFpbHRvOnBhbHZlc0ByZWRoYXQuY29tXQ0KPiBTZW50OiAwOSBP Y3RvYmVyIDIwMTMgMTU6MjkNCj4gVG86IEFudG9uIEtvbGVzb3YNCj4gQ2M6 IGdkYi1wYXRjaGVzQHNvdXJjZXdhcmUub3JnOyBKZXJlbXkuYmVubmV0dEBl bWJlY29zbS5jb20NCj4gU3ViamVjdDogUmU6IFtQQVRDSF0gdGVzdHN1aXRl OiBGaXggZ2RiLmJhc2UvYmFuZy5leHAgZm9yIHJlbW90ZSBzdHVicw0KPiB3 aXRob3V0IGV4aXQNCj4gDQo+IE9uIDEwLzA5LzIwMTMgMDk6NTggQU0sIEFu dG9uIEtvbGVzb3Ygd3JvdGU6DQo+IA0KPiA+IDIwMTMtMTAtMDggIEFudG9u IEtvbGVzb3YgPEFudG9uLktvbGVzb3ZAc3lub3BzeXMuY29tPg0KPiA+DQo+ ID4gCSogZ2RiLmJhc2UvYmFuZy5leHA6IFVzZSBnZGJfY29udGludWVfdG9f ZW5kIHRvIHByb3Blcmx5DQo+IHN1cHBvcnQNCj4gPiAJcmVtb3RlIHN0dWJz IHdoZXJlIGV4aXQoKSBiZWhhdmlvdXIgaXMgdW5yZWxpYWJsZS4NCj4gDQo+ IE9LLCB0aGFua3MuDQoNCkkgZG9uJ3QgaGF2ZSBhIHdyaXRlIGFjY2VzcyB0 byBHREIgcmVwb3NpdG9yeS4gQW5kIEkgZG9uJ3QgdGhpbmsgSSBoYXZlIGEg cmVxdWlyZWQgYXBwcm92YWwuIENhbiBzb21lb25lIHBsZWFzZSBzdWJtaXQg dGhpcyBwYXRjaCwgc2luY2UgaXQgaGFzIGFscmVhZHkgYmVlbiBhcHByb3Zl ZD8gDQoNCkFudG9uIEtvbGVzb3YNCg0KDQo+IA0KPiAtLQ0KPiBQZWRybyBB bHZlcw0K >From gdb-patches-return-106680-listarch-gdb-patches=sources.redhat.com@sourceware.org Fri Oct 25 10:44:10 2013 Return-Path: Delivered-To: listarch-gdb-patches@sources.redhat.com Received: (qmail 11527 invoked by alias); 25 Oct 2013 10:44:09 -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 Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11513 invoked by uid 89); 25 Oct 2013 10:44:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Oct 2013 10:44:08 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9PAi6RT018789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 Oct 2013 06:44:06 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9PAi4Uf006660; Fri, 25 Oct 2013 06:44:05 -0400 Message-ID: <526A4B73.5040304@redhat.com> Date: Fri, 25 Oct 2013 10:44: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: Doug Evans CC: gdb-patches@sourceware.org Subject: Re: [PATCH] Print nonexisting/optimized out static fields gracefully. References: <1381429510-14825-1-git-send-email-palves@redhat.com> <21085.54173.143927.913006@ruffy.mtv.corp.google.com> In-Reply-To: <21085.54173.143927.913006@ruffy.mtv.corp.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-10/txt/msg00793.txt.bz2 Content-length: 10085 On 10/16/2013 12:45 AM, Doug Evans wrote: > Pedro Alves writes: > > gdb/ > > 2013-10-10 Pedro Alves > > > > * 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 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 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 > > > > * 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] Pushed with that commit log typo fixed. --------- Subject: [PATCH] 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 = } (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 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 . After the patch: (gdb) p sss $1 = {static aaa = } (gdb) p sss.aaa $2 = 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 for each). Tested on x86_64 Fedora 17. gdb/ 2013-10-25 Pedro Alves * 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 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 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 * gdb.cp/m-static.exp: Adjust expected output of printing a nonexistent or optimized out static field. Also test printing the the "container" object. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/cp-valprint.c | 17 ++++++++++------- gdb/jv-valprint.c | 22 ++++++++-------------- gdb/p-valprint.c | 6 ++++++ gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.cp/m-static.exp | 5 ++++- gdb/valops.c | 11 +---------- gdb/value.c | 5 ++--- 8 files changed, 53 insertions(+), 35 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ec491c5..88b8340 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2013-10-25 Pedro Alves + + * 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 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 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. + 2013-10-25 Yao Qi * remote.c (remote_traceframe_info): Return early if diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 1d7147c..4b625d1 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -333,12 +333,9 @@ cp_print_value_fields (struct type *type, struct type *real_type, fprintf_filtered (stream, _(""), ex.message); - else if (v == NULL) - val_print_optimized_out (NULL, stream); - else - cp_print_static_field (TYPE_FIELD_TYPE (type, i), - v, stream, recurse + 1, - options); + cp_print_static_field (TYPE_FIELD_TYPE (type, i), + v, stream, recurse + 1, + options); } else if (i == vptr_fieldno && type == vptr_basetype) { @@ -640,7 +637,13 @@ cp_print_static_field (struct type *type, const struct value_print_options *options) { struct value_print_options opts; - + + if (value_entirely_optimized_out (val)) + { + val_print_optimized_out (val, stream); + return; + } + if (TYPE_CODE (type) == TYPE_CODE_STRUCT) { CORE_ADDR *first_dont_print; diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index cb89a85..2c60cc0 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -417,22 +417,16 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, } else if (field_is_static (&TYPE_FIELD (type, i))) { + struct value_print_options opts; struct value *v = value_static_field (type, i); + struct type *t = check_typedef (value_type (v)); - if (v == NULL) - val_print_optimized_out (NULL, stream); - else - { - struct value_print_options opts; - struct type *t = check_typedef (value_type (v)); - - if (TYPE_CODE (t) == TYPE_CODE_STRUCT) - v = value_addr (v); - opts = *options; - opts.deref_ref = 0; - common_val_print (v, stream, recurse + 1, - &opts, current_language); - } + if (TYPE_CODE (t) == TYPE_CODE_STRUCT) + v = value_addr (v); + opts = *options; + opts.deref_ref = 0; + common_val_print (v, stream, recurse + 1, + &opts, current_language); } else if (TYPE_FIELD_TYPE (type, i) == NULL) fputs_filtered ("", stream); diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index e6d4b91..7854bc0 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -844,6 +844,12 @@ pascal_object_print_static_field (struct value *val, struct type *type = value_type (val); struct value_print_options opts; + if (value_entirely_optimized_out (val)) + { + val_print_optimized_out (val, stream); + return; + } + if (TYPE_CODE (type) == TYPE_CODE_STRUCT) { CORE_ADDR *first_dont_print, addr; 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 + + * 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 * 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" "" "static const int initialized nowhere (print field)" + +# Same, but print the whole struct. +gdb_test "print test4" "static nowhere = .*" "static const int initialized nowhere (whole struct)" # static const initialized in the class definition, PR gdb/11702. if { $non_dwarf } { setup_xfail *-*-* } diff --git a/gdb/valops.c b/gdb/valops.c index 15fd7c3..8bff686 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1853,13 +1853,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset, struct value *v; if (field_is_static (&TYPE_FIELD (type, i))) - { - v = value_static_field (type, i); - if (v == 0) - error (_("field %s is nonexistent or " - "has been optimized out"), - name); - } + v = value_static_field (type, i); else v = value_primitive_field (arg1, offset, i, type); *result_ptr = v; @@ -3123,9 +3117,6 @@ value_struct_elt_for_reference (struct type *domain, int offset, if (field_is_static (&TYPE_FIELD (t, i))) { v = value_static_field (t, i); - if (v == NULL) - error (_("static field %s has been optimized out"), - name); if (want_address) v = value_addr (v); return v; diff --git a/gdb/value.c b/gdb/value.c index d96d285..1f562f5 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2590,8 +2590,7 @@ unpack_pointer (struct type *type, const gdb_byte *valaddr) /* Get the value of the FIELDNO'th field (which must be static) of - TYPE. Return NULL if the field doesn't exist or has been - optimized out. */ + TYPE. */ struct value * value_static_field (struct type *type, int fieldno) @@ -2618,7 +2617,7 @@ value_static_field (struct type *type, int fieldno) NULL, NULL); if (!msym) - return NULL; + return allocate_optimized_out_value (type); else { retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), -- 1.7.11.7