From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61001 invoked by alias); 15 Apr 2016 22:32:50 -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 60988 invoked by uid 89); 15 Apr 2016 22:32:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:1460751 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 15 Apr 2016 22:32:48 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3528D7F08B; Fri, 15 Apr 2016 22:32:47 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3FMWina003438; Fri, 15 Apr 2016 18:32:45 -0400 Subject: Re: [PING 2][PATCH v3] Fix gdb crash when trying to print the address of a synthetic C++ reference To: Martin Galvan , gdb-patches@sourceware.org, jan.kratochvil@redhat.com, lgustavo@codesourcery.com, daniel.gutson@tallertechnologies.com References: <1460751838-20954-1-git-send-email-martin.galvan@tallertechnologies.com> From: Pedro Alves Message-ID: <57116C0C.4090502@redhat.com> Date: Fri, 15 Apr 2016 22:32:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1460751838-20954-1-git-send-email-martin.galvan@tallertechnologies.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-04/txt/msg00369.txt.bz2 On 04/15/2016 09:23 PM, Martin Galvan wrote: > diff --git a/gdb/valops.c b/gdb/valops.c > index 5a244a9..40559c2 100644 > --- a/gdb/valops.c > +++ b/gdb/valops.c > @@ -1463,11 +1463,19 @@ value_addr (struct value *arg1) > if (TYPE_CODE (type) == TYPE_CODE_REF) > { > /* Copy the value, but change the type from (T&) to (T*). We > - keep the same location information, which is efficient, and > - allows &(&X) to get the location containing the reference. */ > + keep the same location information, which is efficient, and > + allows &(&X) to get the location containing the reference. > + Do the same to its enclosing type for consistency. */ > + struct type *type_ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type)); > + Spurious empty line. > + struct type *enclosing_type = check_typedef (value_enclosing_type (arg1)); > + struct type *enclosing_type_ptr = > + lookup_pointer_type (TYPE_TARGET_TYPE (enclosing_type)); = goes on the next line. OK with those fixed. I'd write it like this, with the variables reordered to align the lookup_pointer_type calls: struct type *enclosing_type = check_typedef (value_enclosing_type (arg1)); struct type *type_ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type)); struct type *enclosing_type_ptr = lookup_pointer_type (TYPE_TARGET_TYPE (enclosing_type)); Thanks for fixing this, and also for writing a test with the DWARF assembler. Thanks, Pedro Alves