From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: New(?) idea for making backtraces usable: condition-case* Date: Mon, 17 Jul 2023 19:12:15 +0300 Message-ID: <83ttu27c0w.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36455"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 17 18:12:41 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qLQq1-0009GW-0Q for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Jul 2023 18:12:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLQpI-0005rZ-IS; Mon, 17 Jul 2023 12:11:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLQpC-0005q2-Um for emacs-devel@gnu.org; Mon, 17 Jul 2023 12:11:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLQpC-0005mO-KH; Mon, 17 Jul 2023 12:11:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=e3n3d/k2DAC/wG62KRPxDhYZeXhpN16V4zEVO/4s+Po=; b=K4m8pZcXDcL8 T6oABHZ6EmeM1yVf074W65lOv0oTJpKF44vMOi1CoiiNskQ5YXXW55noPrL54EmXPFKgU88h7iE+n 0K0dPdixRdATtZgEmr4Zi3rOirY1/SGriIOMfXjgfXRaHoldkfncRZFr9VCgOIjHfD5/B90Be3BNY r1xta22OGGxZK/tJFv3OFqB7boCMPymK32LXb434HnseEBcGK1b+jnyjimMfxsdsmHdRtU38oVLuS BnToVnKF3ESuJa/FrriqryEWSbxWnfNhd5leDuUrxJEBz8i5PyPfkF3K8FJwuMBGqI04PcEf87r9s o0NWOFoBdIHlM20OJRr4CQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLQpB-0005xA-C1; Mon, 17 Jul 2023 12:11:50 -0400 In-Reply-To: (message from Alan Mackenzie on Mon, 17 Jul 2023 13:52:20 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307935 Archived-At: > Date: Mon, 17 Jul 2023 13:52:20 +0000 > From: Alan Mackenzie > > Hello, Emacs. > > condition-case's are an unfortunate fact of Emacs life - Typically, when > a signal is signalled to indicate a bug in the called code, the condition > case unavoidably discards the most useful part of the backtrace. This > conundrum gave rise (I think) to bug #50629 "hard to debug an uncaught > error with ert" raised by Mike Kupfer on 2021-09-16. > > My idea here is to write a new special form, condition-case*. This would > behave the same as condition-case unless a signal is signalled. In that > case the error handler forms would evaluate _before_ the specpdl gets > unwound. This unwinding would take place on exiting an error handler in > the form. The unwinding would NOT happen if the error handler is exited > with, say, signal. This would give nested condition-case*'s the chance > to output a full backtrace. > > In the event of generating a backtrace, the entire stack at the point of > failure would get output. > > Possibly, a new function unwind-stack might be needed, so that an error > handler can unwind the stack explicitly. I haven't thought this through, > yet. > > The implementation should be relatively straightforward, extending the > existing mechanisms in eval.c. > > Once it's working, large numbers of condition-case's could be replaced by > condition-case*, easing large amounts of debugging. > > What do people think? I don't think I understand what will this give us that we don't already have with the following three existing features: . setting debug-on-signal non-nil . using 'debug' among the condition-case's conditions . using condition-case-unless-debug