- *optimizedp = 0;
- *lvalp = lval_memory;
- *addrp = info->saved_regs[regnum].addr;
- *realnump = -1;
- if (bufferp != NULL)
- {
- /* Reading the return PC from the PC register is slightly
- abnormal. register_size(AVR_PC_REGNUM) says it is 4 bytes,
- but in reality, only two bytes (3 in upcoming mega256) are
- stored on the stack.
-
- Also, note that the value on the stack is an addr to a word
- not a byte, so we will need to multiply it by two at some
- point.
-
- And to confuse matters even more, the return address stored
- on the stack is in big endian byte order, even though most
- everything else about the avr is little endian. Ick! */
-
- /* FIXME: number of bytes read here will need updated for the
- mega256 when it is available. */
-
- ULONGEST pc;
- unsigned char tmp;
- unsigned char buf[2];
-
- read_memory (info->saved_regs[regnum].addr, buf, 2);
-
- /* Convert the PC read from memory as a big-endian to
- little-endian order. */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
-
- pc = (extract_unsigned_integer (buf, 2) * 2);
- store_unsigned_integer (bufferp,
- register_size (current_gdbarch, regnum),
- pc);
- }
+ /* Reading the return PC from the PC register is slightly
+ abnormal. register_size(AVR_PC_REGNUM) says it is 4 bytes,
+ but in reality, only two bytes (3 in upcoming mega256) are
+ stored on the stack.
+
+ Also, note that the value on the stack is an addr to a word
+ not a byte, so we will need to multiply it by two at some
+ point.
+
+ And to confuse matters even more, the return address stored
+ on the stack is in big endian byte order, even though most
+ everything else about the avr is little endian. Ick! */
+ ULONGEST pc;
+ int i;
+ gdb_byte buf[3];
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ read_memory (info->saved_regs[AVR_PC_REGNUM].addr,
+ buf, tdep->call_length);
+
+ /* Extract the PC read from memory as a big-endian. */
+ pc = 0;
+ for (i = 0; i < tdep->call_length; i++)
+ pc = (pc << 8) | buf[i];
+
+ if (regnum == AVR_PC_REGNUM)
+ pc <<= 1;
+
+ return frame_unwind_got_constant (this_frame, regnum, pc);