This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: avr and frame unwinding
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: "Theodore A. Roth" <troth at openavr dot org>
- Cc: gdb at sources dot redhat dot com
- Date: Sun, 08 Jun 2003 15:15:23 -0400
- Subject: Re: avr and frame unwinding
- References: <Pine.LNX.4.44.0306081041190.32526-100000@bozoland.mynet>
:):)Is this arrithmetic correct - I understand the ``* 2'' but not the ``>>8''.
:):)
:):)> pc = (extract_unsigned_integer (buf, 2) * 2) >> 8;
:)
:)That's the ugly part I don't understand. It seems to give the correct
:)result, but now that I think about it more, it could mean that my memory
:)address is off by 1. I will have to re-examine that.
:)
:):)
:):)this memcpy will need to be a
:):)
:):) store_unsigned_integer (bufferp, pc, SIZEOF_AVR_PC);
:):)
:)
:)I tried that, but it performed a endian byte swap and the PC came out wrong.
:)I dug around and saw what looked to be too many byte swaps.
:)
:):)> memcpy (bufferp, &pc, sizeof(pc));
:):)> }
:):)> else
:):)> {
:):)> read_memory (this_saved_regs[regnum], bufferp,
:):)> register_size (current_gdbarch, regnum));
:):)> }
I think found the root of the ugliness. When the avr performs a call
instruction the PC is pushed onto the stack, but it turns out that it is
pushed in big endian order. For the most part though, the avr is little
endian.
That would explain it. I guess it needs an explicit big endian extract
followed by a little endian store (via store_unsigned_integer).
Andrew