unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH]: Re: Early backtrace.
Date: Sun, 30 Jan 2022 11:31:30 -0500	[thread overview]
Message-ID: <jwvczk9ry7j.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <YfZxdNv3fsD6sSq0@ACM> (Alan Mackenzie's message of "Sun, 30 Jan 2022 11:07:32 +0000")

Alan Mackenzie [2022-01-30 11:07:32] wrote:

>> Namespace prefixes don't need to be created before we use them.
>> The point is just that `debugger-` is already used by definitions (in
>> `debug.el`) so we can reuse that space instead of messing up pristine
>> real estate.
> OK, I've called it debug-early.

Deal!

> Are there any objections to me committing this to master?

See my comments below.

>    /* If we're in batch mode, print a backtrace unconditionally to help
> -     with debugging.  Make sure to use `debug' unconditionally to not
> -     interfere with ERT or other packages that install custom
> -     debuggers.  Don't try to call the debugger while dumping or
> -     bootstrapping, it wouldn't work anyway.  */
> +     with debugging.  Make sure to use `debug-early' unconditionally
> +     to not interfere with ERT or other packages that install custom
> +     debuggers.  */

This is not your fault, but I notice that this comment doesn't explain
how we distinguish the case where we want to print a backtrace from the
case where we want to call ERT's "debugger", both of which can occur in
batch mode.

> (defalias 'debug-early-backtrace
>   #'(lambda ()
>   "Print a trace of Lisp function calls currently active.
> The output stream used is the value of `standard-output'.
>
> This is a simplified version of the standard `backtrace'
> function, intended for use in debugging the early parts
> of the build process."
>   (princ "\n")
>   (mapbacktrace
>    #'(lambda (evald func args _flags)
>        (let ((args args))
> 	 (if evald
> 	     (progn
> 	       (princ "  ")
> 	       (prin1 func)
> 	       (princ " (")
> 	       (while args
> 		 (prin1 (car args))
> 		 (setq args (cdr args))
> 		 (if args
> 		     (princ " ")))
> 	       (princ ")\n"))
> 	   (while args
> 	     (princ "  ")
> 	     (prin1 (car args))
> 	     (princ "\n")
> 	     (setq args (cdr args)))))))))
>
> (defalias 'debug-early
>   #'(lambda (&rest args)
>   "Print a trace of Lisp function calls currently active.
> The output stream used is the value of `standard-output'.
>
> There should be two ARGS, the symbol `error' and a cons of
> the error symbol and its data.
>
> This is a simplified version of `debug', intended for use
> in debugging the early parts of the build process."
>   (princ "\nError: ")
>   (prin1 (car (car (cdr args))))	; The error symbol.
>   (princ " ")
>   (prin1 (cdr (car (cdr args))))	; The error data.
>   (debug-early-backtrace)))

I'm curious: why did you split this into two functions?

> (setq debugger #'debug-early)

Could we make `debug-early` the default/initial value of `debugger` in
the C code, so that reloading `debug-early.el` can be done safely?


        Stefan




  reply	other threads:[~2022-01-30 16:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 20:34 Early backtrace Alan Mackenzie
2022-01-10 21:54 ` Stefan Monnier
2022-01-11 11:36   ` Alan Mackenzie
2022-01-11 14:47     ` Stefan Monnier
2022-01-30 11:07       ` [PATCH]: " Alan Mackenzie
2022-01-30 16:31         ` Stefan Monnier [this message]
2022-01-31 14:04           ` Stefan Monnier
2022-02-01 19:14           ` Alan Mackenzie
2022-02-02  3:36             ` Stefan Monnier
2022-02-02 20:38               ` Alan Mackenzie
2022-02-02 20:59                 ` Stefan Monnier
2022-02-03  8:38                   ` Eli Zaretskii
2022-02-03 21:35                     ` Alan Mackenzie
2022-02-04  7:24                       ` Eli Zaretskii
2022-02-04 21:01                         ` Alan Mackenzie
2022-02-05  7:12                           ` Eli Zaretskii
2022-02-05 10:48                             ` Alan Mackenzie
2022-02-04 13:31                     ` Stefan Monnier
2022-02-04 14:02                       ` Eli Zaretskii
2022-01-31  9:30         ` Philipp Stephani
2022-01-31 12:42           ` Eli Zaretskii
2022-01-31 16:54             ` Alan Mackenzie
2022-01-31 17:24               ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvczk9ry7j.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).