apache - 如何在mod_perl下启用perl调试器?

标签 apache perl mod-perl2

我想对我的代码进行非交互式调试。代码在启用 mod_perl2httpd 下运行。

根据official documentation我可以这样做

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

据我了解,我需要使用 PerlSetEnv将 apache setenv 翻译为 apache2 配置的语言。所以配置必须看起来像

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

我尝试使用这样的配置,但当我包装一些代码时,STDERR 上没有输出

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

我会错过什么?

PERLDB_OPTSPERL5OPT 是完全正确的变量:

$ 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

最佳答案

这对我来说不起作用:

PerlSetEnv PERL5OPT -d
PerlSetEnv PERLDB_OPTS NonStop

在 Apache/2.4.10 上确实如此:

SetEnv PERL5OPT -d
SetEnv PERLDB_OPTS NonStop

默认情况下,输出到/var/log/apache2/error.log :

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

祝你好运!

关于apache - 如何在mod_perl下启用perl调试器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56691207/

相关文章:

perl - 用于 Perl 单元测试的模拟文件系统

linux - 如何更改 Apache2/mod_perl2 的工作目录

perl - 如何抑制 mod_perl 中的默认 apache 错误文档?

python - Apache 创建文件 : how to control permissions

php - 使用 PHP 脚本上传图片失败

perl - Perl 中的 grep 和 map 有什么区别?

perl - mod_perl2 moose 应用程序的数据库连接过多

php - 用 PHP 编写的 SSI 解析器?

linux - 如何通过htaccess删除url中的点

perl - 在开发过程中测试 perl 模块的正确方法是什么?