From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23793 invoked by alias); 3 May 2008 23:53:50 -0000 Received: (qmail 23783 invoked by uid 22791); 3 May 2008 23:53:50 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 03 May 2008 23:53:30 +0000 Received: (qmail 6027 invoked from network); 3 May 2008 23:53:28 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 May 2008 23:53:28 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [PATCH] add-symbol-file not to print address truncated Date: Sun, 04 May 2008 00:29:00 -0000 User-Agent: KMail/1.9.9 Cc: Adam Nemet References: <18460.63329.752236.534872@localhost.localdomain> <200805040043.26994.pedro@codesourcery.com> <18460.63955.147821.776423@localhost.localdomain> In-Reply-To: <18460.63955.147821.776423@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805040053.27168.pedro@codesourcery.com> 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: 2008-05/txt/msg00155.txt.bz2 A Sunday 04 May 2008 00:48:35, Adam Nemet wrote: > Pedro Alves writes: > > Would paddr_nz (in utils.c) do the trick? > > I thought of that but I don't think it would truncate the value when it > needs to be truncated. IOW, note the masking in hex_string_addr. > Ah, that looks like paddress then, except for the width. const char * paddress (CORE_ADDR addr) { /* Truncate address to the size of a target address, avoiding shifts larger or equal than the width of a CORE_ADDR. The local variable ADDR_BIT stops the compiler reporting a shift overflow when it won't occur. */ /* NOTE: This assumes that the significant address information is kept in the least significant bits of ADDR - the upper bits were either zero or sign extended. Should gdbarch_address_to_pointer or some ADDRESS_TO_PRINTABLE() be used to do the conversion? */ int addr_bit = gdbarch_addr_bit (current_gdbarch); if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) addr &= ((CORE_ADDR) 1 << addr_bit) - 1; return hex_string (addr); } char * hex_string_addr (CORE_ADDR addr) { int addr_bit = gdbarch_addr_bit (current_gdbarch); if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) addr &= ((CORE_ADDR) 1 << addr_bit) - 1; return hex_string_custom (addr, addr_bit <= 32 ? 8 : 16); } -- Pedro Alves