+ di = gdb_disassemble_info (gdbarch, stream);
+ length = gdbarch_print_insn (gdbarch, memaddr, &di);
+ if (branch_delay_insns)
+ {
+ if (di.insn_info_valid)
+ *branch_delay_insns = di.branch_delay_insns;
+ else
+ *branch_delay_insns = 0;
+ }
+ return length;
+}
+
+static void
+do_ui_file_delete (void *arg)
+{
+ ui_file_delete (arg);
+}
+
+/* Return the length in bytes of the instruction at address MEMADDR in
+ debugged memory. */
+
+int
+gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR addr)
+{
+ static struct ui_file *null_stream = NULL;
+
+ /* Dummy file descriptor for the disassembler. */
+ if (!null_stream)
+ {
+ null_stream = ui_file_new ();
+ make_final_cleanup (do_ui_file_delete, null_stream);
+ }
+
+ return gdb_print_insn (gdbarch, addr, null_stream, NULL);
+}
+
+/* fprintf-function for gdb_buffered_insn_length. This function is a
+ nop, we don't want to print anything, we just want to compute the
+ length of the insn. */
+
+static int ATTRIBUTE_PRINTF (2, 3)
+gdb_buffered_insn_length_fprintf (void *stream, const char *format, ...)
+{
+ return 0;
+}
+
+/* Initialize a struct disassemble_info for gdb_buffered_insn_length. */
+
+static void
+gdb_buffered_insn_length_init_dis (struct gdbarch *gdbarch,
+ struct disassemble_info *di,
+ const gdb_byte *insn, int max_len,
+ CORE_ADDR addr)