What if debugging was just available as a library? What power would you need? I think PLT Scheme is uniquely suited to making this extremely practical. It's easy to implement a programmatic breakpoint: just call/cc and raise an exception with the captured continuation. You immediately have access to a nice language of boolean predicates for determining breakpoint conditions (Scheme), as well as a language to evaluate expressions with access to the locals (also Scheme). But PLT Scheme also provides continuation marks, which allow you to leave little bread-crumbs through the control flow of a program. What I'd really love to do is use this to allow the programmer to annotate interesting points in the control and connect this up to the DrScheme GUI libraries so that the programmer can do something like:
and have a window pop open that displays a stack trace of the suspended program.> (define bp (debug <expression>))
> bp
#<breakpoint>
> (show-control bp)
I'm working on a PLaneT library to make this just about as low-tech and seamless as printf-debugging. You'll just need to throw in one extra line somewhere in the module:
and this will allow you to throw in breakpoints and debug programs much like you could with a full debugging IDE, only with the directness and intra-linguistic style of printf.(require (planet dherman/debug))
5 comments:
Welcome to Smalltalk? (Where "self halt." is a breakpoint)
It's great that Scheme systems are starting to provide useful levels of reflection. One thing missing from the Smalltalk debugger that'd be interesting to see your take on is readily-accessible programmatic control of the debugger.
In Haskell (GHC at least) there is Debug.Trace which can be used to print messages as expressions are evaluated in the middle of the program. The ordering of the output may not be too helpful though.
I think one reason that there are so many different debuggers is that different languages have to be debugged differently. You can't debug a pure-functional and an imperative function the same way.
Sounds great!
very cool. I can't wait to try it out. Let of know he you need a tester.
speaking on behalf of dirty hippies everywhere, ruby has a lovely interactive breakpoint library called ruby-debug. not a terribly high barrier. http://www.datanoise.com/articles/2006/7/12/tutorial-on-ruby-debug
Post a Comment