如何在 mod_perl2 下运行 Devel::Cover?

Posted

技术标签:

【中文标题】如何在 mod_perl2 下运行 Devel::Cover?【英文标题】:How can I run Devel::Cover under mod_perl2? 【发布时间】:2011-01-17 15:20:08 【问题描述】:

Unfortunately, Devel::Cover does not yet work with threads.

它也不适用于 prefork。

startup.plDevel::Cover 中出现use 问题

Not a CODE reference.
END failed--call queue aborted.

perl 5.8.9、Apache 2.2.13。我的操作系统是 FreeBSD,如果这很重要的话。同样的问题是reported for win32

更新:这是PerlTrace all的输出

copying config
restarting apache
mod_perl trace flags dump:
 a On  (Apache API interaction)
 c On  (configuration for directive handlers)
 d On  (directive processing)
 e On  (environment variables)
 f On  (filters)
 g On  (globals management)
 h On  (handlers)
 i On  (interpreter pool management)
 m On  (memory allocations)
 o On  (I/O)
 r On  (Perl runtime interaction)
 s On  (Perl sections)
 t On  (benchmark-ish timings)
modperl_cmd_requires: push PerlRequire /usr/local/www/apache22/data/startup.pl
modperl_cmd_switches: arg = -I/usr/local/www/apache22/data/PMs
modperl_cmd_switches: arg = -I/usr/local/www/apache22/data/project/lib_core
modperl_cmd_modules: push PerlModule Apache::DBI
modperl_config_dir_new: new dcfg: 0x284d3d48
modperl_config_dir_create: dir \.(cgi|pl)$
modperl_cmd_response_handlers: push @PerlResponseHandler, ModPerl::Registry
modperl_handler_new: [47836] new handler ModPerl::Registry
modperl_cmd_push_handlers: created handler stack
modperl_cmd_push_handlers: pushed handler: ModPerl::Registry
modperl_cmd_options: arg = +ParseHeaders
httpd not running, trying to start
modperl_hook_init: mod_perl hook init
modperl_sys_init: mod_perl sys init
MpSrv flags dump (cdev01.project.local):
 Access On 
 Authen On 
 Authz On 
 Autoload Off
 ChildExit On 
 ChildInit On 
 Cleanup On 
 Clone Off
 Enable On 
 Fixup On 
 HeaderParser On 
 InheritSwitches Off
 InputFilter On 
 Log On 
 MapToStorage On 
 MergeHandlers Off
 OpenLogs On 
 OutputFilter On 
 Parent Off
 PostConfig On 
 PostReadRequest On 
 PreConnection On 
 ProcessConnection On 
 Response On 
 Trans On 
 Type On 
 Unset On 
modperl_startup: starting the parent perl for the base server
modperl_config_srv_argv_init =>
   0 = /usr/local/sbin/httpd
   1 = -I/usr/local/www/apache22/data/PMs
   2 = -I/usr/local/www/apache22/data/project/lib_core
   3 = -e;0
modperl_env_clear: [0x28f2a000] %ENV = ();
modperl_env_default_populate: $ENVMOD_PERL = "mod_perl/2.0.4";
modperl_env_default_populate: $ENVMOD_PERL_API_VERSION = "2";
modperl_env_configure_server:   [47836/0x28f2a000/cdev01.project.local:80]
    @ENVkeys scfg->SetEnv = values scfg->SetEnv;
modperl_env_configure_server:   [47836/0x28f2a000/cdev01.project.local:80]
    @ENVkeys scfg->PassEnv = values scfg->PassEnv;
modperl_env_table_populate: $ENVPATH = "/usr/local/www/apache22/data/testing/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
modperl_interp_init: server=cdev01.project.local:80
modperl_interp_new: 0x28f47480 / perl: 0x0 / parent perl: 0x0
modperl_startup: constructed interpreter=0x28f2a000
modperl_handler_anon_init: init $PL_modglobalANONSUB = []
Devel::Cover 0.65: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
    Collecting under mod_perl/2.0.4
Selecting packages matching:
Ignoring packages matching:
    /Devel/Cover[./]
    /Net/OpenSSH[./]
Ignoring packages in:
    .
    /usr/local/lib/perl5/5.8.9
    /usr/local/lib/perl5/5.8.9/BSDPAN
    /usr/local/lib/perl5/5.8.9/mach
    /usr/local/lib/perl5/site_perl/5.8.9
    /usr/local/lib/perl5/site_perl/5.8.9/mach
modperl_config_apply_PerlRequire: loaded Perl file: /usr/local/www/apache22/data/startup.pl for server cdev01.project.local:80
modperl_config_apply_PerlModule: loaded Perl module Apache::DBI for server cdev01.project.local:80
modperl_init_vhost: Init vhost cdev01.project.local:4443: s=0x284d8500, base_s=0x28413a40
modperl_init_vhost: server cdev01.project.local:4443 already initialized
modperl_init_vhost: Init vhost cdev01.project.local:443: s=0x284d5c78, base_s=0x28413a40
modperl_init_vhost: server cdev01.project.local:443 already initialized
modperl_callback_run_handlers: no PerlOpenLogsHandler handlers configured ()
modperl_callback_run_handlers: no PerlPostConfigHandler handlers configured ()
modperl_env_hash_keys: [0x28f2a000] PERL_HASH: MOD_PERL (len: 8)
modperl_env_hash_keys: [0x28f2a000] PERL_HASH: MOD_PERL_API_VERSION (len: 20)
modperl_init_clones: no clones created for non-threaded mpm
modperl_interp_pool_destroy: parent == 0x28f47480
modperl_interp_destroy: interp == 0x28f47480 / perl: 0x28f2a000
modperl_xs_dl_handles_get: B dl handle == 0x28ca9600
modperl_xs_dl_handles_get: Cwd dl handle == 0x28ca9800
modperl_xs_dl_handles_get: List::Util dl handle == 0x28ca9a00
modperl_xs_dl_handles_get: Digest::MD5 dl handle == 0x28ca9c00
modperl_xs_dl_handles_get: IO dl handle == 0x28ca9e00
modperl_xs_dl_handles_get: Fcntl dl handle == 0x28caa000
modperl_xs_dl_handles_get: Storable dl handle == 0x28caa200
modperl_xs_dl_handles_get: File::Glob dl handle == 0x28caa400
modperl_xs_dl_handles_get: Data::Dumper dl handle == 0x28caa600
modperl_xs_dl_handles_get: Devel::Cover dl handle == 0x28caa800
modperl_xs_dl_handles_get: Apache2::Module dl handle == 0x28caaa00
modperl_xs_dl_handles_get: Apache2::RequestUtil dl handle == 0x28caac00
modperl_xs_dl_handles_get: Apache2::ServerUtil dl handle == 0x28caae00
modperl_xs_dl_handles_get: DBI dl handle == 0x28cac000
modperl_perl_call_list: pid 47836/tid 0x28401040/perl id 0x28f2a000 running 4 END subs
Not a CODE reference.
END failed--call queue aborted.

【问题讨论】:

你能use diagnostics; 和/或启用PerlTrace 吗?另外,如果使用Apache2::Reload,可以尝试禁用它吗? 我启用了PerlTrace 并添加了日志文件输出。 【参考方案1】:

邪恶的源头似乎是Apache::DBI。我从配置文件中将其注释掉,然后httpd 开始了。

不幸的是,更多的障碍即将到来:(No coverage for runtime with Devel::Cover and ModPerl::Registry

【讨论】:

我认为这个“答案”应该是对问题的修改。 @Jonathan 我不这么认为。如果您在网上搜索"Not a CODE reference" "Devel Cover",您会看到,这不仅是我的问题,而且还没有得到解决。我的回答显示了正确的方法。如果不是Apache::DBI,它可能是mod_perl 的另一个模块。 @xenoterracide 我不能。也许是因为这是唯一的答案。 哦,伙计。就是这样:如果没有符合上述标准的答案,而您作为问题所有者没有选择接受答案,则您将丧失接受问题答案的权利。

以上是关于如何在 mod_perl2 下运行 Devel::Cover?的主要内容,如果未能解决你的问题,请参考以下文章

如何在 OS X Yosemite 上的 Apache 2.4 中安装 mod_perl 2.0.9?

在 mod_perl 2 下关闭响应

在 mod_perl2 中修改 POST 请求

使用 Apache 和 mod_perl 提供动态生成的图像的正确方法是啥?

如何使用 mod_perl 发送自定义 http 状态码

binmode + mod_perl 2.0.5 + Parse::RecDescent = 分段错误