This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
INTEGER_TO_ADDRESS(), thoughts?
- To: gdb at sources dot redhat dot com
- Subject: INTEGER_TO_ADDRESS(), thoughts?
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 18 Sep 2001 21:13:52 -0400
Hello,
values.c:value_as_pointer() contains:
/* In converting VAL to an address (CORE_ADDR), any small integers
are first cast to a generic pointer. The function unpack_long
will then correctly convert that pointer into a canonical address
(using POINTER_TO_ADDRESS).
Without the cast, the MIPS gets: 0xa0000000 -> (unsigned int)
0xa0000000 -> (LONGEST) 0x00000000a0000000
With the cast, the MIPS gets: 0xa0000000 -> (unsigned int)
0xa0000000 -> (void*) 0xa0000000 -> (LONGEST) 0xffffffffa0000000.
If the user specifies an integer that is larger than the target
pointer type, it is assumed that it was intentional and the value
is converted directly into an ADDRESS. This ensures that no
information is discarded.
NOTE: The cast operation may eventualy be converted into a TARGET
method (see POINTER_TO_ADDRESS() and ADDRESS_TO_POINTER()) so
that the TARGET ISA/ABI can apply an arbitrary conversion.
NOTE: In pure harvard architectures function and data pointers
can be different and may require different integer to pointer
conversions. */
if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT
&& (TYPE_LENGTH (VALUE_TYPE (val))
<= TYPE_LENGTH (builtin_type_void_data_ptr)))
{
val = value_cast (builtin_type_void_data_ptr, val);
}
return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));
as the comment suggests, there are two motivations, behind the hack:
- MIPS needs to signextend integer -> pointer -> address conversions.
- harvard architectures (and probably MIPS) want a way of being able to
by-pass integer -> pointer -> address conversion so that the user can
enter addresses directly.
I'd like to propose a cleanup to this:
/* Some architectures (e.g. Harvard), map instruction and data
addresses onto a single large unified address space. For
instance: An architecture may consider a large integer in the
range 0x10000000 .. 0x1000ffff to already represent a data
addresses (hence not need a pointer to address conversion) while
a small integer would still need to be converted integer to
pointer to address. Just assume such architectures handle all
integer conversions in a single function. */
if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT
&& INTEGER_TO_ADDRESS_P ())
return INTEGER_TO_ADDRESS (VALUE_TYPE (val), VALUE_CONTENTS (val));
which introduces the new architecture method - intrger_to_address() and
that would allow things like MIPS and harvard architectures to implement
arbitrary integer -> address conversions. It would also allow them to
reject invalid conversions.
Thoughts? I've so far identified the MIPS and d10v as targets needing
the new method.
Assuming it soulds ok, I can knock up a patch + doco changes.
Andrew