From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Redisplay hook error bactraces [Was: Fontification error backtrace] Date: Wed, 13 Jul 2022 19:58:13 +0000 Message-ID: References: <83o7yg9f0w.fsf@gnu.org> <83r1396lvr.fsf@gnu.org> <83edz87ivz.fsf@gnu.org> <83r1375m6x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1034"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , larsi@gnus.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 13 21:59:25 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oBiW5-00008Y-39 for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Jul 2022 21:59:25 +0200 Original-Received: from localhost ([::1]:41562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBiW3-0007Eh-QB for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Jul 2022 15:59:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBiVD-0006Ps-Rk for emacs-devel@gnu.org; Wed, 13 Jul 2022 15:58:31 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:33569 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1oBiVA-0006YG-Vk for emacs-devel@gnu.org; Wed, 13 Jul 2022 15:58:30 -0400 Original-Received: (qmail 95817 invoked by uid 3782); 13 Jul 2022 19:58:17 -0000 Original-Received: from acm.muc.de (p4fe15b73.dip0.t-ipconnect.de [79.225.91.115]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 13 Jul 2022 21:58:16 +0200 Original-Received: (qmail 10583 invoked by uid 1000); 13 Jul 2022 19:58:13 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292113 Archived-At: Hello, Stefan. On Wed, Jul 13, 2022 at 15:13:41 -0400, Stefan Monnier wrote: > > + /* If an error is signalled during a Lisp hook in redisplay, write a > > + backtrace into the buffer *Backtrace*. */ > > + if (!debugger_called && !NILP (error_symbol) > > + && redisplay_lisping > > + && backtrace_on_redisplay_lisp_error > > + && (!backtrace_yet || !NILP (Vredisplay_last_error)) > > + && (NILP (clause) || h == redisplay_deep_handler) > > + && NILP (Vinhibit_debugger) > > + && !NILP (Ffboundp (Qdebug_early))) > > + { > > + max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); > > + specpdl_ref count = SPECPDL_INDEX (); > > + ptrdiff_t counti = specpdl_ref_to_count (count); > > + AUTO_STRING (backtrace, "*Backtrace*"); > > + Lisp_Object backtrace_buffer; > > + AUTO_STRING (gap, "\n\n\n\n"); /* Separates backtraces in *Backtrace* */ > I really think that printing the backtrace right when the error is > signaled is a bad idea. Better just copy the whole specpdl (or just the > backtrace part of it) and leave the buffer manipulation and printing for > later when we're back in a normal&sane context. What you suggest would imply a _lot_ of coding to make it happen. Does there exist anywhere any support for copyging a specpdl, and somehow making a lisp object out of it? Why do you think that copying the specpdl would be less work or less risky than directly generating a backtrace, as the current code does? The advantage of directly generating the backtrace is that all the infrastructure is already there. We've got mapbacktrace which encapsulates the formats of the specpdl. And debug-early.el, whose two functions total 60 lines (including doc strings and comments) and don't use any other Lisp whatsoever. > It would be worthwhile doing all this work in the context of the error > if there was an upside such as the ability to do the debugging "live", > but since this is for the case where we'll be doing a "post-mortem > debugging" anyway, we're much better off doing as little as possible in > the context of the error: too many things can go wrong when running in > the context of the error, it's asking for trouble. Again, why is copying the pdl less risky than generating the backtrace? > Stefan -- Alan Mackenzie (Nuremberg, Germany).