[frogs] Scheme debugging and tracing

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


Hi all,

I've been trying to workout how to do some interactive debugging for Scheme code. The CG section on this is still basically a "to-be-supplied" section so I've been doing a bit of digging around.

There was some really useful information from Nicolas in reply to a thread "Debugging/showing internal stuff" on lilypond-devel, but I've been thrashing around trying to find out and do more.

I've found sources like http://www.gnu.org/software/guile/manual/html_node/Debugging-Examples.html#Debugging-Examples
and
http://www.gnu.org/software/guile/manual/html_node/Traps.html#Traps
but there is still a lot of "this is can easily be implemented by the reader" stuff there.

I want to use this as I've been seeing if I can add some of the TODO's in Reinhold's orchestrallily package. (I've already managed to add stuff like Tabstaff and RhythmicStaff processing, but I've got to the stage where having a Scheme debug setup would be good.)

This is what I know so far:
You can get to the guile debug prompt by including a debugger.ly in your source looking a bit like this:

%-----debugger.ly-----
#(use-modules (ice-9 debugger) (ice-9 debugging trace) (ice-9 debugging steps) (ice-9 debugging ice-9-debugger-extensions) )

#     (define (break! proc)
       (install-trap (make <procedure-trap>
                       #:procedure proc
                       #:behaviour debug-trap)))

#     (define (trace! proc)
       (install-trap (make <procedure-trap>
                       #:procedure proc
                       #:behaviour (list trace-trap
                                         trace-at-exit))))

#     (define (trace-subtree! proc)
       (install-trap (make <procedure-trap>
                       #:procedure proc
                       #:behaviour (list trace-trap
                                         trace-until-exit))))
#(module-define! (resolve-module '(guile-user)) 'lilypond-module (current-module))
#(top-repl)
#(set-current-module lilypond-module)
%----------------

One warning - DO NOT use (ice-9 debug) as it has some definitions which conflict with (ice-9 debugging *) modules.

Once I get to the guile prompt I can use break! to set a breakpoint in a procedure in the code and callit like so:
guile> (break! oly:make_parallel_staves)
guile> (oly:make_parallel_staves parser "Test" "FullScore" identity)
Frame 1 at standard input:22:1
	[oly:make_parallel_staves # "Test" "FullScore" ...]
debug>

Once you have the debugger prompt you have these commands available (but some are buggy)

debug> help
Type "help" followed by a command name for full documentation.
Available commands are:
  backtrace
  continue
  down
  evaluate
  finish
  frame
  help
  info
  next
  position
  quit
  step
  up
debug> help finish
Continue until evaluation of the current frame is complete, and
print the result obtained.
debug>

I've been able to step through a procedure, but can anyone give me some pointers to save re-inventing the wheel, so maybe we can provide a standard basic Scheme debugging environment and document it in CG. Contributions from 'grown-up' developers are welcome to help Frog get up to speed.

I'd like to have a debugging environment in place too, so we can maybe get nearer to quickly tracking down 'squawk' errors, (typically ending "crossing fingers, trying to continue", but where you still get a pdf score out of it).

Any tips, pointers, references, Scheme debug code you already have written? The aim is to have this documented in the CG.

Cheers,

Ian Hulin



---

----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/