我正在使用一个庞大,陈旧,凌乱,臃肿的框架.它经常在子程序调用中超过100级.Perl调试器认为适合停止并一遍又一遍地通知我这个事实.
Package::Stash::name(/usr/local/perl/5.10.1/lib/site_perl/5.10.1/Package/Stash.pm:21):
21: return $_[0]->{package};
100 levels deep in subroutine calls!
DB<1>
Run Code Online (Sandbox Code Playgroud)
如何让Perl调试器不关心堆栈有多大?
谢谢.
pax*_*blo 46
添加行:
$DB::deep = 500; # or more if necessary
Run Code Online (Sandbox Code Playgroud)
到你的程序的开始.
以下程序在调试器中运行完成:
use strict;
use warnings;
sub f($) {
my $x = shift;
print "$x\n";
if ($x < 200) {
f(1 + $x);
}
}
$DB::deep = 500;
f(1);
Run Code Online (Sandbox Code Playgroud)
输出:
198
199
200
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> _
Run Code Online (Sandbox Code Playgroud)
没有这$DB::deep = 500;
条线,它会停在100,与你的相同:
97
98
99
main::f(qq.pl:4): my $x = shift;
100 levels deep in subroutine calls!
DB<1> _
Run Code Online (Sandbox Code Playgroud)
已成功测试,堆栈深度为50,000(在if
语句中使用50000 并设置$DB::deep
为50001).如果你的堆栈深度大于那个,我怀疑你应该重新设计而不是调试:-)
顺便说一句,如果你根本不想触摸代码,你可以在运行代码之前在调试器中更改该值 - 只需$Db::deep=500;
在输入c
运行代码之前输入,或者只是在.perldb
文件中设置它:
BEGIN {$DB::deep = 500;}
Run Code Online (Sandbox Code Playgroud)