This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [BUG] print_address_numeric
- To: David Taylor <taylor at cygnus dot com>
- Subject: Re: [BUG] print_address_numeric
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 01 Aug 2000 12:28:42 +1000
- CC: gdb-patches at sourceware dot cygnus dot com
- References: <200007311455.KAA22560@texas.cygnus.com>
David Taylor wrote:
>
> In printcmd.c (print_address_numeric), we find the lines:
>
> int ptr_bit = TARGET_PTR_BIT;
> if (ptr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
> addr &= ((CORE_ADDR) 1 << ptr_bit) - 1;
> print_longest (stream, 'x', use_local, (ULONGEST) addr);
You forgot the lines:
/* Truncate address to the size of a target pointer, avoiding shifts
larger or equal than the width of a CORE_ADDR. The local
variable PTR_BIT stops the compiler reporting a shift overflow
when it won't occure. */
/* 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? */
:-)
> This code has a bug, namely it assumes that addresses and pointers are
> the same size.
>
> [address == gdb representation; pointer == target representation]
CORE_ADDR - GDB's internal representation of an address
it is large enough to fit target address information.
pointer - targets pointer representation
??? - minimum number of bits needed to represent an address on the
target.
When printing a symbolic address, should it be displayed using GDB's
internal format (for MIPS definitly not) or target pointer format.
> For some processors they are different. For the d10v and at least one
> other processor, the size of a pointer is 2 bytes, but the size of an
> address is 4 bytes.
>
> I propose the creation of a new macro TARGET_ADDR_BIT, the addition of
> the lines:
>
> #if !defined(TARGET_ADDR_BIT)
> #define TARGET_ADDR_BIT TARGET_PTR_BIT
> #endif
>
> to defs.h, and that the above lines of print_address_numeric be changed to:
>
> int addr_bit = TARGET_ADDR_BIT
> if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
> addr & ((CORE_ADDR) 1 << ptr_bit) - 1;
> print_longest (stream, 'x', use_local, (ULONGEST) addr);
>
> Comments?
I think it should be a method (function) rather than a macro. The
default function using TARGET_PTR_BIT. It would give your target
complete freedom over how the numeric address is printed.
Andrew