Use setjmp/longjmp for TRY/CATCH instead of sigsetjmp/siglongjmp
authorPedro Alves <palves@redhat.com>
Tue, 12 Apr 2016 16:20:04 +0000 (17:20 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 12 Apr 2016 16:20:04 +0000 (17:20 +0100)
commit173981bc49c9e8fce9271cb47714952dbe2ec627
tree9b7d5064d89ec8c34422be04239d51ca07620b73
parent2afc13ff80492278154c0f2156a9d32dd5ba675a
Use setjmp/longjmp for TRY/CATCH instead of sigsetjmp/siglongjmp

Now that we don't ever throw GDB exceptions from signal handlers [1],
we can switch to have TRY/CATCH implemented in terms of plain
setjmp/longjmp instead of sigsetjmp/siglongjmp.

In https://sourceware.org/ml/gdb-patches/2015-02/msg00114.html, Yichun
Zhang mentions a 11%/14%+ speedup in his GDB python scripts with a
patch that did something similar to only a specific set of TRY/CATCH
calls.

[1] - https://sourceware.org/ml/gdb-patches/2016-03/msg00351.html

Tested on x86_64 Fedora 23, native and gdbserver.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.c (struct catcher) <buf>: Now a
'jmp_buf' instead of SIGJMP_BUF.
(exceptions_state_mc_init): Change return type to 'jmp_buf'.
(throw_exception): Use longjmp instead of SIGLONGJMP.
* common/common-exceptions.h: Include <setjmp.h> instead of
"gdb_setjmp.h".
(exceptions_state_mc_init): Change return type to 'jmp_buf'.
[GDB_XCPT == GDB_XCPT_SJMP] (TRY): Use setjmp instead of
SIGSETJMP.
* cp-support.c: Include "gdb_setjmp.h".
gdb/ChangeLog
gdb/common/common-exceptions.c
gdb/common/common-exceptions.h
gdb/cp-support.c