To debug scripts running under mod_perl noninteractively (i.e., to print the Perl execution trace), simply set the usual environment variables that control debugging.
The NonStop debugger option enables you to get some decent debugging information when running under mod_perl. For example, before starting the server:
panic% setenv PERL5OPT -d panic% setenv PERLDB_OPTS \ "NonStop=1 LineInfo=/tmp/db.out AutoTrace=1 frame=2"
Now watch /tmp/db.out for line:filename information. This is most useful for tracking those core dumps that normally leave us guessing, even with a stack trace from gdb, which we'll discuss later. db.out will show you what Perl code triggered the core dump. Refer to the perldebug manpage for more PERLDB_OPTS options.
Say we execute a simple Apache::Registryscript, test.pl:
use strict; my $r = shift; $r->send_http_header("text/plain"); $r->print("Hello");
The generated trace found in /tmp/db.out is too long to be printed here in its entirety. We will show only the part that actually executes the handler created on the fly by Apache::Registry:
entering Apache::ROOT::perl::test_2epl::handler 2: 3: entering Apache::send_http_header exited Apache::send_http_header 4: entering Apache::print exited Apache::print exited Apache::ROOT::perl::test_2epl::handler
You can see how Perl executes this script—first the send_http_header( ) function is executed, then the string "Hello" is printed.
 
Continue to: