For an introduction to Catalyst debugging, see Catalyst::Manual::Tutorial::Debugging.
You may wish to run your application in debug mode with a different configuration file (e.g. specifying a test database). To tell the Config::Loader used by your app to load a different config file, set the MYAPP_CONFIG environment variable:
FOOAPP_CONFIG=fooapp_sqlite.conf script/fooapp_server.pl -d
To get a variable dump in the browser, append ?dump_info=1 at the end of the URL while you run the server in debug mode (-d).
Debugging "live" Catalyst applications is possible with Komodo and might work with Eclipse+EPIC (please chip in if you have experience with the latter).
You don't want to step through all the Catalyst-specific code. Put a breakpoint (F9 in Komodo) directly in the file you wish to start debugging from (most of the time, a controller). Alternatively, you can insert $DB::single = 1 statements where you want breakpoints in your application.
Then, call perl with the -d flag to enable debugging:
perl -d script/myapp_server.pl
You can also debug how your application handles a request without running an HTTP server. To do this, run the myapp_test.pl script, or any of the .t scripts. They all use Catalyst::Test:
perl -d myapp_test.pl /troublemaker_url/foo
To debug remotely with Komodo, refer to ActiveState's article on Remote Debugging Perl with Komodo. In short, here's what to do:
wget and unpack the perl debugging lib tgz
add the following to your ~/.profile:
export PERL5LIB=/path/to/where/you/unpacked/the/tgz
export PERLDB_OPTS="RemotePort=[IP of the Komodo machine]:9000"
on the remote host, run
perl -d myapp_test.pl http://mysite.com/troublemaker_url
Komodo will pop-up on your "Komodo machine" and ask to map the file ("Mapped URIs") to a Remote Account (Preferences -> Servers).
If the remote host can't connect to your Komodo machine (e.g. due to a firewall), you can do the following:
<IP of the Komodo machine> above with 127.0.0.1127.0.0.1:9000 to localhost:9000. For Windows, an excellent SSH client that supports both client-to-server and server-to-client forwarding is Bitvise Tunnelier.There are/were two issues with Komodo:
while ( accept( Remote, $daemon ) ) loop in Catalyst::Engine::HTTP.Stepping through scripts that use Catalyst::Test causes the following error message to be dumped in Komodo's Output pane:
Unexpected use of a standard filehandle while debugging:
The STDOUT and STDERR handles have been tied for remote debugging,
and can't be redirected in the code being debugged.
Try adding
untie(*STDOUT) if tied(*STDOUT);
untie(*STDERR) if tied(*STDERR);
to the code at /usr/lib/perl5/site_perl/5.8/HTTP/Request/AsCGI.pm line 124
This is currently tracked on ActiveState's Bugzilla queue for Komodo.
Alternatively, you can debug using perl's integrated debugger:
myapp/myapp_server.pl -df Foo.pml commandb 31r again to resume the server's executionp perl_expression or step through the code (n)h for helpCatalyst::Plugin::FirePHP - causes Catalyst's debug calls to go to the FirePHP console. If you use Firebug (and you should), this saves having to switch between the remote server's console with the Catalyst application output, and the browser window.
Charles Web Debugging proxy - cross-Platform application, written in Java. It has Firefox/IE/Safari proxy autoconfiguration, AJAX debugging capabilities, and bandwidth throttling simulation.
Paros Proxy - written in Java and geared at evaluating the security of web applications.
If you're using DBIx::Class, set DBIC_TRACE=1 when running your application.