Commit graph

12 commits

Author SHA1 Message Date
Stefan Monnier
391c208aec (backtrace-on-redisplay-error): Use handler-bind
Reimplement `backtrace-on-redisplay-error` using `push_handler_bind`.
This moves the code from `signal_or_quit` to `xdisp.c` and
`debug-early.el`.

* lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
Add `base` arg to strip "internal" frames.
(debug--early): New function, extracted from `debug-early`.
(debug-early, debug-early--handler): Use it.
(debug-early--muted): New function, extracted (translated) from
`signal_or_quit`; trim the buffer to a max of 10 backtraces.

* src/xdisp.c (funcall_with_backtraces): New function.
(dsafe_calln): Use it.
(syms_of_xdisp): Defsym `Qdebug_early__muted`.

* src/eval.c (redisplay_deep_handler): Delete var.
(init_eval, internal_condition_case_n): Don't set it any more.
(backtrace_yet): Delete var.
(signal_or_quit): Remove special case for `backtrace_on_redisplay_error`.
* src/keyboard.c (command_loop_1): Don't set `backtrace_yet` any more.
* src/lisp.h (backtrace_yet): Don't declare.
2024-01-04 16:37:01 -05:00
Stefan Monnier
604e34338f Move batch backtrace code to top_level_2
Move ad-hoc code meant to ease debugging of bootstrap (and batch mode)
to `top_level_2` so it doesn't pollute `signal_or_quit`.

* src/lisp.h (pop_handler, push_handler_bind): Declare.
* src/keyboard.c (top_level_2): Setup an error handler to call
`debug-early` when noninteractive.
* src/eval.c (pop_handler): Not static any more.
(signal_or_quit): Remove special case for noninteractive use.
(push_handler_bind): New function, extracted from `Fhandler_bind_1`.
(Fhandler_bind_1): Use it.
(syms_of_eval): Declare `Qdebug_early__handler`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Weed out
frames below `debug-early`.
(debug-early--handler): New function.
2024-01-04 16:35:53 -05:00
Po Lu
8e1c56ae46 ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
Stefan Monnier
1f1d36fa80 * lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Fix bug#61847
The `noerror` arg of `require` doesn't do what Stefan naively thought
when he wrote this code, so use `condition-case` instead.
Also check for `cl-defmethod` since `cl-prin1` can't be loaded before
that anyway.
2023-03-01 12:31:09 -05:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
Lars Ingebrigtsen
bd1f20eea1 Make debug-early-backtrace more resilient
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Allow
outputting backtraces during bootstrap.
2022-06-24 11:04:51 +02:00
Stefan Monnier
08108a856a debug-early: Print bytecode in a more manageable way
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
Escape newlines to and bytecodes to make backtraces slightly more
readable.  Use `cl-prin1` when available.
2022-04-29 22:18:09 -04:00
Stefan Monnier
69efc36c6b Fix eval-tests/backtrace-in-batch-mode test
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Fix the
zero-arg case.
2022-02-06 19:20:36 -05:00
Stefan Monnier
bff8354ec4 (debug-early-backtrace): Tweak the non-evald output
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Make the
non-evald output more like what is used in `debug.el`.
2022-02-06 13:06:22 -05:00
Stefan Monnier
e95ca5cf07 (debug-early-backtrace): Tweak the non-evald output
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Make the
non-evald output more like what is used in `debug.el`.
2022-02-06 13:04:35 -05:00
Alan Mackenzie
9029212c86 * lisp/emacs-lisp/debug-early.el: Improve the documentation 2022-02-05 10:43:27 +00:00
Alan Mackenzie
aa795a6223 New file lisp/emacs-lisp/debug-early.el for backtraces in early bootstrap
This is also used in batch mode in general.

* lisp/debug-early.el (debug-early-backtrace, debug-early): New functions.

* lisp/loadup.el (top level): Load debug-early.el as first file.

* src/eval.c (signal_or_quit): Remove the condition in the batch mode section
of not being in dumping or bootstrap, since it is no longer needed.  Test that
'debug-early's symbol-function is bound.  Ensure there is enough working space
in specpdl and eval_depth.
(syms_of_eval): New DEFSYM for Qdebug_early.  Initialise Vdebugger to
Qdebug_early rather than Qnil.
2022-02-02 20:35:39 +00:00