I’m just starting to get some results through after working with the latest Ruby In Steel debugger. This is the fast version - the one that’s going into our Developer Edition - rather than the current slow debugger in the free edition. I haven’t got all the bugs out of it yet, but, hopefully, in the next week I should have those sorted. But even in its incomplete state, it is very fast indeed.
I’ve also built a ‘drill-down’ watch window that allows you to examine what’s inside a Ruby structure much more easily than you can right now. Currently (in the slow debugger), all you get is a linear ‘inspect’ string. That’s ok for simple stuff, but totally inadequate for anything complicated.
There seem to be two choices in doing a drill-down window. The first is to parse the ’inspect string’ that Ruby gives you; the second is to use YAML. YAML gives a nicely formatted and easily parsable output … but it’s slooow!.
The first option is more reasonable, but the question is: how to parse it? Well, ANTLR to the rescue again. It took me about a day to build up a simple lexer/parser/tree-walker for the inspect syntax (and most of that was trying to figure out what exactly the Ruby inspect syntax is - like a lot of Ruby, it’s not actually written down anywhere), another day to figure out how to connect it all up to the Visual Studio debugger IDE and a third day doing the finer points and testing.
I’ve now got five ANTLR parsers built – the main Ruby lexer/parser, RHTML, two RDOCs (don’t ask!) and the new Inspect one. Previously, I would have used regular expressions (REs) to do simple parsing, but I’m now firmly of the view that in many cases ANTLR is a better solution. First, it’s a lot more powerful than REs and secondly (and more importantly) its far more maintainable. I have several pre-processors written in RE syntax written several months for ad-hoc jobs – and I now haven’t a clue what they do.
Anyway, here’s a screen shot of a reasonably complicated structure
Drill-down in a Watch Window
And here is its ‘drill down’ in a Visual Studio Watch Window. You can see that the Array @mylittlearray has a Struct::Customer as it’s first element and various simpler objects following. (Note that the Type is actually the Ruby Class):
The only minor remaining problem I’ve got is that the Ruby objects don’t really map onto a Visual Studio glyph. There’s no suitable glyph for an Array for example. Hopefully, Visual Studio will allow for better glyphs in the future