[英]How to run perl code block under debugger?
I'm writing a test for my debugger. 我正在为调试器编写测试。
subtest "main" => sub {
$ENV{PERL5DB} = 'Devel::AllSubs';
my $stderr = capture_stderr {
sub foo { bar(); }
sub bar { 1; }
foo();
};
$ENV{PERL5DB} = '';
is $stderr, "main::foo\nmain::bar";
};
How to apply debugger to 如何将调试器应用于
{
sub foo { bar(); }
sub bar { 1; }
foo();
}
block ? 阻止?
I tried to use $ENV{PERL5DB}
but no effect. 我尝试使用$ENV{PERL5DB}
但没有效果。
You can't use $ENV{PERL5DB}
the way you want. 您不能按需要使用$ENV{PERL5DB}
。
use Devel::AllSubs
它必须是完整的命令,才能加载调试器代码,例如use Devel::AllSubs
-d
switch 仅在使用裸机-d
开关启动Perl时才检查它 So in order to apply your debugger to only part of the code you will need to first load it in using the -d switch like this 因此,为了将调试器仅应用于部分代码,您将需要先使用-d开关将其加载,如下所示
perl -d:AllSubs script.pl
and then use a package variable to decide if you want to process the code or not. 然后使用包变量来确定是否要处理代码。 Looking at your module name I assume you are trying to do something with each subroutine so your test probably wants to be in your DB::sub
method 查看模块名称,我假设您正在尝试对每个子例程进行操作,因此您的测试可能希望在您的DB::sub
方法中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.