- if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame),
- get_frame_base (frame),
- get_frame_base (frame)))
- return deprecated_read_register_dummy (get_frame_pc (frame),
- get_frame_base (frame),
- AVR_PC_REGNUM);
+ CORE_ADDR start_pc, current_pc;
+ ULONGEST prev_sp;
+ ULONGEST this_base;
+ struct avr_unwind_cache *info;
+ struct gdbarch *gdbarch;
+ struct gdbarch_tdep *tdep;
+ int i;
+
+ if (*this_prologue_cache)
+ return *this_prologue_cache;
+
+ info = FRAME_OBSTACK_ZALLOC (struct avr_unwind_cache);
+ *this_prologue_cache = info;
+ info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
+
+ info->size = 0;
+ info->prologue_type = AVR_PROLOGUE_NONE;
+
+ start_pc = get_frame_func (this_frame);
+ current_pc = get_frame_pc (this_frame);
+ if ((start_pc > 0) && (start_pc <= current_pc))
+ avr_scan_prologue (get_frame_arch (this_frame),
+ start_pc, current_pc, info);
+
+ if ((info->prologue_type != AVR_PROLOGUE_NONE)
+ && (info->prologue_type != AVR_PROLOGUE_MAIN))
+ {
+ ULONGEST high_base; /* High byte of FP */
+
+ /* The SP was moved to the FP. This indicates that a new frame
+ was created. Get THIS frame's FP value by unwinding it from
+ the next frame. */
+ this_base = get_frame_register_unsigned (this_frame, AVR_FP_REGNUM);
+ high_base = get_frame_register_unsigned (this_frame, AVR_FP_REGNUM + 1);
+ this_base += (high_base << 8);
+
+ /* The FP points at the last saved register. Adjust the FP back
+ to before the first saved register giving the SP. */
+ prev_sp = this_base + info->size;
+ }