From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#36145: 26.2; Unable to "trigger another backtrace" Date: Fri, 21 Jun 2019 08:21:10 -0400 Message-ID: <87h88juo21.fsf@gmail.com> References: <87o9370x44.fsf@gmail.com> <87a7eq21xo.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="150044"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 36145@debbugs.gnu.org To: Xu Chunyang Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 21 14:22:54 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1heIZ8-000cm4-4l for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Jun 2019 14:22:50 +0200 Original-Received: from localhost ([::1]:60914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heIZ6-0002C4-1B for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Jun 2019 08:22:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33867) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heIYW-0002B4-L0 for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2019 08:22:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1heIYM-0006q9-06 for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2019 08:22:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1heIYL-0006pt-TV for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2019 08:22:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1heIYL-0006ks-Nm for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2019 08:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jun 2019 12:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36145 X-GNU-PR-Package: emacs Original-Received: via spool by 36145-submit@debbugs.gnu.org id=B36145.156111968225913 (code B ref 36145); Fri, 21 Jun 2019 12:22:01 +0000 Original-Received: (at 36145) by debbugs.gnu.org; 21 Jun 2019 12:21:22 +0000 Original-Received: from localhost ([127.0.0.1]:49845 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1heIXi-0006jo-28 for submit@debbugs.gnu.org; Fri, 21 Jun 2019 08:21:22 -0400 Original-Received: from mail-io1-f43.google.com ([209.85.166.43]:35421) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1heIXe-0006jR-VI; Fri, 21 Jun 2019 08:21:20 -0400 Original-Received: by mail-io1-f43.google.com with SMTP id m24so809996ioo.2; Fri, 21 Jun 2019 05:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=eaUBos5j0nUbkYs/4pGrgCH7FHn5uUnMyv5iOr4U+A8=; b=lZ1zDh9t9nKQzlUWd4f2k+9BdR2I71ddvhsNYWVN8U8SZ6sfnbsbLAAsSFhu7g2P+I 8p4CTk8X2Z38SEBmy1EO/5fVNhygGwTtHn+XOvGxY5dbpkotH8u6Hq65UJBcrnypbl5+ pLmJ+NNBj95DohubnlOKwIF0y/c3nec8sQOG86JOkRTodKf7vQj7CRwzBwF7JPTMElPE 0FRX24C6MQJtbblqvOEU3kvq7XE5OxDCcqakFrIMOQefDcRH0uVmIu8DUF35h3wYHsDn ndFerZ56GuxRSJB4M2RdjU02IPWWqvSmqMbwbg0EBk5KEPMKH/iMEHHJkcBVEs6ouQ/H tlgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=eaUBos5j0nUbkYs/4pGrgCH7FHn5uUnMyv5iOr4U+A8=; b=S665QI3f7vB/4eMxQMjbznAG1wHjvSd206nnEtJXTwZtfgKRUfALeO5zhanOYeH7Z5 glrtfA55Ky3J6wU69A4tmx8xr91T1yHr15M0HIdPJJzKzt3Q2+aIowvllk0FX+CAJFkq G36WhEqbGUmTfa2EKiGD1Kle6knu5yPmUQAaRIHPyeHOlJLc26BVfttvM/AWhdYGRrbn y48LC3pTbqk3M8zvOG5a3YJZT7cuMlMsAOpU8xeA827jCBVGT5vASOtN0JW43Aqf1Sch Db8+1fQFAnw0gE8cPmlOKJp18R2hSiD7VxkDbNUYs6A9NWALMyAF8ylPTQeeanA+MbqY fZ6w== X-Gm-Message-State: APjAAAV9nPDuTKgGDk0y9oRAP3JZUvMn3Hpj8S4Q9TYPfM78MtJeLtWI v3Nbkx2t1KodsCBndEVr91+aF38c X-Google-Smtp-Source: APXvYqxqRt7F9QYkHWvKaTXdVP/t8Uf9Q7XdvIEXU8aV1dDLQe3yxAP4qqXMa5rrhTc0vh8Xh+1B+A== X-Received: by 2002:a5e:d51a:: with SMTP id e26mr826558iom.71.1561119672866; Fri, 21 Jun 2019 05:21:12 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id y18sm2682222iob.64.2019.06.21.05.21.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2019 05:21:11 -0700 (PDT) In-Reply-To: <87a7eq21xo.fsf@gmail.com> (Noam Postavsky's message of "Sun, 09 Jun 2019 11:50:11 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160939 Archived-At: --=-=-= Content-Type: text/plain severity 36145 minor tags 36145 + patch quit > Although it is possible to trigger another backtrace if the first one > was from calling `debug' directly, e.g., M-: (debug) RET. And it's also possible to trigger another backtrace with 'e', if using it from a frame above the debugger's. I bump into this every so often by accident, and it's quite annoying. Of course, I'm always in the middle of debugging something else so I forget about it, but I'd like to change it. Patch attached. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Suppress-recursive-debugger-for-e-command-Bug-36145.patch Content-Description: patch >From c6d52846598eeaf200c553ff0ac9f16db612b64e Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 21 Jun 2019 08:14:20 -0400 Subject: [PATCH] Suppress recursive debugger for 'e' command (Bug#36145) * lisp/emacs-lisp/debug.el (debugger-eval-expression): * lisp/emacs-lisp/edebug.el (edebug-eval-expression) (edebug-eval-last-sexp, edebug-eval-print-last-sexp): Suppress debugger with inhibit-debugger, unless given a prefix argument. * doc/lispref/edebug.texi (Edebug Eval): * doc/lispref/debugging.texi (Debugger Commands, Backtraces): Document new behavior. (Using Debugger): Remove incorrect paragraph about debug-on-error. * etc/NEWS: Announce new behavior. --- doc/lispref/debugging.texi | 15 ++++----------- doc/lispref/edebug.texi | 10 +++++++--- etc/NEWS | 11 +++++++++++ lisp/emacs-lisp/debug.el | 12 ++++++++---- lisp/emacs-lisp/edebug.el | 33 +++++++++++++++++++++------------ 5 files changed, 51 insertions(+), 30 deletions(-) diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index 9e43343310..7538e70ab5 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi @@ -383,16 +383,6 @@ Using Debugger rather than bury it. Consult the variable's documentation for more possibilities.) - When the debugger has been entered, the @code{debug-on-error} -variable is temporarily set according to -@code{eval-expression-debug-on-error}. If the latter variable is -non-@code{nil}, @code{debug-on-error} will temporarily be set to -@code{t}. This means that any further errors that occur while doing a -debugging session will (by default) trigger another backtrace. If -this is not what you want, you can either set -@code{eval-expression-debug-on-error} to @code{nil}, or set -@code{debug-on-error} to @code{nil} in @code{debugger-mode-hook}. - The debugger itself must be run byte-compiled, since it makes assumptions about the state of the Lisp interpreter. These assumptions are false if the debugger is running interpreted. @@ -527,7 +517,10 @@ Debugger Commands temporarily restores their values from outside the debugger, so you can examine and change them. This makes the debugger more transparent. By contrast, @kbd{M-:} does nothing special in the debugger; it shows you -the variable values within the debugger. +the variable values within the debugger. By default, this command +suppresses the debugger during evaluation, so that an error in the +evaluated expression won't add a new error on top of the existing one. +Use the prefix argument to override this. @item R Like @kbd{e}, but also save the result of evaluation in the diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index 2c0ee3969b..823a5009e8 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi @@ -681,8 +681,11 @@ Edebug Eval @table @kbd @item e @var{exp} @key{RET} Evaluate expression @var{exp} in the context outside of Edebug -(@code{edebug-eval-expression}). That is, Edebug tries to minimize its -interference with the evaluation. +(@code{edebug-eval-expression}). That is, Edebug tries to minimize +its interference with the evaluation. By default, this command +suppresses the debugger during evaluation, so that an error in the +evaluated expression won't add a new error on top of the existing one. +Use a prefix argument to override this. @item M-: @var{exp} @key{RET} Evaluate expression @var{exp} in the context of Edebug itself @@ -690,7 +693,8 @@ Edebug Eval @item C-x C-e Evaluate the expression before point, in the context outside of Edebug -(@code{edebug-eval-last-sexp}). +(@code{edebug-eval-last-sexp}). Similar to @key{e}, this command +suppresses the debugger unless a prefix argument is used. @end table @cindex lexical binding (Edebug) diff --git a/etc/NEWS b/etc/NEWS index 4a168d5678..43dc6ea969 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1074,6 +1074,11 @@ Backtrace mode adds fontification and commands for changing the appearance of backtrace frames. See the node "(elisp) Backtraces" in the Elisp manual for documentation of the new mode and its commands. ++++ +*** Recursive debugging is suppressed by default for 'e'. +That is bound to the command 'debug-eval-expression'. Use a prefix +argument to override this. + ** Edebug +++ @@ -1098,6 +1103,12 @@ The new 'backtrace-goto-source' command, bound to 's', works in Edebug's backtraces on backtrace frames whose source code has been instrumented by Edebug. ++++ +*** Backtrace debugging is suppressed by default for 'e' and 'C-x C-e'. +Those are bound to the commands 'edebug-eval-expression' and +'edebug-eval-last-sexp', respectively. Use a prefix argument to +override this. + ** Enhanced xterm support *** New variable 'xterm-set-window-title' controls whether Emacs sets diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 8989aa0719..20aceccb68 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -516,17 +516,21 @@ (defun debugger--backtrace-base () 'debug--implement-debug-on-entry) (t 'debug))) -(defun debugger-eval-expression (exp &optional nframe) +(defun debugger-eval-expression (exp &optional nframe allow-recursive-debug) "Eval an expression, in an environment like that outside the debugger. -The environment used is the one when entering the activation frame at point." +The environment used is the one when entering the activation frame at point. +With a prefix argument, errors signaled while evaluating may +trigger the debugger again." (interactive - (list (read--expression "Eval in stack frame: "))) + (list (read--expression "Eval in stack frame: ") + nil current-prefix-arg)) (let ((nframe (or nframe (condition-case nil (1+ (debugger-frame-number 'skip-base)) (error 0)))) ;; If on first line. (base (debugger--backtrace-base))) (debugger-env-macro - (let ((val (backtrace-eval exp nframe base))) + (let ((val (let ((inhibit-debugger (not allow-recursive-debug))) + (backtrace-eval exp nframe base)))) (prog1 (debugger--print val t) (let ((str (eval-expression-print-format val))) diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index ab5553b4e8..1f9d994fed 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -3580,28 +3580,37 @@ (defalias 'edebug-prin1-to-string #'cl-prin1-to-string) (defalias 'edebug-format #'format-message) (defalias 'edebug-message #'message) -(defun edebug-eval-expression (expr) +(defun edebug-eval-expression (expr &optional allow-debugger) "Evaluate an expression in the outside environment. If interactive, prompt for the expression. -Print result in minibuffer." - (interactive (list (read--expression "Eval: "))) +Print result in minibuffer. +With a prefix argument, errors signaled while evaluating may +trigger the debugger." + (interactive (list (read--expression "Eval: ") + current-prefix-arg)) (princ (edebug-outside-excursion - (setq values (cons (edebug-eval expr) values)) + (push (let ((inhibit-debugger (not allow-debugger))) + (edebug-eval expr)) + values) (concat (edebug-safe-prin1-to-string (car values)) (eval-expression-print-format (car values)))))) -(defun edebug-eval-last-sexp () +(defun edebug-eval-last-sexp (&optional allow-debugger) "Evaluate sexp before point in the outside environment. -Print value in minibuffer." - (interactive) - (edebug-eval-expression (edebug-last-sexp))) +Print value in minibuffer. +With a prefix argument, errors signaled while evaluating may +trigger the debugger." + (interactive "P") + (edebug-eval-expression (edebug-last-sexp allow-debugger))) -(defun edebug-eval-print-last-sexp () +(defun edebug-eval-print-last-sexp (&optional allow-debugger) "Evaluate sexp before point in outside environment; insert value. -This prints the value into current buffer." - (interactive) - (let* ((form (edebug-last-sexp)) +This prints the value into current buffer. +With a prefix argument, errors signaled while evaluating may +trigger the debugger." + (interactive "P") + (let* ((form (edebug-last-sexp allow-debugger)) (result-string (edebug-outside-excursion (edebug-safe-prin1-to-string (edebug-safe-eval form)))) -- 2.11.0 --=-=-=--