+/* Determine type of frame by scanning the function for a return
+ instruction. */
+
+static enum rx_frame_type
+rx_frame_type (struct frame_info *this_frame, void **this_cache)
+{
+ const char *name;
+ CORE_ADDR pc, start_pc, lim_pc;
+ int bytes_read;
+ struct rx_get_opcode_byte_handle opcode_handle;
+ RX_Opcode_Decoded opc;
+
+ gdb_assert (this_cache != NULL);
+
+ /* If we have a cached value, return it. */
+
+ if (*this_cache != NULL)
+ {
+ struct rx_prologue *p = (struct rx_prologue *) *this_cache;
+
+ return p->frame_type;
+ }
+
+ /* No cached value; scan the function. The frame type is cached in
+ rx_analyze_prologue / rx_analyze_frame_prologue. */
+
+ pc = get_frame_pc (this_frame);
+
+ /* Attempt to find the last address in the function. If it cannot
+ be determined, set the limit to be a short ways past the frame's
+ pc. */
+ if (!find_pc_partial_function (pc, &name, &start_pc, &lim_pc))
+ lim_pc = pc + 20;
+
+ while (pc < lim_pc)
+ {
+ opcode_handle.pc = pc;
+ bytes_read = rx_decode_opcode (pc, &opc, rx_get_opcode_byte,
+ &opcode_handle);
+
+ if (bytes_read <= 0 || opc.id == RXO_rts)
+ return RX_FRAME_TYPE_NORMAL;
+ else if (opc.id == RXO_rtfi)
+ return RX_FRAME_TYPE_FAST_INTERRUPT;
+ else if (opc.id == RXO_rte)
+ return RX_FRAME_TYPE_EXCEPTION;
+
+ pc += bytes_read;
+ }
+
+ return RX_FRAME_TYPE_NORMAL;
+}
+
+