This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: avr and frame unwinding



:):)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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]