+2017-01-20 Yao Qi <yao.qi@linaro.org>
+
+ PR gdb/20939
+ * disasm.c (dis_asm_memory_error): Catch the error and rethrow
+ it as a SJ/LJ exception. Add GDB_NOEXCEPT.
+ (disasm_print_insn_noexcept): New function.
+ (disasm_print_insn): New function.
+ (gdb_pretty_print_insn): Call disasm_print_insn instead of
+ gdbarch_print_insn.
+ (gdb_print_insn): Likewise.
+ (gdb_buffered_insn_length): Likewise.
+ * event-top.c (GDB_NOEXCEPT): Move it to ...
+ * exceptions.h (GDB_NOEXCEPT): ... here.
+ * guile/scm-disasm.c (gdbscm_disasm_memory_error): Remove.
+ (gdbscm_print_insn_from_port): Don't set di.memory_errro_func.
+ Call disasm_print_insn rather than gdbarch_print_insn.
+
2017-01-12 Tom Tromey <tom@tromey.com>
* python/py-framefilter.c (py_print_frame): Use
return target_read_code (memaddr, myaddr, len);
}
-/* Like memory_error with slightly different parameters. */
+/* Like memory_error with slightly different parameters, but it longjmp
+ out of the opcodes callback. */
static void
dis_asm_memory_error (int err, bfd_vma memaddr,
- struct disassemble_info *info)
+ struct disassemble_info *info) GDB_NOEXCEPT
{
- memory_error (TARGET_XFER_E_IO, memaddr);
+ struct gdb_exception exception = exception_none;
+
+ TRY
+ {
+ memory_error (TARGET_XFER_E_IO, memaddr);
+ }
+ CATCH (ex, RETURN_MASK_ALL)
+ {
+ exception = ex;
+ }
+ END_CATCH
+
+ throw_exception_sjlj (exception);
}
/* Like print_address with slightly different parameters. */
print_address (gdbarch, addr, (struct ui_file *) info->stream);
}
+/* Wrapper of gdbarch_print_insn, save its return value in *LEN if no
+ exception is thrown out of gdbarch_print_insn. */
+
+static struct gdb_exception
+disasm_print_insn_noexcept (struct gdbarch *gdbarch, bfd_vma vma,
+ struct disassemble_info *info,
+ int *len) GDB_NOEXCEPT
+{
+ struct gdb_exception gdb_expt = exception_none;
+
+ TRY_SJLJ
+ {
+ *len = gdbarch_print_insn (gdbarch, vma, info);
+ }
+ CATCH_SJLJ (ex, RETURN_MASK_ALL)
+ {
+ gdb_expt = ex;
+ }
+ END_CATCH_SJLJ
+
+ return gdb_expt;
+}
+
+int
+disasm_print_insn (struct gdbarch *gdbarch, bfd_vma vma,
+ struct disassemble_info *info)
+{
+ int len;
+
+ struct gdb_exception gdb_expt
+ = disasm_print_insn_noexcept (gdbarch, vma, info, &len);
+
+ /* Rethrow using the normal EH mechanism. */
+ if (gdb_expt.reason < 0)
+ throw_exception (gdb_expt);
+
+ return len;
+}
+
static int
compare_lines (const void *mle1p, const void *mle2p)
{
struct cleanup *cleanups =
make_cleanup_ui_file_delete (opcode_stream);
- size = gdbarch_print_insn (gdbarch, pc, di);
+ size = disasm_print_insn (gdbarch, pc, di);
end_pc = pc + size;
for (;pc < end_pc; ++pc)
do_cleanups (cleanups);
}
else
- size = gdbarch_print_insn (gdbarch, pc, di);
+ size = disasm_print_insn (gdbarch, pc, di);
ui_out_field_stream (uiout, "inst", stb);
ui_file_rewind (stb);
int length;
di = gdb_disassemble_info (gdbarch, stream);
- length = gdbarch_print_insn (gdbarch, memaddr, &di);
+ length = disasm_print_insn (gdbarch, memaddr, &di);
if (branch_delay_insns)
{
if (di.insn_info_valid)
gdb_buffered_insn_length_init_dis (gdbarch, &di, insn, max_len, addr);
- return gdbarch_print_insn (gdbarch, addr, &di);
+ return disasm_print_insn (gdbarch, addr, &di);
}
return status != NULL ? -1 : 0;
}
-/* disassemble_info.memory_error_func for gdbscm_print_insn_from_port.
- Technically speaking, we don't need our own memory_error_func,
- but to not provide one would leave a subtle dependency in the code.
- This function exists to keep a clear boundary. */
-
-static void
-gdbscm_disasm_memory_error (int status, bfd_vma memaddr,
- struct disassemble_info *info)
-{
- memory_error (TARGET_XFER_E_IO, memaddr);
-}
-
/* disassemble_info.print_address_func for gdbscm_print_insn_from_port.
Since we need to use our own application_data value, we need to supply
this routine as well. */
data.offset = offset;
di.application_data = &data;
di.read_memory_func = gdbscm_disasm_read_memory;
- di.memory_error_func = gdbscm_disasm_memory_error;
di.print_address_func = gdbscm_disasm_print_address;
- length = gdbarch_print_insn (gdbarch, memaddr, &di);
+ length = disasm_print_insn (gdbarch, memaddr, &di);
if (branch_delay_insns)
{