Debugging

Overview

  • To turn on debug code in general insert the following to ~/.sbclrc

(sb-ext:restrict-compiler-policy 'debug 3)
  • In debugger mode type ? to get a list of available commands

Trace function calls

(trace function)
  • To undo

(untrace function)

Step through a function

  • Every function you want to step into must be compiled with debug optimization, insert

(declaim (optimize (debug 3)))
  • Now run

(step (function args))
  • And use the command :step to step into NOT :next note the '!

  • With source 10 you can see the source 10 levels (parantheses) deep

Invoke debugger at specific conditions

(ignore-errors ;Normally, this would suppress debugger entry
 (handler-bind ((error #'invoke-debugger)) ;But this forces debugger entry
   (error "Foo.")))

Breakpoints

  • Insert (break) at the specific code lines

Measure time of code execution

(time (function args))

Disassemble a function

(disassemble 'format)