ActionScript Debugger: Cylon Attack!
Well, Autumn has arrived and I’ve been settling down in front of a nice warm log fire with season 4 of Battlestar Galactica. Which in a round-about way encouraged me to start work on a long planned upgrade to the current Amethyst debugger.
Visual Studio allows you to create custom “Debug Engines” (DEs) to handle debugging of languages such as Ruby and ActionScript. Now I’ve already created two DEs for our Ruby IDE and built another one, based around Adobe’s Flex debugger, FDB, for Amethyst. The first Ruby DE was a slow debugger based on Ruby itself. The second one was a super fast “Cylon” engine – in fact, it’s the fastest debugger for Ruby, by a factor of three over the nearest rival. The name “Cylon” comes from a brilliant Microsoft advertisement for Visual Studio I saw a couple of years ago: “Cylons: why debugging matters. Use Visual Studio”. Well, I really couldn’t resist ...
As I mentioned, the first Amethyst debugger was based on FDB – as is every other Flash debugger I’ve come across. But FDB is really designed as a command line debugger and it’s clunky (to say the least) to plug it into an IDE. So I decided to design a new one from the ground up written in C# specifically for Visual Studio. This involved a TCP/IP transport layer, C# interfaces to the native Flash Adobe Virtual Machine (AVM) debug API, interfaces to Visual Studio and some really rather tricky threading and synchronization code (for speed). And finally, having written four Visual Studio DEs, I think I’m getting close to understanding how the things work. A Visual Studio DE can be horrendous to code and get running, but once you’ve got things working, they really are rather cool.
The end result is a really fast, clean Flash debugger, totally integrated with Visual Studio and with some really neat features for debugging websites that aren’t in any other Flash debugger that I know of. For example, one of the things we can now do is debug the Amethyst Designer itself, though Huw (who’s in charge of the Amethyst Designer project) still goes cross-eyed when I try and explain how the Visual Studio ’Process Attach’ mechanism works.
I’ve still got quite a bit of work to do integrating the main IntelliSense system with the Cylon Expression Evaluator – for a compound variable, for example, you need to know what an object is in detail before you can ask the AVM intelligent questions about it. But I think the main slog (“will this *@#?* thing ever work?”) has been done and I can now concentrate on IntelliSense integration into the debugger.
The result doesn’t actually look much different for the original FDB based debugger - but underneath, it’s totally different. It will form the basis for several really advanced debugging techniques which I’ll blog about in the future. Which is to say, if I’m honest, when I’ve got them working ... ;-)