From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31557 invoked by alias); 9 Sep 2002 19:36:12 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31550 invoked from network); 9 Sep 2002 19:36:11 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 9 Sep 2002 19:36:11 -0000 Received: from ges.redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 3FA493F43; Mon, 9 Sep 2002 15:36:06 -0400 (EDT) Message-ID: <3D7CF826.5020508@ges.redhat.com> Date: Mon, 09 Sep 2002 12:36:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kevin Buettner , fnf@intrinsity.com Cc: gdb-patches@sources.redhat.com Subject: Re: [RFC] Another 64 bit CORE_ADDR & 32 bit target address printing botch References: <200209080433.g884XU302357@beeville.vert.intrinsity.com> <1020909162819.ZM14375@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-09/txt/msg00127.txt.bz2 > On Sep 7, 11:33pm, Fred Fish wrote: > > >> I found another place where 32 bit addresses with the MSB set are printed >> as 0xffffffffxxxxxxxx. I hacked around the problem with this patch, >> but it might not be the best place to do it. Any better ideas? > > > Was this on MIPS? Aren't these addresses supposed to be sign extended on > MIPS? Yep, the value is definitly correct. > In any event, if the address stored in the CORE_ADDR is incorrect, I think > it'd be better to fix it at the point where it's being stored incorrectly. The problem isn't with the sign extension. Rather, its with the function proper. The comment: > /* FIXME: cagney/2002-05-03: Need local_address_string() function > that returns the language localized string formatted to a width > based on TARGET_ADDR_BIT. */ drops a vague hit as to the problem. The function is ment to be printing an address (of size TARGET_ADDR_BIT) and not a CORE_ADDR (of size sizeof (CORE_ADDR) * HOST_CHAR_BIT). The function name (..._core_addr), unfortunatly really confuses this. I'm just left wondering if the code should also check for truncation. That CORE_ADDR -> address -> CORE_ADDR doesn't loose information. Hmm, grub grub: /* Print address ADDR on STREAM. USE_LOCAL means the same thing as for print_longest. */ void print_address_numeric (CORE_ADDR addr, int use_local, struct ui_file *stream) { /* 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 ADDRESS_TO_POINTER() or some ADDRESS_TO_PRINTABLE() be used to do the conversion? */ int addr_bit = TARGET_ADDR_BIT; if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) addr &= ((CORE_ADDR) 1 << addr_bit) - 1; print_longest (stream, 'x', use_local, (ULONGEST) addr); } So, Fred, yes ok but steal the above code and comment. Andrew