all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lute Kamstra <Lute.Kamstra.lists@xs4all.nl>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Problems with debug-on-entry in the Lisp debugger.
Date: Wed, 09 Mar 2005 11:14:49 +0100	[thread overview]
Message-ID: <87k6ohunvq.fsf@xs4all.nl> (raw)
In-Reply-To: <jwv6502vuzc.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 08 Mar 2005 13:59:22 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> This gives a backtrace like this:
>
>> ------ Buffer: *Backtrace* ------ 
>> Debugger entered--entering a function:
>> * (lambda (var) (if (or inhibit-debug-on-entry debugger-jumping-flag) nil (debug ...)) (list (quote setq) var (list ... var)))(x)
>>   (inc x)
>>   (progn (setq x 0) (inc x))
>>   eval((progn (setq x 0) (inc x)))
>>   eval-last-sexp-1(nil)
>>   eval-last-sexp(nil)
>>   call-interactively(eval-last-sexp)
>> ------ Buffer: *Backtrace* ------ 
>
>> where you can see the debug-entry-code (if (or inhibit-debug-on-entry
>> debugger-jumping-flag) nil (debug ...)).  I would prefer to hide the
>> internals of the debugger from its users.
>
> debug.el already hides its internals.  See debugger-setup-buffer.
> It just has to be updated to hide this part of the internals.

In this case, hiding the internals is possible.  It will be clumsy
though.  You have to search for debug-entry-code as text, which can be
abbreviated like in "(if (or inhibit-debug-on-entry
debugger-jumping-flag) nil (debug ...))".  You probably can only do
that easily for a specific example of debug-entry-code.  So the next
time debug-entry-code is changed, debug.el breaks in yet another
place.  (Remember that when you introduced the (if ...) test in
debug-entry-code, debug.el already had to be changed in 3 defuns to
compensate for this?)  So debug.el will become more difficult to
maintain.

In the other case I mentioned, hiding the debugger's internals is not
possible.  When you encounter debug-entry-code while stepping with
`d', it will not be possible to hide this.  You could hide the code
visually by deleting it from the backtrace buffer, but then the user
would still have to press `d' a couple of times (seemingly without any
effect) to step through the debug-entry-code.

>> You proposed to change defun, defsubst, defalias and defmacro to
>> add debug-entry-code when their argument was in
>> debug-function-list.  That is a similarly big change.
>
> There's no need to do that.  The hooks are already present for
> defadvice, so we should simply use them.

Hmm, I'm don't see how you can use these hooks except by using
defadvice: they seem to be designed to handle only advice.  I'd have
to change Ffset to deal with debug-on-entry.  Am I missing something?

> Better yet, we should use defadvice directly:
>
>    (defadvice <FOO> (before debug-on-entry activate)
>      (if inhibit-debug-on-entry nil (debug 'debug)))
>
> This will properly survive function redefinitions.

It does survive function redefinition.  I think this solution is worse
than the problem it tries to solve, however.  The defadvice changes a
function definition quite a bit.  The hapless debugger user might not
recognize his own function anymore:

(defun fun () "Return one." 1)
(symbol-function 'fun)
  => (lambda nil "Return one." 1)
(defadvice fun (before debug-on-entry activate)
  (if inhibit-debug-on-entry nil (debug 'debug)))
(symbol-function 'fun)
  => (lambda nil "$ad-doc: fun$" 
       (let (ad-return-value) 
	 (if inhibit-debug-on-entry 
	     nil 
	   (debug (quote debug))) 
	 (setq ad-return-value (ad-Orig-fun)) 
	 ad-return-value))

Stepping through this will cause some confusion, I think.  Can you
think of an easy way to hide the debugger's internals when you use
advice like this?

Lute.

  reply	other threads:[~2005-03-09 10:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-07 11:05 Problems with debug-on-entry in the Lisp debugger Lute Kamstra
2005-03-07 13:31 ` Stefan Monnier
2005-03-07 15:20   ` Lute Kamstra
2005-03-07 16:32     ` Stefan Monnier
2005-03-08 18:57       ` Lute Kamstra
2005-03-09 16:58         ` Richard Stallman
2005-03-09 17:30           ` Lute Kamstra
2005-03-07 13:40 ` Kim F. Storm
2005-03-07 14:20   ` drkm
2005-03-07 14:45     ` Kim F. Storm
2005-03-08  2:53 ` Richard Stallman
2005-03-08 18:02   ` Lute Kamstra
2005-03-08 18:59     ` Stefan Monnier
2005-03-09 10:14       ` Lute Kamstra [this message]
2005-03-09 16:58     ` Richard Stallman
2005-03-09 16:58     ` Richard Stallman
2005-03-09 17:38       ` Lute Kamstra
2005-03-10  0:26       ` Kevin Rodgers
2005-03-11  1:47         ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k6ohunvq.fsf@xs4all.nl \
    --to=lute.kamstra.lists@xs4all.nl \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.