print-address.patch

David Taylor taylor@cygnus.com
Thu Feb 8 10:20:00 GMT 2001


    From: Doug Evans <dje@transmeta.com>
    Date: Thu, 8 Feb 2001 09:35:41 -0800 (PST)

    David Taylor writes:
     >     Date: Wed, 7 Feb 2001 23:22:25 -0800
     >     From: Doug Evans <dje@transmeta.com>
     > 
     >     The comment in print_address_numeric claims it's casting the address
     >     to the size of [TARGET_]PTR_BIT (which sounds correct to me),
     >     when in fact it's using TARGET_ADDR_BIT.
     > 
     > Then the comment is wrong.  It should indeed be using TARGET_ADDR_BIT.
     >
     > print_address_numeric is printing an *ADDRESS* not a *POINTER*, so
     > TARGET_ADDR_BIT is the right thing to use.

    I'm not sure I buy that, given this comment in the todo list.
    [also in the code methinks]

Well, there's a reason why print_address_numeric has the word
*address* in its name -- it takes an address.

If you think about it, addresses are currently what the user types.

Yes, what the user sees/types, what gdb uses, and what the target uses
should all three be separate, but they aren't currently.  The first
two are currently the same.

    ---
    printcmd.c (print_address_numeric):

    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?
    ---

The ADDRESS_TO_POINTER part in that TODO entry is simply wrong.

And, yes, someday we should create a new abstraction for what the user
sees/types/uses and have something like ADDRESS_TO_PRINTABLE as part
of it.  But, that hasn't happened yet.

    In the case of ptr_bit == 32 and addr_bit == 64,
    seems to me like the code is intending to chop the upper 32 bits off:

      if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
	addr &= ((CORE_ADDR) 1 << addr_bit) - 1;

    Question: when is addr_bit < sizeof (CORE_ADDR)?

Well, addr_bit is always <= sizeof (CORE_ADDR) * HOST_CHAR_BIT.  All
we can say for sure about CORE_ADDR is that it has sufficient bits to
represent an address -- that it has at least addr_bit bits.

For Harvard Architecture targets, generally some of the upper bits are
used to tell which address space the address belongs to.


More information about the Gdb-patches mailing list