emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New(?) idea for making backtraces usable: condition-case*


From: Alan Mackenzie
Subject: New(?) idea for making backtraces usable: condition-case*
Date: Mon, 17 Jul 2023 13:52:20 +0000

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?

-- 
Alan Mackenzie (Nuremberg, Germany)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]