This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Use read_memory_unsigned_integer when reading to CORE_ADDR
- From: Klee Dienes <klee at apple dot com>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Sun, 6 Oct 2002 02:52:57 -0400
- Subject: Re: [PATCH] Use read_memory_unsigned_integer when reading to CORE_ADDR
Perhaps something along the lines of the following?
{
unsigned char buf[sizeof (CORE_ADDR)];
if (target_read_memory (memaddr, buf, TYPE_LENGTH
(builtin_type_void_data_ptr)) != 0)
error ("Unable to determine lower bound of array.");
*lower_bound = extract_typed_address (buf,
builtin_type_void_data_ptr);
}
That's a bit verbose, and it's not clear to me if sizeof (CORE_ADDR) is
guaranteed to be large enough to contain a raw target pointer, but I
can't really think of any better alternatives.
Aside from the intimidating comments in findvar.c, this would seem a
good candidate for extract_address ... though a similar modification
would have to be made to it to handle the sign-extension as well.
Or alternately, I could just leave well-enough alone, and be careful to
truncate CORE_ADDRs to 32 bits in our target xfer_memory code (or the
MIPS code could sign-extend it in the same place).
On Saturday, October 5, 2002, at 10:57 PM, Daniel Jacobowitz wrote:
Well, I'm a little concerned about this. MIPS generally wants the
result to be sign extended; the MIPS 32-bit ABIs map onto the lowest
and highest 2G segments of the 64-bit address space, not the low 4G
segment. Isn't there an appropriate function somewhere to read a
CORE_ADDR?
Answer: Yes, there is, but it has the same problem. You're just
extending current practice, so I don't see a problem with your patch.
Andrew, is my understanding right? Is there some reason this isn't a
problem?