1. you can add a (break) form anywhere in your code which will cause the program
to stop and fall into the debugger.
2. In SLIME at least you can hit "s" while in the debugger to step. You can also
(in SLIME) evaluate any expression in the context of a frame.
------------------------------------------------------------------------------
Stas,
I can debug 3, I can remove inline. How do I "call my function with stepping"?
Thanks,
Will
Hmm. Help says that this will work, but as I explained below, I
haven't been able to see it work. Can you provide an example?
Ha, I was about to reply that I'm a complete newb, but I'm pretty sure you knew that :). Thanks for the example! It's working.
So, taking off on what you suggested, I did this:
(defun sum (n1 n2)
(declare (optimize (debug 3)))
(break)
(if (zerop n1) n2
(sum (1- n1) (1+ n2))))
now when I execute the function, it breaks on each call.
CL-USER> (sum 99999 0)
debugger invoked on a SIMPLE-CONDITION in thread
#<THREAD "main thread" RUNNING {100216E5B3}>:
break
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] Return from BREAK.
1: [ABORT ] Exit debugger, returning to top level.
(SUM 99999 0)
source: (BREAK)
0] c
debugger invoked on a SIMPLE-CONDITION in thread
#<THREAD "main thread" RUNNING {100216E5B3}>:
break
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] Return from BREAK.
1: [ABORT ] Exit debugger, returning to top level.
(SUM 99998 1)
source: (BREAK)
0] c
debugger invoked on a SIMPLE-CONDITION in thread
#<THREAD "main thread" RUNNING {100216E5B3}>:
break
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] Return from BREAK.
1: [ABORT ] Exit debugger, returning to top level.
(SUM 99997 2)
source: (BREAK)
It seems reasonable and in line with what I would expect. Hallelujah! The function is just too simple and quick for it to be very interesting, but I gather that a more complex function that has more forms to process will feel more like a traditional debugging session. I can break on entering the function and step through the forms. I'm not entirely sure what role START has in any session though, any insight on when I would need/use START?
Thanks,
Will
Success! I appreciate your help.
(defun sum (n1 n2)
(declare (optimize (debug 3)))
(break)
(if (zerop n1) n2
(sum (1- n1) (1+ n2))))
SUM
CL-USER> (sum 999999999 0)
debugger invoked on a SIMPLE-CONDITION in thread
#<THREAD "main thread" RUNNING {100216E5B3}>:
break
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] Return from BREAK.
1: [ABORT ] Exit debugger, returning to top level.
(SUM 999999999 0)
source: (BREAK)
0] s
Not currently single-stepping. (Use START to activate the
single-stepper)
0] start
; Evaluating call:
; (- N1 1)
; With unknown arguments
0] s
; Evaluating call:
; (+ N2 1)
; With unknown arguments
0] n1
999999999
0] n2
0
0] p
(SUM 999999999 0)
0] s
; Evaluating call:
; (SUM (1- N1) (1+ N2))
; With arguments:
; 999999998
; 1
1]