unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New(?) idea for making backtraces usable: condition-case*
@ 2023-07-18  4:38 Gerd Möllmann
  0 siblings, 0 replies; 10+ messages in thread
From: Gerd Möllmann @ 2023-07-18  4:38 UTC (permalink / raw)
  To: acm; +Cc: emacs-devel

Hi Alan,

not sure if you mean that with the "new? in the title, but Common Lisp 
has something in that department: handler-case, for example:

http://clhs.lisp.se/Body/m_hand_1.htm



^ permalink raw reply	[flat|nested] 10+ messages in thread
* New(?) idea for making backtraces usable: condition-case*
@ 2023-07-17 13:52 Alan Mackenzie
  2023-07-17 16:12 ` Eli Zaretskii
  2023-07-19  2:19 ` Richard Stallman
  0 siblings, 2 replies; 10+ messages in thread
From: Alan Mackenzie @ 2023-07-17 13:52 UTC (permalink / raw)
  To: emacs-devel

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)



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-07-21  5:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18  4:38 New(?) idea for making backtraces usable: condition-case* Gerd Möllmann
  -- strict thread matches above, loose matches on Subject: below --
2023-07-17 13:52 Alan Mackenzie
2023-07-17 16:12 ` Eli Zaretskii
2023-07-19  2:19   ` Richard Stallman
2023-07-19 20:35   ` Alan Mackenzie
2023-07-20  4:41     ` Eli Zaretskii
2023-07-21  2:42     ` Richard Stallman
2023-07-21  5:55       ` Eli Zaretskii
2023-07-21  5:59         ` Ihor Radchenko
2023-07-19  2:19 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).