From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.devel Subject: Re: Backtrace printing in batch mode ignores all customizations Date: Sat, 21 Dec 2019 18:07:33 +0100 Message-ID: References: <83tv5uyqwq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="207441"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Emacs developers To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 21 18:07:58 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iiiEP-000rp0-Si for ged-emacs-devel@m.gmane.org; Sat, 21 Dec 2019 18:07:58 +0100 Original-Received: from localhost ([::1]:41044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiiEO-0004hv-OL for ged-emacs-devel@m.gmane.org; Sat, 21 Dec 2019 12:07:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38424) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiiEH-0004hc-Qw for emacs-devel@gnu.org; Sat, 21 Dec 2019 12:07:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiiEG-0004kB-Ie for emacs-devel@gnu.org; Sat, 21 Dec 2019 12:07:49 -0500 Original-Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:50376) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiiEE-0004YL-KU; Sat, 21 Dec 2019 12:07:46 -0500 Original-Received: by mail-wm1-x331.google.com with SMTP id a5so11915977wmb.0; Sat, 21 Dec 2019 09:07:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fuRVuxbPNvrPbCxiMuaK7qZqrmXyVTnKlh7swHUSX4A=; b=MOAdczODTMKJMAW49kdYe4F58/7omaBBtM9+2TGYblwzoX0JBggu7NXkNNPDVc8UZP nJeQ3Q/0UchEpZG2UKz451uLyNVrm0hhRgKvqr9/ubGXac0tXYzy/JlEzxWyPfJ5Spkw bWHGGeQoMJtRmbxbrB5h1z0txsLVuTms951L5SBoEOMfLCI8+XXOJsqcCWiKnpj233E2 mtwpjbhDoWuZcRysNgf8GUhRdXJ3xN5/D3RhYQnRjXHL3IFRO9NZcEwD3kaMurfgJXAR LMTr4m+JBAauniezgafVLORbTkakSnbfGZ7txj7ATMeuQj/cPibPjD038lyiVFEa7Ck9 UgfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fuRVuxbPNvrPbCxiMuaK7qZqrmXyVTnKlh7swHUSX4A=; b=WYNdlvzlKm5k4FYp0CssjVArwCyDRUAjzYlIZytiVIdRGM07t9sKPiZ29mYbHjf2oS xLnbVrK65DeDN6rAObwJ5LnhRuh+06n3A6e/0Yv0jVS47nUEGeZcIBYAvNQw3y/l4Hon R/IpFOrdI4Ze2N0OZqagK4fu9/lssxCCXw7WFopeLPt2e4gGLJGQWNRToH72DMLnvkQH d3COIRkqT0dRu/MUE26aFt9OlF9SgzWO2uka4rmepRjMaDaY6J83PWB9GXV4TnSWOFEs YZxaCpHhGYwaB6gWHUKwwOQ5YMiEU/xI8qGQiUja65Q5uPLiyeIBAy/jh6ghaE820cIZ 5whg== X-Gm-Message-State: APjAAAW7Pa2+UhZ5JKk5fJmRvGsOJVrWTCX0s+YR9slLc/x/b2fFUvx0 e+oqXSWyPch29FZJJR8SBjWVotZa3hxd8JS2vBhmJPs= X-Google-Smtp-Source: APXvYqzeSvBp0wJMfQ4hWMjrTgLNdc7gtLcyl3tziwpOjLnJlCQxWr7Nwctmturqf+JYtAMpjnggX8+UaXt06svnEUI= X-Received: by 2002:a7b:c183:: with SMTP id y3mr23198643wmi.0.1576948064657; Sat, 21 Dec 2019 09:07:44 -0800 (PST) In-Reply-To: <83tv5uyqwq.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243538 Archived-At: It's not really about _my_ customizations. Basically, this "failsafe" mode in `debug' bypasses even e.g. built-in Emacs `debugger-print-function'. Here is an example (it has nothing to do with `registry', I just needed some EIEIO class to illustrate): $ emacs -Q --batch --eval "(let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db)))" Error: (error (void-variable bar)) (foo #s(registry-db unbound nil 2305843009213693951 0.1 nil nil #s(hash-table size 100 test eql rehash-size 2.0 rehash-threshold 0.8125 data ( ...)) #s(hash-table size 10000 test equal rehash-size 2.0 rehash-threshold 0.8125 data ( ...)))) (let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db))) (eval (let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db))) t) (command-line-1 ("--eval" "(let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db)))")) (command-line) (normal-top-level) And now with a workaround that disables this "failsafe" mode: $ emacs -Q --batch --eval "(advice-add 'terminal-name :override (lambda () \"workaround\"))" --eval "(let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db)))" Debugger entered--Lisp error: (void-variable bar) foo(#) (let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db))) eval((let ((debug-on-error t)) (require 'registry) (defun foo (x) bar) (foo (registry-db))) t) command-line-1(("--eval" "(advice-add 'terminal-name :override (lambda () \"w..." "--eval" "(let ((debug-on-error t)) (require 'registry) (def...")) command-line() normal-top-level() Without the workaround, `debugger-print-function' (i.e. `cl-prin1') is never called and in the second line of output you can see "#s(registry-db ..."). With the workaround `cl-prin1' is called where it should be, and you can see "# wrote: > > > From: Paul Pogonyshev > > Date: Mon, 16 Dec 2019 23:34:42 +0100 > > > > + ((and (eq t (framep (selected-frame))) > > + (equal "initial_terminal" (terminal-name))) > > + ;; We're in the initial-frame (where `message' just outputs to stdout) so > > + ;; there's no tty or GUI frame to display the backtrace and interact with > > + ;; it: just dump a backtrace to stdout. > > + ;; This happens for example while handling an error in code from > > + ;; early-init.el with --debug-init. > > + (message "Error: %S" args) > > [...] > > > > The condition seems to always be true when `noninteractive' is t. Is > > this intentional? It appears to mean that all debug/backtrace > > customizations in batch mode are meaningless, since debugger just goes > > the "failsafe" route and prints backtrace with simple `message' calls > > now. > > Can you please elaborate about the debug/backtrace customizations you > did, which are bypassed due to this code? What are those > customizations supposed to do?