From: deech
Subject: Newbie: Following Execution of a Lisp Program
Date: 
Message-ID: <1185553156.132653.219770@m37g2000prh.googlegroups.com>
Hi all,
I am new to Lisp and trying to understand some example programs I
found on the 'net. I have a Slime+SBCL setup.

Is there any way to execute a lisp program through slime and have
slime tell me which line of code is being executed at each step?
Across multiple files?

Thanks....
Deech

From: ··@codeartist.org
Subject: Re: Newbie: Following Execution of a Lisp Program
Date: 
Message-ID: <1185559763.791859.274390@22g2000hsm.googlegroups.com>
On 27 Jul., 18:19, deech <············@gmail.com> wrote:
> Hi all,
> I am new to Lisp and trying to understand some example programs I
> found on the 'net. I have a Slime+SBCL setup.
>
> Is there any way to execute a lisp program through slime and have
> slime tell me which line of code is being executed at each step?
> Across multiple files?
>
> Thanks....
> Deech

I don't know if there is stepper support in Slime, but you
could try LispWorks Personal Edition from http://www.lispworks.com.
It contains a really good integrated source-level stepper.

ciao,
Jochen
From: Thomas Russ
Subject: Re: Newbie: Following Execution of a Lisp Program
Date: 
Message-ID: <ymisl791wts.fsf@tubular.isi.edu>
Well a more general solution, which isn't quite as detailed as using a
stepper is to use the Common Lisp standard TRACE facility.  You can
tell it to trace particular functions and then it will print the entry
and exit values.

That may be good enough for your purposes.

Of course, to get the best understanding, it may help to either hand
simulate the code, or execute bits of it in the lisp listener.
From: Rainer Joswig
Subject: Re: Newbie: Following Execution of a Lisp Program
Date: 
Message-ID: <joswig-1E90CE.22280227072007@news-europe.giganews.com>
In article <···············@tubular.isi.edu>,
 Thomas Russ <···@tubular.isi.edu> wrote:

> Well a more general solution, which isn't quite as detailed as using a
> stepper is to use the Common Lisp standard TRACE facility.  You can
> tell it to trace particular functions and then it will print the entry
> and exit values.
> 
> That may be good enough for your purposes.
> 
> Of course, to get the best understanding, it may help to either hand
> simulate the code, or execute bits of it in the lisp listener.

LispWorks has other nice features, btw. You can go
into the debugger and it finds and highlights the expression
in the source, where it currently halts (for stack frames).
This can also used with breakpoints.

-- 
http://lispm.dyndns.org
From: D Herring
Subject: Re: Newbie: Following Execution of a Lisp Program
Date: 
Message-ID: <CqCdncIqS7FDKzfbnZ2dnUVZ_rignZ2d@comcast.com>
deech wrote:
> Hi all,
> I am new to Lisp and trying to understand some example programs I
> found on the 'net. I have a Slime+SBCL setup.
> 
> Is there any way to execute a lisp program through slime and have
> slime tell me which line of code is being executed at each step?
> Across multiple files?

SBCL has some tools to help with that:
http://www.sbcl.org/manual/Single-Stepping.html
http://www.sbcl.org/manual/Source-Location-Printing.html

Slime has another interface for this:
http://common-lisp.net/project/slime/doc/html/Debugger.html

Here's an example session:

;; In test.lisp
(defun test (x y)
   (declare (optimize (debug 3)
                      (safety 3)
                      (space 0)
                      (speed 0)))
   (break) ; trigger the debugger
   (+ x y)
   (* x y)
   (- 5 x y))
#|
use C-c C-c to compile this function (so slime knows where the 
definition is)
|#

;; In the repl (or at the C-c C-e prompt)
(test 3 4)

;; Type these in the Slime debug window
n ; moves to the next stack frame (1)
t ; toggle shows/hides the local variables
v ; shows the current frame's definition
B ; drops you into the SBCL debugger
backtrace 3
frame 1
l ; lists the local variables
frame 0
start ; starts single-step mode -- Slime picks up on this
v
2
v
2
v
0 ; continue to end

- Daniel
From: Juho Snellman
Subject: Re: Newbie: Following Execution of a Lisp Program
Date: 
Message-ID: <slrnfam3s0.tb8.jsnell@sbz-30.cs.Helsinki.FI>
D Herring <········@at.tentpost.dot.com> wrote:
> ;; In the repl (or at the C-c C-e prompt)
> (test 3 4)
>
> ;; Type these in the Slime debug window
> n ; moves to the next stack frame (1)
> t ; toggle shows/hides the local variables
> v ; shows the current frame's definition
> B ; drops you into the SBCL debugger
> backtrace 3
> frame 1
> l ; lists the local variables
> frame 0
> start ; starts single-step mode -- Slime picks up on this

You don't actually need to drop down to the SBCL debugger to do this,
but can just use the "s" command in sldb for any condition that has a
CONTINUE restart.

> v
> 2

The appropriate restarts can also be selected using sldb commands ("s"
-> step, "x" -> next, "o" -> out). There also shouldn't be any need to
manually press "v" to view the source, it should doing that
automatically when stepping.

And finally, this is unfortunately best used with sbcl 1.0.5 but not
later, since there's a bug in saving source location information in
later versions which I haven't gotten around to fixing yet. So in
later sbcl versions Slime will generally be highlighting the wrong
form.

-- 
Juho Snellman