From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7694 invoked by alias); 24 Apr 2007 18:03:16 -0000 Received: (qmail 7681 invoked by uid 22791); 24 Apr 2007 18:03:15 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 24 Apr 2007 19:03:13 +0100 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.1/8.13.1) with ESMTP id l3OI3B0h013844 for ; Tue, 24 Apr 2007 14:03:11 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l3OI3BE9008673 for ; Tue, 24 Apr 2007 14:03:11 -0400 Received: from ironwood.lan (vpn-14-113.rdu.redhat.com [10.11.14.113]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l3OI3A8E026929 for ; Tue, 24 Apr 2007 14:03:10 -0400 Date: Tue, 24 Apr 2007 18:13:00 -0000 From: Kevin Buettner To: gdb-patches@sources.redhat.com Subject: Re: [RFC] dwarf2_read_address(): sign extend as appropriate Message-ID: <20070424110309.58b32205@ironwood.lan> In-Reply-To: References: <20070420163312.56701614@ironwood.lan> <200704231505.l3NF5KV5025451@d12av02.megacenter.de.ibm.com> <20070423094900.15a047d2@ironwood.lan> <20070423165646.GA15110@caradoc.them.org> X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.10.4; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 X-SW-Source: 2007-04/txt/msg00319.txt.bz2 On Tue, 24 Apr 2007 00:43:05 +0200 Andreas Schwab wrote: > Daniel Jacobowitz writes: > > > On Mon, Apr 23, 2007 at 09:49:00AM -0700, Kevin Buettner wrote: > >> We can't use address_from_register() in this instance since > >> dwarf2_read_address() is not fetching an address from a register, but > >> rather from some DWARF2 info. > > > > How about value_as_address? > > How about extract_typed_address? I really liked this suggestion when I first saw it because it appears that it would do the right thing on MIPS and we would avoid creating a value which we'd immediately take apart again. However, after further study, I see two issues with using this function: 1) extract_typed_address() does its conversion using POINTER_TO_ADDRESS. For most architectures, this isn't an issue, but I'm not convinced that it will work correctly for those which define non-trivial pointer-to-address methods. 2) dwarf2_read_address is currently extracting an address which is TARGET_ADDR_BIT bits wide. extract_typed_address() must be invoked on a pointer (TYPE_CODE_PTR) or reference (TYPE_CODE_REF) type. If it gets anything else, it generates an internal error. If the pointer type passed to extract_typed_address() is created via make_pointer_type(), the type width will be TARGET_PTR_BIT rather than TARGET_ADDR_BIT. Thus, I'd expect extract_typed_address() to work as expected on architectures for which TARGET_ADDR_BIT is the same as TARGET_PTR_BIT, but not otherwise - unless some sort of special TARGET_ADDR_BIT width pointer were created for just this purpose - but that smells like a hack to me. Given these problems, I don't think that the use of extract_typed_address() is suitable for this situation. That leaves the value_as_address() suggestion. I don't like that suggestion, but my only objection is that it is inefficient. (As far as I can tell, it would work correctly.) It seems wasteful (in both time and space) to create a (struct value *) with the express purpose of immediately decomposing it, never to be used again. Kevin