Smalltalk

Power tools for Smalltalk debugging

September 26, 2003 17:23:15.702

Sometimes the ability to debug problems in Smalltalk amazes me. At times, though, the debugger (even the PDP debugger) just isn't up to the task of finding problems. That's when I pull out the power tools.

Usually, the problem boils down to "when I do this over here, somehow that over there changes - why?" The problem is that there are thousands of things that could change "that over there" and I can't put a breakpoint into all of them.

My power tool is one I wrote a few years ago then found that John Brant and Don Roberts re-invented. It's called Method Wrappers. What I do is choose a large number of classes (such as "all the classes in my application" and automatically replace the methods with generated ones that do something at the start of the method, call the original method, then do something on the return. In this case, the "somethings" are to evaluate a block and the first time it returns true, capture a stack trace of where we are.

Now, I just have to trigger the condition and look at the stack trace. It's rather like trying to find someone who's lost in a big city. It's a whole lot easier if you can create a huge 5000 ft. high arrow above them saying "they are here".

Try doing that in other languages.