简体   繁体   中英

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]

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....

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.

I and several others at my company have been trying to attach a debugger to mod_perl for years. We have managed to break at several points in the mod_perl process before we actually reach the code in our ASP pages, but we have never been able to break inside of our ASP pages. Even if we break before our code is run, and then 'c' to our $DB::single = 1 statement inside of our interesting code, the page runs to termination and doesn't break (it appears to skip over the $DB::single).

All of us believe that there is a bug in our version of perl, our version of perl5db, or our version of mod_perl, which makes this impossible to do for our version. We are on perl 5.8.9, and some version of apache 2 which escapes me at the moment.

I know this isn't an answer, but I just wanted to tell you this so that you wouldn't feel bad about giving up if you eventually do give up.

This problem we're having with mod_perl is one of the main reasons that I am in the process of inserting a Plack layer between our webserver and our application. With this abstraction layer, I can run a different web server in development - and one in which I can attach a debugger. I am not linking to this so much as a suggestion that you do it but just so you know that I am really serious about having interactive debugging.

I think the next logical step in the epic battle for interactive debugging in mod_perl would be to build the latest version and see if that works. Then upgrade our perl version and see if that works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM