From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96988 invoked by alias); 20 Dec 2016 19:43:53 -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 96974 invoked by uid 89); 20 Dec 2016 19:43:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3356, H*i:sk:0dfbf8b, H*f:sk:0dfbf8b, H*MI:sk:0dfbf8b 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 ESMTP; Tue, 20 Dec 2016 19:43:42 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 3EF0F338871; Tue, 20 Dec 2016 19:43:41 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBKJhZLl027304; Tue, 20 Dec 2016 14:43:39 -0500 Subject: Re: [RFC master/7.12.1] Don't propagate C++ exceptions across readline using SjLj on SjLj-based exception unwinding To: Yao Qi References: <1482158537-17839-1-git-send-email-yao.qi@linaro.org> <20161220143308.GC18061@E107787-LIN> <0dfbf8b3-7066-2bc0-1af2-0f720b1398c8@redhat.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <6404cafe-6820-cc26-1b1f-ce2d37dee993@redhat.com> Date: Tue, 20 Dec 2016 19:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <0dfbf8b3-7066-2bc0-1af2-0f720b1398c8@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-12/txt/msg00364.txt.bz2 On 12/20/2016 04:25 PM, Pedro Alves wrote: > Great, I've applied it to master now, like below. Will apply to > the 7.12 branch in a moment. ... and the buildbot let me know that this broke the branch ... > -static void > -gdb_rl_callback_read_char_wrapper (gdb_client_data client_data) > +static struct gdb_exception > +gdb_rl_callback_read_char_wrapper_noexcept () noexcept ... because I completely forgot that 7.12 is supposed to build in C and C++03 as well... I've applied this fix on the branch now. master doesn't need it, since it requires C++11. >From 9bfe0298332782a9c082fb475bdf8eeeef8cf45e Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 20 Dec 2016 19:18:15 +0000 Subject: [PATCH] gdb: Fix C and C++03 builds The readline/sjlj-exceptions fix added an unconditional use of noexcept, but that's only valid C++11, and 7.12 must build with C and C++03 too. Fix this by adding a GDB_EXCEPT macro that compiles away to nothing in C, and to throw() in C++03, which I've confirmed fixes the original issue just the same as noexcept, with GCC 7 + -std=gnu+03 + sjlj-exceptions. gdb/ChangeLog: 2016-12-20 Pedro Alves PR gdb/20977 * event-top.c (GDB_NOEXCEPT): Define. (gdb_rl_callback_read_char_wrapper_noexcept): Use GDB_NOEXCEPT instead of noexcept and use (void) instead of (). (gdb_rl_callback_handler): Use GDB_NOEXCEPT instead of noexcept. --- gdb/ChangeLog | 8 ++++++++ gdb/event-top.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e99025e..0aaae46 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,12 @@ 2016-12-20 Pedro Alves + + PR gdb/20977 + * event-top.c (GDB_NOEXCEPT): Define. + (gdb_rl_callback_read_char_wrapper_noexcept): Use GDB_NOEXCEPT + instead of noexcept and use (void) instead of (). + (gdb_rl_callback_handler): Use GDB_NOEXCEPT instead of noexcept. + +2016-12-20 Pedro Alves Yao Qi PR gdb/20977 diff --git a/gdb/event-top.c b/gdb/event-top.c index 3e218ff..7f590a9 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -73,6 +73,14 @@ static void async_stop_sig (gdb_client_data); #endif static void async_sigterm_handler (gdb_client_data arg); +#ifndef __cplusplus +# define GDB_NOEXCEPT +#elif __cplusplus < 201103L +# define GDB_NOEXCEPT throw () +#else +# define GDB_NOEXCEPT noexcept +#endif + /* Instead of invoking (and waiting for) readline to read the command line and pass it back for processing, we use readline's alternate interface, via callback functions, so that the event loop can react @@ -162,7 +170,7 @@ void (*after_char_processing_hook) (void); (sjlj-based) C++ exceptions. */ static struct gdb_exception -gdb_rl_callback_read_char_wrapper_noexcept () noexcept +gdb_rl_callback_read_char_wrapper_noexcept (void) GDB_NOEXCEPT { struct gdb_exception gdb_expt = exception_none; @@ -203,7 +211,7 @@ gdb_rl_callback_read_char_wrapper (gdb_client_data client_data) (sjlj-based) C++ exceptions. */ static void -gdb_rl_callback_handler (char *rl) noexcept +gdb_rl_callback_handler (char *rl) GDB_NOEXCEPT { struct gdb_exception gdb_rl_expt = exception_none; struct ui *ui = current_ui; -- 2.5.5