aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-04-12 17:20:04 +0100
committerPedro Alves <palves@redhat.com>2016-04-12 17:20:04 +0100
commit173981bc49c9e8fce9271cb47714952dbe2ec627 (patch)
tree9b7d5064d89ec8c34422be04239d51ca07620b73 /gdb/common
parent2afc13ff80492278154c0f2156a9d32dd5ba675a (diff)
downloadgdb-173981bc49c9e8fce9271cb47714952dbe2ec627.zip
gdb-173981bc49c9e8fce9271cb47714952dbe2ec627.tar.gz
gdb-173981bc49c9e8fce9271cb47714952dbe2ec627.tar.bz2
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".
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/common-exceptions.c6
-rw-r--r--gdb/common/common-exceptions.h8
2 files changed, 7 insertions, 7 deletions
diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c
index 5ea8188..2e63862 100644
--- a/gdb/common/common-exceptions.c
+++ b/gdb/common/common-exceptions.c
@@ -46,7 +46,7 @@ struct catcher
{
enum catcher_state state;
/* Jump buffer pointing back at the exception handler. */
- SIGJMP_BUF buf;
+ jmp_buf buf;
/* Status buffer belonging to the exception handler. */
struct gdb_exception exception;
struct cleanup *saved_cleanup_chain;
@@ -73,7 +73,7 @@ catcher_list_size (void)
return size;
}
-SIGJMP_BUF *
+jmp_buf *
exceptions_state_mc_init (void)
{
struct catcher *new_catcher = XCNEW (struct catcher);
@@ -275,7 +275,7 @@ throw_exception (struct gdb_exception exception)
be zero, by definition in defs.h. */
exceptions_state_mc (CATCH_THROWING);
current_catcher->exception = exception;
- SIGLONGJMP (current_catcher->buf, exception.reason);
+ longjmp (current_catcher->buf, exception.reason);
#else
if (exception.reason == RETURN_QUIT)
{
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index 54c6249..e21713c 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -20,7 +20,7 @@
#ifndef COMMON_EXCEPTIONS_H
#define COMMON_EXCEPTIONS_H
-#include "gdb_setjmp.h"
+#include <setjmp.h>
/* Reasons for calling throw_exceptions(). NOTE: all reason values
must be less than zero. enum value 0 is reserved for internal use
@@ -142,7 +142,7 @@ struct gdb_exception
macros defined below. */
#if GDB_XCPT == GDB_XCPT_SJMP
-extern SIGJMP_BUF *exceptions_state_mc_init (void);
+extern jmp_buf *exceptions_state_mc_init (void);
extern int exceptions_state_mc_action_iter (void);
extern int exceptions_state_mc_action_iter_1 (void);
extern int exceptions_state_mc_catch (struct gdb_exception *, int);
@@ -181,9 +181,9 @@ extern void exception_rethrow (void);
#define TRY \
{ \
- SIGJMP_BUF *buf = \
+ jmp_buf *buf = \
exceptions_state_mc_init (); \
- SIGSETJMP (*buf); \
+ setjmp (*buf); \
} \
while (exceptions_state_mc_action_iter ()) \
while (exceptions_state_mc_action_iter_1 ())