FDB is the command line debugger that comes bundled in with the Flex SDK. While it's arguably not as quick or easy to use as the debugger supplied with Flash Builder it is free and useful to quickly step through a project that you don't have set up in Flash Builder. It's also very straight forward to use as a remote debugger.
Below I will run through some simple usage with FDB.
The program itself lives in the bin
folder of the Flex SDK. Running it provides you with a command prompt from which you can launch an application and begin debugging.
Launching
To launch an application you type run
or r
followed by a space and the address to the swf or mxml application you wish to launch. If you don't specify anything, then FDB will wait for a debug player to connect. This is the method I usually use and is also the only method available to Mac users.
If you just used run
with no address to launch you now have a small amount of time to load up the application to be debugged. All going well you should see a message like the one pictured below.
Just a couple of notes: don't launch an swf through the Flash IDE as this will steal the debug connection, and also make sure the swf is debug enabled.
Setting up
Depending on how you ran FDB up there is a chance you will now need to add source directories. This is achieved by typing directory
or dir
followed by a ';' delimited list (':' on a Mac) of source paths. You can list current source paths by typing info sources
or i so
.
Now you can add break points. This is done by typing something like the following: break Main.as:20
. This will add a break point at line 20 of the file Main.as. You can also specify method names instead of line numbers, e.g. break Main.as:getSomething
. You can review break points by typing info break
or i b
and delete them by type delete n
or d n
where n
is the number given to the break point when it was created.
Once you have finished setting break points continue the swfs execution by typing continue
or c.
Stepping through code
Once a break point is encountered execution halts and you will be presented with a screen like this.
From here you can use a number of commands to analyse the situation. You can type step
or s
to step over a line of code, next
or n
to step into a line of code or finish
(f
) to step return to the calling method. You can print variables by typing print varname
as well as list all of an object properties with print object.
(notice the full stop after the property name).
Other useful commands while execution is halted are bt
or where
to print a backtrace of all stack frames. Print out lines of source code using list
either alone or with a line number, method name or file name/line number combination. For more information on these command type help
either alone or followed by any other command for general or specific information.
Once you are finished looking at this particular break point type continue
to resume execution.
Finishing
To finish either close the Flash Player, or when execution is halted type kill
or k
followed by y
when prompted. From here you can begin another session by typing run
, and if it is the same swf then all your previous source paths and break points will still exist.
This covers basic operation. Hopefully I will have time to cover some of FDB's more advanced features in another post.