Skip to content

Easy Debugging for your Perl Catalyst Web Applications

March 31, 2009

I decided to give Catalyst a try and see how it works for me.
When writing and code I feel that the easiest it is to debug it the better the quality of the product, as such although I love perl, I hate the perl debugger. It is all text/command line, very unfriendly and time consuming.
So long ago I decided to use a perl graphical debugger and after testing several packages I finally settled with ActiveState’s Komodo IDE.

It is a great IDE, and great debugger, where you can inspect all your code and variables in a nice, friendly way.
I also supports remote dubbuging which comes in handy to debug Catalyst applications.

  1. Download the Komodo IDE and remote debugging tools from ActiveState and install them locally on your system, if your using the MyApp_servre.pl to develop and test it, or in the target system where you application resides.There are several versions of the remote debugging tools, make sure the one you download matched your Komodo version, and make sure you download the right platform as well.
  2. tar zxf Komodo-PerlRemoteDebugging-5.1.0-27487-macosx-x86.tar.gz (in my case I am using MAC,)
  3. mkdir /usr/local/lib/perl
  4. cp -R Komodo-PerlRemoteDebugging-5.1.0-27487-macosx-x86 /usr/local/lib/perl
  5. vi /etc/profile

and add the lines, please replace the 55217 with the port your Komodo IDE expects, you can get that value in the Debug Menu, Listener Status (Port field).

export PERL5LIB=/usr/local/lib/perl/
export PERLDB_OPTS=RemotePort=localhost:55217
export DBGP_IDEKEY=

save /etc/profile and execute: . /etc/profile to read it (the dot is important.)

Now you can open your controller in Komodo and add the variable $DB::single=1 where you want your breakpoint.


# controller file: database.pm
sub index : Path :Args(0) {
my ( $self, $c ) = @_;

# template file we want to use
$c->stash->{template} = 'list_users.tt';

$DB::single = 1; # Debugger Breakpoint

# here we selected the ModelName::table_name
$c->stash->{users} = $c->model('OrdersDB::users');
}

  1. Start you application server with
    perl -d script/MyApp_server.pl (-d starts debug mode)
  2. leave your Komodo open, open your browser and point it to http://localhost:3000/database
  3. I you go back to Komodo you’ll your application the Debugger stopped at your breakpoint ($DB::single).

Enjoy the easy life of debugging Catalyst applications 🙂

Advertisements

From → Perl

3 Comments
  1. testing better in CGI

    MyApp_server.pl – heavily load the server

  2. anitha1234 permalink

    Best Software Downloads and Reviews. the most comprehensive source for free-to-trysoftware downloads on the WebBEST 4 DOWNLOADS

  3. Hugo permalink

    The perl debugger I have always used is Devel::ptkdb. Allows to inspect the code, set breakpoints etc, and It interfaces nicely with the DB::single command to break at predefined code points. It is really very good, but I have no idea how it compares to other debuggers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: