From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lute Kamstra Newsgroups: gmane.emacs.devel Subject: Re: Lisp debugger problems. Date: Mon, 28 Feb 2005 02:37:21 +0100 Message-ID: <87u0nxcvn2.fsf@xs4all.nl> References: <878y5eke1b.fsf@xs4all.nl> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1109554431 2070 80.91.229.2 (28 Feb 2005 01:33:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Feb 2005 01:33:51 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 28 02:33:51 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D5Zn7-0000Xs-1o for ged-emacs-devel@m.gmane.org; Mon, 28 Feb 2005 02:33:45 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D5a5N-0002hg-Ak for ged-emacs-devel@m.gmane.org; Sun, 27 Feb 2005 20:52:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D5a55-0002cR-Rj for emacs-devel@gnu.org; Sun, 27 Feb 2005 20:52:19 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D5a4x-0002aY-UP for emacs-devel@gnu.org; Sun, 27 Feb 2005 20:52:14 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D5a4u-0002a8-Nu for emacs-devel@gnu.org; Sun, 27 Feb 2005 20:52:09 -0500 Original-Received: from [194.109.24.21] (helo=smtp-vbr1.xs4all.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D5Zqc-0000eP-5N for emacs-devel@gnu.org; Sun, 27 Feb 2005 20:37:22 -0500 Original-Received: from pijl (a80-127-67-124.adsl.xs4all.nl [80.127.67.124]) by smtp-vbr1.xs4all.nl (8.12.11/8.12.11) with ESMTP id j1S1bKpm020933 for ; Mon, 28 Feb 2005 02:37:20 +0100 (CET) (envelope-from Lute.Kamstra@xs4all.nl) Original-Received: from lute by pijl with local (Exim 3.36 #1 (Debian)) id 1D5Zqb-0001je-00 for ; Mon, 28 Feb 2005 02:37:21 +0100 Original-To: emacs-devel@gnu.org In-Reply-To: <878y5eke1b.fsf@xs4all.nl> (Lute Kamstra's message of "Thu, 24 Feb 2005 01:16:48 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Original-Lines: 79 X-Virus-Scanned: by XS4ALL Virus Scanner X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:33903 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:33903 Lute Kamstra writes: [...] > A second problem I encountered is with debugger-jump. It is currently > not documented in the lisp manual so I'm trying to figure out what it > does. From what I understand, it is intended to work just like > debugger-continue with the difference that it temporarily cancels the > effect of debug-on-entry for all functions. This is not the case > however: > > (defun funa () 1) > (debug-on-entry 'funa) > (funa) > > enters the debugger: > > ------ Buffer: *Backtrace* ------ > Debugger entered--entering a function: > * funa() > eval((funa)) > eval-last-sexp-1(nil) > eval-last-sexp(nil) > call-interactively(eval-last-sexp) > ------ Buffer: *Backtrace* ------ > > When I now press j to invoke debugger-jump, I see: > > ------ Buffer: *Backtrace* ------ > Debugger entered--returning value: nil > funa() > eval((funa)) > eval-last-sexp-1(nil) > eval-last-sexp(nil) > call-interactively(eval-last-sexp) > ------ Buffer: *Backtrace* ------ > > I would expect a return value of 1. When I press c instead of j (to > invoke debugger-continue), the debugger does give a return value of 1. > Is this a bug? I investigated this problem a bit more. It seems that the bug only happens when the body of a function contains just one sexp. For example, when I do: (defun fun (a) "Docstring." (interactive) (1+ a)) (debug-on-entry 'fun) (fun 1) to enter the debugger and then type j to invoke debugger-jump, then the return value is nil (wrong). But when I do: (defun fun (a) "Docstring." (interactive) a (1+ a)) (debug-on-entry 'fun) (fun 1) to enter the debugger and then type j to invoke debugger-jump, then the return value is 2 (right). debug-on-entry inserts (debug 'debug) into the definition of fun: (defun fun (a) "Docstring." (interactive) (1+ a)) (symbol-function 'fun) => (lambda (a) "Docstring." (interactive) (1+ a)) (debug-on-entry 'fun) (symbol-function 'fun) => (lambda (a) "Docstring." (interactive) (debug (quote debug)) (1+ a)) So when fun is called, it invokes the debugger. Then the debugger calls debugger-jump, which changes the definition of fun by removing (debug 'debug). So the definition of fun is changed in the middle of a call to fun. My guess is that this somehow confuses the lisp interpreter (in case the body of fun consists of just one sexp) and causes it to produce the wrong return value. Maybe somebody with more experience with the lisp interpreter's internals can debug this further? Lute.