From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121257 invoked by alias); 26 Apr 2016 21:48:41 -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 121236 invoked by uid 89); 26 Apr 2016 21:48:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1781 X-HELO: mail-pa0-f48.google.com Received: from mail-pa0-f48.google.com (HELO mail-pa0-f48.google.com) (209.85.220.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 26 Apr 2016 21:48:27 +0000 Received: by mail-pa0-f48.google.com with SMTP id iv1so11412545pac.2 for ; Tue, 26 Apr 2016 14:48:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=HidEzkm8XGNbVzZfCMPc0jxxhoM6CCrfE6DDxz4rHxA=; b=e0ygT/g3t9YLZQSqMQ1U7Yu66dJ/C96eZewhYEgfmJ1wZdJoU1ouYPfsGFSgUFUyy2 f6DjpT3/k/28jzkgixz9cm0C+auMYeW77SAuQcRNZa2vnxDGZFKLgCE6j4P1JT877Wld orZi6H+RbogfbctTFrWdqpYpxNjq2/iKGcn7/W7NPH+VC74DCmtawz7KtuZs4ScIPfVU XsLTv43svsrHt0OLH6/U2hLUHFqOhriMGjEKISnZ+h7AjZgu1XfsHVbhKoBBXol+aJZx w6B8fduQ3EzG1HhyVGe61Gx/ENNr/fyt27CnH3ZU23NOOg1RT5VppigJ5jgx2unyRN/Z MDCA== X-Gm-Message-State: AOPr4FW5XnoJS0/D2M7mZAJs/h4x2PbL19FNwyNY2rcnrnGwjraNNF9uOOGyf0KdEXXN9QWK X-Received: by 10.66.230.195 with SMTP id ta3mr4274289pac.150.1461707305873; Tue, 26 Apr 2016 14:48:25 -0700 (PDT) Received: from martin-galvan.dominio.tallertechnologies.com ([200.69.202.173]) by smtp.gmail.com with ESMTPSA id x64sm616344pfx.95.2016.04.26.14.48.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Apr 2016 14:48:25 -0700 (PDT) From: Martin Galvan To: gdb-patches@sourceware.org, palves@redhat.com, tom@tromey.com, daniel.gutson@tallertechnologies.com Subject: [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT Date: Tue, 26 Apr 2016 21:48:00 -0000 Message-Id: <1461707298-26514-1-git-send-email-martin.galvan@tallertechnologies.com> X-SW-Source: 2016-04/txt/msg00562.txt.bz2 Currently c_value_print will turn struct reference values into pointers before doing a set of RTTI checks. This was introduced as a fix to PR c++/15401. If there's RTTI the pointer will be adjusted and converted back to a reference. However, if there's no RTTI the value will still be treated as a pointer during the remainder of the function. This patch moves the conversion down so that it's always performed when needed. I have write access and copyright assignment. Ok to commit? gdb/ChangeLog: 2016-04-26 Martin Galvan * c-valprint.c (c_value_print): Always convert val back to reference type if we converted it to a pointer type. --- gdb/c-valprint.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 62552ec..e1da3d5 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -611,7 +611,7 @@ c_value_print (struct value *val, struct ui_file *stream, fprintf_filtered (stream, "("); if (value_entirely_available (val)) - { + { real_type = value_rtti_indirect_type (val, &full, &top, &using_enc); if (real_type) @@ -623,18 +623,19 @@ c_value_print (struct value *val, struct ui_file *stream, val = value_from_pointer (real_type, value_as_address (val) - top); - if (is_ref) - { - val = value_ref (value_ind (val)); - type = value_type (val); - } - /* Note: When we look up RTTI entries, we don't get any information on const or volatile attributes. */ } } - type_print (type, "", stream, -1); + + if (is_ref) + { + val = value_ref (value_ind (val)); + type = value_type (val); + } + + type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); val_type = type; } -- 2.8.1