[slime-devel] Jump to source code

Helmut Eller e9626484 at stud3.tuwien.ac.at
Thu Mar 17 11:55:16 UTC 2005


hww <hww at inbox.ru> writes:

> Course emacs teels me abou error.  Then via debugging frame and
> commands 'M-n',  'M-p'    or  'v'  I can position to source code for
> the all frames. But no way to point at the 'test.l' file.
>
> Why?

Well, because you work in an unusual way and because your code has a
very unusual bug.

> Or how i can from eror message jump to position of this error in a
> source code?

Most people compile the source file and load the fasl file instead of
the source file.  If you load the source file, compiling, loading, and
execution are interleaved and debugging becomes harder. So far, nobody
has invested a lot of effort to make this situation easy to debug.

The usual (well, at least my) way to work is as follows:

1. write your code in a file
2. write definitions (not random code at toplevel)
3. compile a function with C-c C-c or an entire file with C-c C-k.
4. test little bits of code with C-x C-e or in the REPL

So I'd write your code like so:

(defun foo ()
  (+ 1 2)
  (+ 3 "4"))

(foo)

Then type C-c C-c inside of foo and the compiler will say "Asserted
type number conflicts with derived type ..." and M-n/M-p will bring
you to the source form.  

To test the function press C-x C-e after the (foo) line.  In CMUCL,
the backtrace looks like:

  0: (kernel:two-arg-+ 3 "4")
  1: (+ 3 "4")
  2: ("defslimefun interactive-eval")
  
Pressing v on frame 1 and will bring you the source in the file
numbers.lisp.  Unfortunately, tailcall optimization has removed the
frame for foo.  If you suppress tailcall optimization, e.g., with
(declaim (optimize (debug 3))), the backtrace will have a frame for
foo an v should bring you to the source.

The v command doesn't work so well in SBCL because no one has
implemented compile-from-stream yet and only minimal debug info is
generated with the default compiler settings.  Please file a bug
report to the SBCL developers about this issue :)

When compiling with C-c C-k, CMUCL removes the code entirely.  Dunno
why; perhaps a bug or maybe because + doesn't have side effects.

In general, you have to know a little about what kind of debugging
works best with your implementation and tell the compiler to emit
debugging info.  Most debugging features in SLIME are biased towards
CMUCL, because, well, nobody did the polishing for the other
implementations.

Helmut.



More information about the slime-devel mailing list