This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/gdb-7.12-branch] Throw SJ/LJ exception on error in disassembly


*** TEST RESULTS FOR COMMIT e2285602341fff057a9b4687b465a9d9cde1303f ***

Author: Yao Qi <yao.qi@linaro.org>
Branch: gdb-7.12-branch
Commit: e2285602341fff057a9b4687b465a9d9cde1303f

Throw SJ/LJ exception on error in disassembly

PR 20939 reports that GDB will abort on memory error in disassembly,

(gdb) disassemble 0x0,+4
Dump of assembler code from 0x0 to 0x4:
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
   0x0000000000000000:	Aborted

(gdb) guile (print (arch-disassemble arch 0 #:size 4))^M
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'^M
ERROR: Process no longer exists

This patch fixes PR 20939 by catching C++ exception, throwing SJ/LJ
exception in the call back passed to C functions of opcodes, and
catching SJ/LJ exception in gdb, and throw exception.

The patch follows this commit

 89525768cd086a0798a504c81fdf7ebcd4c904e1
 Propagate GDB/C++ exceptions across readline using sj/lj-based TRY/CATCH

rather than "backport" the fix to this PR I posted for mainline
https://sourceware.org/ml/gdb-patches/2017-01/msg00288.html because the
fix for mainline includes 1) some changes to opcodes, 2) some refactors
in C++.  All of them are risky to backport to 7.12 branch.

With this patch applied to 7.12 branch, GDB doesn't abort on memory error
in disassembly.  It fixes some test failures in gdb.guile/scm-disasm.exp
and gdb.python/py-arch.exp on aarch64-linux.

-ERROR: Process no longer exists
-UNRESOLVED: gdb.guile/scm-disasm.exp: test bad memory access
+PASS: gdb.guile/scm-disasm.exp: test bad memory access

-ERROR: Process no longer exists
-UNRESOLVED: gdb.python/py-arch.exp: test bad memory access
+PASS: gdb.python/py-arch.exp: test bad memory access

I'll add the scm-disasm test to master later.

gdb:

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]