Obstacles to porting SmallTalk debugger in Perl

jjore on 2007-12-24T06:35:21

I've been playing in Squeak recently and it has the best debugger I've ever seen before. Not only can I inspect any part of the running system, I can modify the code for anything, let the absence of methods or other exceptions serve as breakpoints, pop up a level (or many) in the stack and restart a function.

It's sweet. To make this happen in Perl 5 I'd need the following facilities that

"find the source for the thing that is executing" "project an editor somewhere useful" "be able to accept the edited code and replace it in the original file (this is difficult. maybe requires PPI)" "Merge newly compiled block into running program. (trivial? for non-closures. needs rebinding for closures)" "pop the stack to some arbitrary point. be able to restart the block"

This is just off the top of my head. Maybe it's not worth doing in Perl 5 but it'd be hella nice to have.


Step One

chromatic on 2007-12-24T08:26:28

A custom runloop plus a little optional B::Op magic would fix up step one nice. If you can't do it in ten lines of code, that's because making B::Op's blessing code reusable is a lot more work than it should be.

My Hero

malte on 2007-12-24T12:49:43

You'd be my hero!

I remember programming in VisualWorks for Smalltalk in the 90's where we'd start coding by putting a halt in the source code and then just debug the program until it was done.

A starting point...

jesse on 2007-12-25T06:30:11

might be Devel::ebug.

Merge code

scrottie on 2008-01-16T10:13:19

``"Merge newly compiled block into running program. (trivial? for non-closures. needs rebinding for closures)"''

Code::Splice. Cross your fingers, though.

Should work for closures. There's a fun bit of code in there that looks up the pad entries for variables in the source and target pads and changes the t_args to whatever the variable is named in the target. With the right t_arg and Perl providing the right pad for the closure, it should just kinda go.

Something that's been nagging me is how utterly cool developing on MUD was -- real time, developing from within the environment, seeing your code used immediately and tested by people standing in the same room as you, being represented by an object and other people you're interacting represented as objects. You mentioning debugging in Smalltalk spurred me to go blog about it. So thanks for that =)

Cheers,
-scott