all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Tobias C. Rittweiler" <tcr@freebits.de>
To: emacs-devel@gnu.org
Subject: Backtraces to use macro information from edebug-specs?
Date: Fri, 13 Feb 2009 22:40:04 +0100	[thread overview]
Message-ID: <87y6waow23.fsf@freebits.de> (raw)


Let's take the following code

  (defun foo (list)
    (destructuring-bind (key slot1 slot2) list
      (case key
        (:foo (quux slot1)
              (:bar (quux slot2))))))

  (defun quux (x)
    (error "QUUX -- %S" x))

Now evaluating

  (foo '(:foo 23 42))

results in the following backtrace

  Debugger entered--Lisp error: (error "QUUX -- 23")
    signal(error ("QUUX -- 23"))
    error("QUUX -- %S" 23)
    quux(23)
    (cond ((eql key ...) (quux slot1) (:bar ...)))
    (case key (:foo (quux slot1) (:bar ...)))
    (let* ((--cl-rest-- list) (key ...) (slot1 ...) (slot2 ...)) (case ...)
    (progn (let* (... ... ... ...) (case key ...)))
    (destructuring-bind (key slot1 slot2) list (case key (:foo ... ...)))
    foo((:foo 23 42))

Given the information form edebug-specs (which are defined for all `cl'
macros), it may perhaps be possible to find out that

  `quux(23)' comes from the body of case, but `(cond ((eql ...' doesn't.

  `(case key ...' appears in the body of destructuring-bind, but the
  `(let* ... ' and `(progn ...' do not.

As a result the backtrace could be presented as follows

  Debugger entered--Lisp error: (error "QUUX -- 23")
    signal(error ("QUUX -- 23"))
    error("QUUX -- %S" 23)
    quux(23)
      (cond ((eql key ...) (quux slot1) (:bar ...)))
    (case key (:foo (quux slot1) (:bar ...)))
      (let* ((--cl-rest-- list) (key ...) (slot1 ...) (slot2 ...)) (case ...)
      (progn (let* (... ... ... ...) (case key ...)))
    (destructuring-bind (key slot1 slot2) list (case key (:foo ... ...)))
    foo((:foo 23 42))

Of course, they may be better ways to do this, depending on how much
debug information is available.

Has anyone worked on something like that?

  -T.





             reply	other threads:[~2009-02-13 21:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-13 21:40 Tobias C. Rittweiler [this message]
2009-02-14  1:53 ` Backtraces to use macro information from edebug-specs? Stefan Monnier

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=87y6waow23.fsf@freebits.de \
    --to=tcr@freebits.de \
    --cc=emacs-devel@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.