From unknown Fri Sep 05 11:00:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24617: 26.0.50; Handlers in `condition-case' should have programmatic access to the backtrace Resent-From: Philipp Stephani
This sounds like a great idea!
As an aside, note that these things are not impossible; just tricky.=C2=A0 = You just need to register your own debugger, then in that debugger function= re-throw the error after recording the backtrace.=C2=A0 You also need to i= ncrement num-nonmacro-input-events from the debugger.
Second, unconditionally copying the backtrace would be expensiveAre you sure about that? In languages that are typic= ally far more performance-sensitive (e.g. Java), the backtrace is also copi= ed unconditionally.=C2=A0an= d
would still not allow access to local variables in stack frames or the
value of dynamic variables at the point where the error was signalled
Just because Java or Python do that doesn't make it a great idea.True, but having the fun= ction names and argument values is better than nothing when debugging the c= ause of a signal.=C2=A0
Third, the solution to this problem in Common Lisp is the HANDLER-CASE
macro which is similar to condition-case but the error handlers are
executed without unwinding the stack.=C2=A0 That doesn't require any co= pying
and gives full access to the stack.That s= ounds like an interesting approach that could be made to solve some common = use cases (e.g. test runners or rethrowing signals).