Paul Serikov
Paul Serikov

Reputation: 3161

How to enable perl debugger under mod_perl?

I want to make non-interactive debugging of my code. Code is running under httpd with mod_perl2 enable.

According official documentation I can do like

% setenv PERL5OPT -d
% setenv PERLDB_OPTS "NonStop=1 LineInfo=db.out AutoTrace=1 frame=2"

As far I understand, I need to use PerlSetEnv translating apache setenv to language of apache2 config. So config must looks like

<IfDefine MODPERL>
    LoadModule perl_module modules/mod_perl.so
    ...
    PerlSetEnv PERL5OPT -d
    PerlSetEnv PERLDB_OPTS NonStop
</IfDefine>

I tried with such config but no output on STDERR when I wrap some code on

$DB::frame = 1;
# code
$DB::frame = 0;

What could I miss ?

PERLDB_OPTS and PERL5OPT are exacltly right variables:

$ cat 1.pl 
#!/usr/bin/env perl
sub bar { foo() }
sub foo { }
sub hello {
$DB::frame=1; 
bar(); 
$DB::frame=0;
}
hello();
$ PERLDB_OPTS=NonStop PERL5OPT=-d perl 1.pl > /dev/null
   entering main::bar
    entering main::foo

Upvotes: 3

Views: 367

Answers (1)

robut
robut

Reputation: 351

This does not work for me :

PerlSetEnv PERL5OPT -d
PerlSetEnv PERLDB_OPTS NonStop

This does, on Apache/2.4.10 :

SetEnv PERL5OPT -d
SetEnv PERLDB_OPTS NonStop

Outputs to /var/log/apache2/error.log for me, by default :

...
[Fri Jun 21 14:43:51.886302 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:         entering DBD::_::common::install_method
[Fri Jun 21 14:43:51.886341 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:          entering DBI::_install_method
[Fri Jun 21 14:43:51.886385 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:         entering DBD::_::common::install_method
[Fri Jun 21 14:43:51.886425 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:          entering DBI::_install_method
[Fri Jun 21 14:43:51.886468 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:         entering DBD::_::common::install_method
[Fri Jun 21 14:43:51.886508 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:          entering DBI::_install_method
[Fri Jun 21 14:43:51.886784 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:       entering CODE(0x18904ff0)
[Fri Jun 21 14:43:51.886823 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:        entering DBI::dr::connect
[Fri Jun 21 14:43:51.886862 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:         entering DBD::Pg::dr::connect
[Fri Jun 21 14:43:51.886899 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:          entering DBI::_new_dbh
[Fri Jun 21 14:43:51.886943 2019] [cgi:error] [pid 24014] [client 127.0.0.1:48278] AH01215:           entering DBI::_new_handle
...

Good luck !

Upvotes: 3

Related Questions