Writing software, the wrong way

Wednesday, February 27, 2008

Using Venkman to combat terrorism and save freedom

Venkman has been a big help during this release, and it something that I want to share. I have been avoiding using a javascript for a while, and that's mainly because I opted to use alert() and dump() instead. But after a while, they both suck and can make debugging incredibly frustrating especially if you have to restart firefox each time to go one step ahead.

Introduction
It's been out since 0.9 folks!


Install
Grab the extension

Setting it up
  • Under Debug menu, make sure "Exclude Browser Files" is not checked.
  • Under the File menu, check "Save Break/Watch Settings on Exit".

Setting Breakpoints
This is reasonably simple. On the left are your files. Here I am debugging ProxyEnable.js.

Below it are the functions within that file. Double-clicking on the filename brings up the source code on the right.
  1. Place your breakpoints. The dashes near the left side of the source are where you can put your breakpoints. Here I am putting a breakpoint just before the if-statement.
  2. Exit venkman (this will close firefox)
  3. Relaunch firefox with -venkman argument. For example :
    /path/to/firefox -venkman --no-remote -profile /path/to/profile

Once you restart, venkman starts first and catches any breakpoints.

This is ideal when you can't use browser chrome to initiate the javascript, for example, js code that is executed on startup.

Fun
Once the debugger breaks, you have access to all the variables. So you can start investigating the problem much more effectively than with dump. You use the black window at the bottom as an interactive javascript shell.


Navigation
The buttons at the top let you go to the next line, go deeper into js functions, or continue. Try them out.


Now Code
No more excuses.

2 comments:

Michael Mullin said...

All hail for freedom, democracy and ghost(bug) busting!

Lukas Blakk said...

thanks for the excellent demo of how to use venkman, i'm totally going to try it now.