Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

acme (189)

  (email not shown publicly)

Leon Brocard (aka acme) is an orange-loving Perl eurohacker with many varied contributions to the Perl community, including the GraphViz module on the CPAN. YAPC::Europe was all his fault. He is still looking for a Perl Monger group he can start which begins with the letter 'D'.

Journal of acme (189)

Friday April 01, 2005
01:20 AM

A new Perl debugger!

[ #23967 ]
In my previous journal entry, I talked about amusing comments or bits of code I found in the Perl debugger. Now, you might wonder what sort of insane person would look inside for fun? Well, I blame obra. Not only did he mention that someone should write a new debugger for Perl, he also told me this while I had a laptop to hand and he handed me a beer.

What's wrong with the existing Perl debugger, you ask? Well, it's a bit, errr "crufty". It's grown organically, is quite huge, doesn't have a test suite, and contains amusing comments. For some reason, I was dreaming of an object oriented interface to debugging a program, which would make writing debugger front-ends easy.

So, like any good little extreme programmer, I sat down and wrote a few tests before writing any code:

my $ebug = Devel::ebug->new;
is($ebug->line , 7);
is($ebug->filename, 't/');
is($ebug->line, 8);
is($ebug->filename, 't/');
is($ebug->line, 9);
is($ebug->filename, 't/');
is($ebug->finished, 1);

Well, there were more tests. I mean, there's quite a few things you might want to do in a debugger, like set break points (with conditions), set watch points (conditions sans a line number), inspect variables, evaluate code, return from subroutine and more.

So I sat up late into the night, hacked on Perl code, and a few hours later had a new Perl debugger with tests and documentation. I reckon autrijus' energy must be rubbing off onto me.

And then I wondered what kind of interface you might want. I mean, having a console interface to a debugger, but it's not really exciting and I hate having to remember that "b 6 $x > 7" sets a break point at line 6 of where it'll only stop if $x > 7. So then I thought about GUIs, and I played a little bit with Curses::UI speccing out an interface, but I decided it wasn't quite flexible enough. Gtk2 might well be the way to go, but I thought that we all have web browsers, and with JavaScript thesedays we have the technology to make nice rich web interfaces. Thus I designed a sample web interface which shows off the main features a debugger would have.

So I threw a few modules together and built that very web app that you see in the screenshot above. Actually, I spent more time making "s" keystrokes automatically "step" using JavaScript than I spent building the web application. I guess I should brush up on my Ajax skills.

Ok, so it doesn't do everything you might want a debugger to do, but I did manage to build a complete Perl debugger in a few hours, which has a nice OO interface, and a web frontend. Neat, huh?

Of course, what's really scary is that this isn't an April Fool's joke. It's actually on CPAN as Devel::ebug. Patches welcome. Enjoy.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.