emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lisp debugger problems.


From: Lute Kamstra
Subject: Re: Lisp debugger problems.
Date: Mon, 28 Feb 2005 02:37:21 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Lute Kamstra <address@hidden> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]