From patchwork Thu Apr 10 12:40:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Agovic, Sanimir" X-Patchwork-Id: 478 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id E5E4736005B for ; Thu, 10 Apr 2014 05:46:50 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id A46854862753; Thu, 10 Apr 2014 05:46:50 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 817B94862767 for ; Thu, 10 Apr 2014 05:46:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=n7P1pHJRBGUWJUJdkdZ9dJzsdAH9cpU wW/pzdtex3GXHB6Wrbe7Ga9D2y+vGjJxxGQ7Sz73GUsN+p1/kCuM3Gz7eVUeYqR6 Wj0VHxB2c46Ro29vc2Ue1ZKAUO/KBypdTiTS4gWZIFIwE65q+4L2SPKcvj8NQlSG oGViMvrdmbY0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=xokBfM7OZBsBNu3+AVMOxvtv4gM=; b=p8VWo x8gvJeNlGIHk1l89sb4rsW6HytTlIy1Pq15vCe9BNlQLF1fQSrC+uZL6On83zaVU 3oIF1RXebAYC9ZPEDhAtO+jYi7wveiEuyL69njNPisffb/OpdrqbOMXkEpcDHFM6 zerJLoP8Wv0r6I0/+rM7lh7hLbTlLuOZZR9oEk= Received: (qmail 28918 invoked by alias); 10 Apr 2014 12:46:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28908 invoked by uid 89); 10 Apr 2014 12:46:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Apr 2014 12:46:47 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 10 Apr 2014 05:41:39 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 10 Apr 2014 05:46:23 -0700 Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [172.28.50.125]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s3ACjs7l010048; Thu, 10 Apr 2014 13:45:59 +0100 Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [127.0.0.1]) by ulliclel004.iul.intel.com (8.13.8/8.12.8/MailSET/client) with ESMTP id s3ACis66026756; Thu, 10 Apr 2014 14:45:14 +0200 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id s3ACimpa026755; Thu, 10 Apr 2014 14:44:48 +0200 From: Sanimir Agovic To: brobecker@adacore.com Cc: gdb-patches@sourceware.org, tromey@redhat.com Subject: [PATCH v6 06/15] vla: update type from newly created value Date: Thu, 10 Apr 2014 14:40:08 +0200 Message-Id: <1397133617-26681-7-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> References: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Constructing a value based on a type and address might change the type of the newly constructed value. Thus re-fetch type via value_type to ensure we have the correct type at hand. 2013-10-18 Sanimir Agovic Keven Boell * ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value. (ada_template_to_fixed_record_type_1): Likewise. (ada_to_fixed_type_1): Likewise. * cp-valprint.c (cp_print_value_fields_rtti): Likewise. (cp_print_value): Likewise. * d-valprint.c (dynamic_array_type): Likewise. * eval.c (evaluate_subexp_with_coercion): Likewise. * findvar.c (address_of_variable): Likewise. * jv-valprint.c (java_value_print): Likewise. * valops.c (value_ind): Likewise. * value.c (coerce_ref): Likewise. Signed-off-by: Sanimir Agovic --- gdb/ada-lang.c | 13 +++++++++++-- gdb/cp-valprint.c | 2 ++ gdb/d-valprint.c | 1 + gdb/eval.c | 1 + gdb/jv-valprint.c | 1 + gdb/valops.c | 4 ++++ gdb/value.c | 1 + 7 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d08e116..caf52f2 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2300,6 +2300,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj)) { v = value_at (type, value_address (obj)); + type = value_type (v); bytes = (unsigned char *) alloca (len); read_memory (value_address (v) + offset, bytes, len); } @@ -7658,6 +7659,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, size first before creating the value. */ check_size (rtype); dval = value_from_contents_and_address (rtype, valaddr, address); + rtype = value_type (dval); } else dval = dval0; @@ -7760,7 +7762,10 @@ ada_template_to_fixed_record_type_1 (struct type *type, off = TYPE_FIELD_BITPOS (rtype, variant_field); if (dval0 == NULL) - dval = value_from_contents_and_address (rtype, valaddr, address); + { + dval = value_from_contents_and_address (rtype, valaddr, address); + rtype = value_type (dval); + } else dval = dval0; @@ -7901,7 +7906,10 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, return type; if (dval0 == NULL) - dval = value_from_contents_and_address (type, valaddr, address); + { + dval = value_from_contents_and_address (type, valaddr, address); + type = value_type (dval); + } else dval = dval0; @@ -8199,6 +8207,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, value_from_contents_and_address (fixed_record_type, valaddr, address); + fixed_record_type = value_type (obj); if (real_type != NULL) return to_fixed_record_type (real_type, NULL, diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index bcf54ff..b868d37 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -443,6 +443,7 @@ cp_print_value_fields_rtti (struct type *type, /* Ugh, we have to convert back to a value here. */ value = value_from_contents_and_address (type, valaddr + offset, address + offset); + type = 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. */ @@ -545,6 +546,7 @@ cp_print_value (struct type *type, struct type *real_type, base_val = value_from_contents_and_address (baseclass, buf, address + boffset); + baseclass = value_type (base_val); thisoffset = 0; boffset = 0; thistype = 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 *valaddr, true_type = lookup_array_range_type (true_type, 0, length - 1); ival = value_at (true_type, addr); + true_type = value_type (ival); d_val_print (true_type, value_contents_for_printing (ival), diff --git a/gdb/eval.c b/gdb/eval.c index b3e45ca..85cf071 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2985,6 +2985,7 @@ evaluate_subexp_with_coercion (struct expression *exp, { (*pos) += 4; val = address_of_variable (var, exp->elts[pc + 1].block); + type = value_type (val); return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val); } diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index f465ca0..808e01b 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -65,6 +65,7 @@ java_value_print (struct value *val, struct ui_file *stream, type = lookup_pointer_type (type); val = value_at (type, address); + type = value_type (val); } } diff --git a/gdb/valops.c b/gdb/valops.c index eefa8c6..4b81a7a 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -268,6 +268,7 @@ value_cast_structs (struct type *type, struct value *v2) { v = value_full_object (v2, real_type, full, top, using_enc); v = value_at_lazy (real_type, value_address (v)); + real_type = 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 *arg) return value_at_lazy (type, addr); tem = value_at (type, addr); + type = value_type (tem); /* The first dynamic check specified in 5.2.7. */ if (is_public_ancestor (arg_type, TYPE_TARGET_TYPE (resolved_type))) @@ -1372,6 +1374,7 @@ address_of_variable (struct symbol *var, const struct block *b) Lazy evaluation pays off here. */ val = value_of_variable (var, b); + type = value_type (val); if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) || TYPE_CODE (type) == TYPE_CODE_FUNC) @@ -1620,6 +1623,7 @@ value_ind (struct value *arg1) (value_as_address (arg1) - value_pointed_to_offset (arg1))); + enc_type = value_type (arg2); return readjust_indirect_value_type (arg2, enc_type, base_type, arg1); } diff --git a/gdb/value.c b/gdb/value.c index 993157f..3139a8b 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3364,6 +3364,7 @@ coerce_ref (struct value *arg) retval = value_at_lazy (enc_type, unpack_pointer (value_type (arg), value_contents (arg))); + enc_type = value_type (retval); return readjust_indirect_value_type (retval, enc_type, value_type_arg_tmp, arg); }