From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 534 invoked by alias); 18 Jan 2013 16:59:33 -0000 Received: (qmail 514 invoked by uid 22791); 18 Jan 2013 16:59:31 -0000 X-SWARE-Spam-Status: No, hits=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Jan 2013 16:59:22 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0IGxJ1w023655 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Jan 2013 11:59:19 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0IGxI1x028869; Fri, 18 Jan 2013 11:59:18 -0500 Message-ID: <50F97F65.1050701@redhat.com> Date: Fri, 18 Jan 2013 16:59:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Tom Tromey CC: Pierre Muller , gdb-patches@sourceware.org Subject: Re: catch SIGSEGV in the demangler References: <87fw23o70u.fsf@fleche.redhat.com> <19236.9665638127$1358374641@news.gmane.org> <87622vd2vd.fsf@fleche.redhat.com> <50F93081.1090905@redhat.com> <87obgm8nbj.fsf@fleche.redhat.com> In-Reply-To: <87obgm8nbj.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2013-01/txt/msg00441.txt.bz2 On 01/18/2013 04:31 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> The original idea was to do return instead of raise: > Pedro> +static void > Pedro> +handle_segv (int sig) > Pedro> +{ > Pedro> + struct gdb_exception except; > Pedro> + > Pedro> + if (!in_demangler) > Pedro> + { > Pedro> + signal (sig, SIG_DFL); > Pedro> + return; > Pedro> + } > > This works fine, but has the effect of causing gdb to ignore an explicit > 'kill -SEGV'. I had to hack "maint dump-me" to really see it work. Yeah, you're not supposed to send synchronous signals asynchronously. :-) We can detect that using sigaction/SA_SIGINFO, and then look at si_code, e.g.: void handler (int signo, siginfo_t *info) { if (expecting_segv) { signal (SIGSEGV, SIG_DFL); if (info->si_code == SI_USER) raise (signo); else return; } } Doesn't cover all si_codes, but should work fine in practice. -- Pedro Alves