[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New(?) idea for making backtraces usable: condition-case*
From: |
Alan Mackenzie |
Subject: |
Re: New(?) idea for making backtraces usable: condition-case* |
Date: |
Wed, 19 Jul 2023 20:35:06 +0000 |
Hello, Eli.
On Mon, Jul 17, 2023 at 19:12:15 +0300, Eli Zaretskii wrote:
> > Date: Mon, 17 Jul 2023 13:52:20 +0000
> > From: Alan Mackenzie <acm@muc.de>
> > 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
Maybe not very much.
I've tried using debug-on-signal, but it triggers just too often to be
helpful.
I didn't know that one can usefully put `debug' in a condition-case
condition (which is what condition-case-unless-debug does). So, thanks
for the education!
But we only have 33 uses of condition-case-unless-debug as against 1661
of condition-case. There're probably a lot of the latter that could
usefully be changed into the former.
Anyhow, I withdraw my proposal for condition-case*.
--
Alan Mackenzie (Nuremberg, Germany).
Re: New(?) idea for making backtraces usable: condition-case*, Richard Stallman, 2023/07/18