From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15633 invoked by alias); 20 Nov 2013 07:54:51 -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 15600 invoked by uid 89); 20 Nov 2013 07:54:49 -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_50,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mga03.intel.com Received: from Unknown (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Nov 2013 07:54:47 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga101.ch.intel.com with ESMTP; 19 Nov 2013 23:54:39 -0800 X-ExtLoop1: 1 Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga001.fm.intel.com with ESMTP; 19 Nov 2013 23:54:38 -0800 Received: from irsmsx152.ger.corp.intel.com (163.33.192.66) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 20 Nov 2013 07:54:37 +0000 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.215]) by IRSMSX152.ger.corp.intel.com ([169.254.6.169]) with mapi id 14.03.0123.003; Wed, 20 Nov 2013 07:54:37 +0000 From: "Agovic, Sanimir" To: 'Tom Tromey' CC: "gdb-patches@sourceware.org" Subject: RE: [PATCH 06/10] vla: update type from newly created value Date: Wed, 20 Nov 2013 07:56:00 -0000 Message-ID: <0377C58828D86C4588AEEC42FC3B85A7176B7EEA@IRSMSX105.ger.corp.intel.com> References: <1382366424-21010-1-git-send-email-sanimir.agovic@intel.com> <1382366424-21010-7-git-send-email-sanimir.agovic@intel.com> <87wqkkt03g.fsf@fleche.redhat.com> In-Reply-To: <87wqkkt03g.fsf@fleche.redhat.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00586.txt.bz2 > -----Original Message----- > From: Tom Tromey [mailto:tromey@redhat.com] > Sent: Thursday, November 07, 2013 09:43 PM > To: Agovic, Sanimir > Cc: gdb-patches@sourceware.org > Subject: Re: [PATCH 06/10] vla: update type from newly created value >=20 > >>>>> "Sanimir" =3D=3D Sanimir Agovic writes: >=20 > Sanimir> Constructing a value based on a type and address might change > Sanimir> the type of the newly constructed value. Thus re-fetch type via > Sanimir> value_type to ensure we have the correct type at hand. >=20 > Sanimir> 2013-10-18 Sanimir Agovic > Sanimir> Keven Boell >=20 > Sanimir> * valops.c (value_ind): Re-fetch type from value. > Sanimir> * value.c (coerce_ref): Re-fetch type from value. >=20 > This is fine by itself; however, I wonder whether there are other calls > that require fixing. Did you check through the rest of the code? >=20 My approach to find similar occurrences: 1) Grep sources for value_at / value_at_lazy / value_from_contents_and_addr= ess 2) Follow control flow within a function, if the type passed to the above constructors is used after constructing a value I re-fetched the type. Running the testsuite before/after this patch series showed no regressions. I used Jans diffgdb. gjc, gcc/++, pascal, and ada was used on Fedora20.=20 I run into some ada fails with and without c99 patches. Not sure if this is known or expected: FAIL: gdb.ada/interface.exp: print s FAIL: gdb.ada/iwide.exp: print My_Drawable FAIL: gdb.ada/iwide.exp: print s_access.all FAIL: gdb.ada/iwide.exp: print sp_access.all FAIL: gdb.ada/iwide.exp: print d_access.all FAIL: gdb.ada/iwide.exp: print dp_access.all FAIL: gdb.ada/ptype_tagged_param.exp: ptype s FAIL: gdb.ada/tagged.exp: ptype obj FAIL: gdb.ada/tagged.exp: print obj Below you will find all hits. Let me know if it is OK. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9ff3ab9..26d0c24 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2299,6 +2299,7 @@ ada_value_primitive_packed_val (struct value *obj, co= nst gdb_byte *valaddr, else if (VALUE_LVAL (obj) =3D=3D lval_memory && value_lazy (obj)) { v =3D value_at (type, value_address (obj)); + type =3D value_type (v); bytes =3D (unsigned char *) alloca (len); read_memory (value_address (v) + offset, bytes, len); } @@ -7656,6 +7657,7 @@ ada_template_to_fixed_record_type_1 (struct type *typ= e, size first before creating the value. */ check_size (rtype); dval =3D value_from_contents_and_address (rtype, valaddr, add= ress); + rtype =3D value_type (dval); } else dval =3D dval0; @@ -7758,7 +7760,10 @@ ada_template_to_fixed_record_type_1 (struct type *ty= pe, off =3D TYPE_FIELD_BITPOS (rtype, variant_field); if (dval0 =3D=3D NULL) - dval =3D value_from_contents_and_address (rtype, valaddr, address); + { + dval =3D value_from_contents_and_address (rtype, valaddr, address= ); + rtype =3D value_type (dval); + } else dval =3D dval0; @@ -7899,7 +7904,10 @@ to_record_with_fixed_variant_part (struct type *type= , const gdb_byte *valaddr, return type; if (dval0 =3D=3D NULL) - dval =3D value_from_contents_and_address (type, valaddr, address); + { + dval =3D value_from_contents_and_address (type, valaddr, address); + type =3D value_type (dval); + } else dval =3D dval0; @@ -8197,6 +8205,8 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byt= e *valaddr, value_from_contents_and_address (fixed_record_type, valaddr, address); + + fixed_record_type =3D value_type (obj); if (real_type !=3D NULL) return to_fixed_record_type (real_type, NULL, diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 1d7147c..72c8d41 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -446,6 +446,7 @@ cp_print_value_fields_rtti (struct type *type, /* Ugh, we have to convert back to a value here. */ value =3D value_from_contents_and_address (type, valaddr + offset, address + offset); + type =3D value_type (value); /* We don't actually care about most of the result here -- just the type. We already have the correct offset, due to how val_print was initially called. */ @@ -548,6 +549,7 @@ cp_print_value (struct type *type, struct type *real_ty= pe, base_val =3D value_from_contents_and_address (baseclass, buf, address + bof= fset); + baseclass =3D value_type (base_val); thisoffset =3D 0; boffset =3D 0; thistype =3D baseclass; diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 6e9c28d..cca629a 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -59,6 +59,7 @@ dynamic_array_type (struct type *type, const gdb_byte *va= laddr, true_type =3D lookup_array_range_type (true_type, 0, length - 1); ival =3D value_at (true_type, addr); + true_type =3D value_type (ival); d_val_print (true_type, value_contents_for_printing (ival), diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index cb89a85..27901a3 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -65,6 +65,7 @@ java_value_print (struct value *val, struct ui_file *stre= am, type =3D lookup_pointer_type (type); val =3D value_at (type, address); + type =3D value_type (val); } } diff --git a/gdb/valops.c b/gdb/valops.c index 6706d9f..b539610 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -268,6 +268,7 @@ value_cast_structs (struct type *type, struct value *v2) { v =3D value_full_object (v2, real_type, full, top, using_enc); v =3D value_at_lazy (real_type, value_address (v)); + real_type =3D value_type (v); /* We might be trying to cast to the outermost enclosing type, in which case search_struct_field won't work. */ @@ -803,6 +804,7 @@ value_dynamic_cast (struct type *type, struct value *ar= g) return value_at_lazy (type, addr); tem =3D value_at (type, addr); + type =3D value_type (tem); /* The first dynamic check specified in 5.2.7. */ if (is_public_ancestor (arg_type, TYPE_TARGET_TYPE (resolved_type))) -Sanimir Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052