How do I use the debugger with mod_perl
Asked Answered
R

3

8

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]
Reviewer answered 7/4, 2011 at 18:20 Comment(5)
Have you tried setting a breakpoint before you start up apache? (i.e. $DB::single=1) Or, try dumping the \%DB:: symbol table to see if the debugger is even loaded in the part of the process that generates the response?Jansenism
Depending on your needs, you could also litter the code with print eval, "\n" while <>; lines, which would drop you into a basic repl each time they are run. Type the commands you need, and then hit CTRL-D to end the while loop, and the code will run until the next time it hits a "breakpoint". Depending on where you place them, you might need to wrap the above with {local $_; ... } to protect the $_ variable.Totalizator
I don't believe it when you say -X is not accepted. Every Apache httpd released in the last 10 years or longer has that feature. You must be doing something wrong.Octagonal
Edited the main post ...Reviewer
mod_perl debugGasparo
T
2

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.

Tug answered 14/6, 2011 at 8:7 Comment(1)
You can download it here eknigi.org/engine/download.php?id=70634 and search here books.google.ru/books?id=UDUmoHOUXiMC&printsec=frontcoverUjiji
G
2

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

Goaltender answered 16/1, 2013 at 20:6 Comment(0)
C
0

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.

Chore answered 25/4, 2012 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.