Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the debugger with mod_perl

I'm trying to attach the Perl debugger to Apache and mod_perl. Our environment is quite complex (lots of additional stuff (eg Catalyst) configured with Apache) and the engineers who configured it are no longer with the company. I've followed the instructions on the Apache web site, setting 'PerlFixupHandler Apache::DB', etc. but so far all I get is a break into the debugger after the page has been delivered. I'm guessing that I get the break in the dispatch process, not the worker process. I'm running the prefork MPM version of Apache. The instructions for debugging say pass the -X parameter when starting httpd. But the httpd I'm running doesn't accept a -X parameter. I'm assuming the -X param would actually cause some versions of httpd to NOT fork?

Any and all guidance appreciated.

$ ./httpd -v
Server version: Apache/2.2.17 (Unix)
Server built:   Nov 16 2010 20:13:24

-X isn't listed when I do httpd -?    
Usage: ./httpd [-D name] [-d directory] [-f file]
           [-C "directive"] [-c "directive"]
           [-k start|restart|graceful|graceful-stop|stop]
           [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S]
like image 710
Leonard Avatar asked Apr 07 '11 18:04

Leonard


2 Answers

The book 'Pro Perl Debugging' has a chapter on 'Debugging a CGI Program' and a subsection titled 'Configuring mod_perl'.

Sorry, I don't have access to the book right now.

like image 73
hexcoder Avatar answered Oct 31 '22 17:10

hexcoder


I have successfully run the debugger that comes with the epic perl module for eclipse and also the komodo debugger.

For Komodo, you add something like the following to apache2.conf

<IfDefine DEBUG>
<Perl>
  use ModPerl::Registry;
  use lib qw(/usr/local/lib/perl/Komodo-PerlRemoteDebugging-6.0.3-59641-linux-x86);
  $ENV{PERLDB_OPTS} = "RemotePort=127.0.0.1:9000 LogFile=stderr";
  $ENV{DBGP_IDEKEY} = "yourkey";
  use Apache::DB ();
  Apache::DB->init;
</Perl>
</IfDefine>

Follow the instructions here : http://docs.activestate.com/komodo/4.4/debugperl.html

For Epic

<IfDefine DEBUG>
    PerlModule ModPerl::Registry
    PerlSetEnv PERLDB_OPTS "RemotePort=192.168.x.x:9500 DumpReused ReadLine=0 PrintRet=0"
    PerlSetEnv PERL5DB "BEGIN { $DB::CreateTTY=0; require /path_to_epic_db_scripts/perl5db.pl'; }"
    PerlRequire /path_to_epic_db_scripts/db.pl
    PerlPostConfigRequire /etc/apache2/perl/whatever.pl
</IfDefine>

See documentation here: http://www.epic-ide.org/guide/ch06.php

Of course, Epic is free and Komodo isn't, and it shows, it's still quite ok though. I have to say it's been about 18 months since I had call to use it, so that's about as much as I can remember. Good luck....

like image 39
mark Avatar answered Oct 31 '22 18:10

mark