From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13171 invoked by alias); 12 Apr 2016 16:46:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 13133 invoked by uid 89); 12 Apr 2016 16:46:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=73,7, TRY, Reasons, reserved X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 12 Apr 2016 16:46:31 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A674F7822B; Tue, 12 Apr 2016 16:46:30 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CGkTg5026594; Tue, 12 Apr 2016 12:46:29 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Cc: "Yichun Zhang (agentzh)" Subject: [pushed] Use setjmp/longjmp for TRY/CATCH instead of sigsetjmp/siglongjmp Date: Tue, 12 Apr 2016 16:46:00 -0000 Message-Id: <1460479589-21126-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-04/txt/msg00249.txt.bz2 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 * common/common-exceptions.c (struct catcher) : 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 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 | 13 +++++++++++++ gdb/common/common-exceptions.c | 6 +++--- gdb/common/common-exceptions.h | 8 ++++---- gdb/cp-support.c | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5dfd4b0..b750266 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,18 @@ 2016-04-12 Pedro Alves + * common/common-exceptions.c (struct catcher) : 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 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". + +2016-04-12 Pedro Alves + * common/common-exceptions.c (exception_rethrow): Remove prepare_to_throw_exception call. * common/common-exceptions.h (prepare_to_throw_exception): Delete 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 /* 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 ()) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index c7f5074..5662f86 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -34,7 +34,7 @@ #include "cp-abi.h" #include "namespace.h" #include - +#include "gdb_setjmp.h" #include "safe-ctype.h" #define d_left(dc) (dc)->u.s_binary.left -- 2.5.5