Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to "single-step" in slime+emacs

391 views
Skip to first unread message

Mirko....@gmail.com

unread,
May 28, 2008, 10:38:03 AM5/28/08
to
Hello,

(using :editor emacs :editor-package slime :lisp sbcl :platform
linux).
(Consider :following-code)


(declaim (optimize (safety 3)) (optimize (debug 3)) (optimize (speed
0)))

(defun callee (arg1 arg2 arg3)
(let ((combo (+ arg1 arg2 arg3)))
(break "first")
(sin (* pi combo))
(break "second ~f" combo)))

(defun caller ()
(callee 1 2 3))

(sheepishly),  How can I step from caller into callee? I've been
trying to figure it out and read up on it, but to no avail.

(The break statements are from other experiments that eliminated some
other silly questions)

Thank you,

Mirko

Pascal J. Bourguignon

unread,
May 28, 2008, 11:14:32 AM5/28/08
to
Mirko....@gmail.com writes:

> Hello,
>
> (using :editor emacs :editor-package slime :lisp sbcl :platform
> linux).
> (Consider :following-code)
>
>
> (declaim (optimize (safety 3)) (optimize (debug 3)) (optimize (speed
> 0)))
>
> (defun callee (arg1 arg2 arg3)
> (let ((combo (+ arg1 arg2 arg3)))
> (break "first")
> (sin (* pi combo))
> (break "second ~f" combo)))
>
> (defun caller ()
> (callee 1 2 3))
>
> (sheepishly),  How can I step from caller into callee? I've been
> trying to figure it out and read up on it, but to no avail.

First you'd use STEP :

(step (caller))

then, using the native debugger, you'd step "in", instead of stepping
"over". In clisp that'd be: step or :s

Yep, it looks like it's not possible to do it in slime, from the
documentation of sldb at:
http://common-lisp.net/project/slime/doc/html/Miscellaneous.html#Miscellaneous

--
__Pascal Bourguignon__

Peter Hildebrandt

unread,
May 28, 2008, 11:26:24 AM5/28/08
to
Pascal J. Bourguignon wrote:

> Yep, it looks like it's not possible to do it in slime, from the
> documentation of sldb at:
> http://common-lisp.net/project/slime/doc/html/Miscellaneous.html#Miscellaneous

???

(defun myfn () (print 'hallo))
(step (myfn))

--->

Evaluating call:
(MYFN)
With arguments:


[Condition of type SB-EXT:STEP-FORM-CONDITION]

Restarts:
0: [STEP-CONTINUE] Resume normal execution
1: [STEP-OUT] Resume stepping after returning from this function
2: [STEP-NEXT] Step over call
3: [STEP-INTO] Step into call
4: [ABORT] Return to SLIME's top level.
5: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread"
{B15B4C9}>)

Backtrace:
0: (NIL)
1: (SB-INT:SIMPLE-EVAL-IN-LEXENV
(LET ((SB-IMPL::*STEP-OUT* :MAYBE))
(UNWIND-PROTECT (SB-IMPL::WITH-STEPPING-ENABLED #)))
#S(SB-KERNEL:LEXENV
:FUNS NIL
:VARS NIL
:BLOCKS NIL
:TAGS NIL
:TYPE-RESTRICTIONS NIL
:LAMBDA NIL ..))

Juho Snellman

unread,
May 28, 2008, 11:36:07 AM5/28/08
to
Mirko....@gmail.com writes:

> Hello,
>
> (using :editor emacs :editor-package slime :lisp sbcl :platform
> linux).
> (Consider :following-code)
>
>
> (declaim (optimize (safety 3)) (optimize (debug 3)) (optimize (speed
> 0)))
>
> (defun callee (arg1 arg2 arg3)
> (let ((combo (+ arg1 arg2 arg3)))
> (break "first")
> (sin (* pi combo))
> (break "second ~f" combo)))
>
> (defun caller ()
> (callee 1 2 3))
>
> (sheepishly),  How can I step from caller into callee? I've been
> trying to figure it out and read up on it, but to no avail.

First ensure that you enter the debugger when calling CALLER. For
example by doing (trace caller :break t), or by adding an explicit
BREAK into the source code.

Once in the debugger, press "s" to enter the stepper. From there you
can use "s" to step into the call, "x" to step over the call, or "o"
to step out of the function that's currently being executed.

--
Juho Snellman

Pascal J. Bourguignon

unread,
May 28, 2008, 12:17:47 PM5/28/08
to
Peter Hildebrandt <peter.hi...@gmail.com> writes:

> Pascal J. Bourguignon wrote:
>
>> Yep, it looks like it's not possible to do it in slime, from the
>> documentation of sldb at:
>> http://common-lisp.net/project/slime/doc/html/Miscellaneous.html#Miscellaneous
>
> ???
>
> (defun myfn () (print 'hallo))
> (step (myfn))
>
> --->
>
> Evaluating call:
> (MYFN)
> With arguments:
>
>
> [Condition of type SB-EXT:STEP-FORM-CONDITION]
>
> Restarts:
> 0: [STEP-CONTINUE] Resume normal execution

With clisp, and the version of slime I have here, it doesn't work.
Granted, it's rather "old"... I'll have to update it.

--
__Pascal Bourguignon__

Mirko....@gmail.com

unread,
May 28, 2008, 12:31:06 PM5/28/08
to
On May 28, 11:36 am, Juho Snellman <jsn...@iki.fi> wrote:

I get an error when I try to use "s", "x", or "o". The last two are
not assigned to any emacs commands, while pressing "s" results in

No continue restart.
[Condition of type SIMPLE-ERROR]

Restarts:
0: [ABORT] Return to sldb level 1.
1: [ABORT-REQUEST] Abort handling SLIME request.
2: [ABORT] Exit debugger, returning to top level.


I may need to update my slime setup.

Thank you to all of you. This will make life much simpler.

Mirko

Peter Hildebrandt

unread,
May 28, 2008, 4:28:55 PM5/28/08
to
Mirko....@gmail.com wrote:
> On May 28, 11:36 am, Juho Snellman <jsn...@iki.fi> wrote:
trying to figure it out and read up on it, but to no avail.
>> First ensure that you enter the debugger when calling CALLER. For
>> example by doing (trace caller :break t), or by adding an explicit
>> BREAK into the source code.
>>
>> Once in the debugger, press "s" to enter the stepper. From there you
>> can use "s" to step into the call, "x" to step over the call, or "o"
>> to step out of the function that's currently being executed.

I believe these are the bindings when using SBCL directly.

When using slime, the key bindings are different, eg.

0: [STEP-CONTINUE] Resume normal execution

1: [STEP-OUT] Resume stepping after returning from this function
2: [STEP-NEXT] Step over call
3: [STEP-INTO] Step into call

This is with SBCL 1.0.11 and a SLIME from CVS.from some time mid 2007.

Peter

Juho Snellman

unread,
May 28, 2008, 5:08:16 PM5/28/08
to
Peter Hildebrandt <peter.hi...@gmail.com> writes:

> Mirko....@gmail.com wrote:
> > On May 28, 11:36 am, Juho Snellman <jsn...@iki.fi> wrote:
> trying to figure it out and read up on it, but to no avail.
> >> First ensure that you enter the debugger when calling CALLER. For
> >> example by doing (trace caller :break t), or by adding an explicit
> >> BREAK into the source code.
> >>
> >> Once in the debugger, press "s" to enter the stepper. From there you
> >> can use "s" to step into the call, "x" to step over the call, or "o"
> >> to step out of the function that's currently being executed.
>
> I believe these are the bindings when using SBCL directly.

I believe that you're not right about that, as SBCL has no
"keybindings". And those are the keybindings I added into Slime. It's
of course possible that somebody has removed them in the last couple
of years.

> When using slime, the key bindings are different, eg.
>
> 0: [STEP-CONTINUE] Resume normal execution
> 1: [STEP-OUT] Resume stepping after returning from this function
> 2: [STEP-NEXT] Step over call
> 3: [STEP-INTO] Step into call
>
> This is with SBCL 1.0.11 and a SLIME from CVS.from some time mid 2007.

Those aren't keybindings, that's a restart menu (SBCL communicates
with the stepper, whether the one in Slime or the SBCL debugger, via
conditions and restarts). You can of course use the restarts directly
if you insist, rather than using the commands I listed. There are
however a number of downsides to using the restarts:

* They might move around, if eg. the SBCL stepper is changed, which
would be bad if you've gotten into a habit of pressing eg. "3"
instead of "s".
* They would obviously not be available at all on Lisp
implementations where the stepper doesn't use conditions. This
doesn't matter too much, since most other lisps don't have
single stepping support in Slime.

--
Juho Snellman

Peter Hildebrandt

unread,
May 28, 2008, 5:54:50 PM5/28/08
to
Juho Snellman wrote:

> Peter Hildebrandt <peter.hi...@gmail.com> writes:
>>>> Once in the debugger, press "s" to enter the stepper. From there you
>>>> can use "s" to step into the call, "x" to step over the call, or "o"
>>>> to step out of the function that's currently being executed.
>> I believe these are the bindings when using SBCL directly.
>
> I believe that you're not right about that, as SBCL has no
> "keybindings". And those are the keybindings I added into Slime. It's
> of course possible that somebody has removed them in the last couple
> of years.

I believe you have a point here :-)

To the OP: It looks like the point has to be on a form in the stack
trace when using s, o, or x, so they work much like r, but keep
stepping. So telling from the error message you got, you probably had
not moved the point into the debugger window and on a form from the
stack trace.

HTH,
Peter

0 new messages