如何使Perl调试器不停止在“子例程调用的100个深层”中? [英] How do I get the Perl debugger to not stop at "100 levels deep in subroutine calls"

查看:61
本文介绍了如何使Perl调试器不停止在“子例程调用的100个深层”中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个大型的,旧的,凌乱的,肿的框架。它经常在子例程调用中深入到100多个层次。 Perl调试器认为应该停止并再次将此事实通知我。

I'm working with a big, old, messy, bloated framework. It regularly goes well over 100 levels deep in subroutine calls. The Perl debugger sees fit to stop and inform me of this fact... over and over again.

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> 

如何让Perl调试器不在乎堆栈有多大?

How do I make the Perl debugger not care about how big the stack is?

谢谢。

推荐答案

添加以下行:

$DB::deep = 500; # or more if necessary

到程序开始。

以下程序在调试器中运行至完成:

The following program runs to completion in the debugger:

use strict;
use warnings;
sub f($) {
        my $x = shift;
        print "$x\n";
        if ($x < 200) {
                f(1 + $x);
        }
}
$DB::deep = 500;
f(1);

输出:

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> _

没有 $ DB :: deep = 500; 行,它会停在100,与您的行相同:

Without the $DB::deep = 500; line, it stops at 100, the same as yours:

97
98
99
main::f(qq.pl:4):               my $x = shift;
100 levels deep in subroutine calls!
  DB<1> _

已成功测试到50,000的堆栈深度(在<$ c $中使用50000 c> if 语句并将 $ DB :: deep 设置为50001)。如果您的堆栈深度大于那个,我怀疑您应该重新设计而不是调试:-)

That's been tested successfully up to a stack depth of 50,000 (use 50000 in the if statement and set $DB::deep to 50001). If your stack depth is greater than that, I suspect you should be re-engineering rather than debugging :-)

如果您根本不想触摸代码,可以在运行代码之前在调试器中更改该值-只需输入 $ Db :: deep = 500; 输入 c 运行代码,或将其设置在 .perldb 文件中:

By the way, if you don't want to touch the code at all, you can change that value in the debugger before running your code - just enter $Db::deep=500; before you enter c to run the code, or just set it in your .perldb file:

BEGIN {$DB::deep = 500;}

这篇关于如何使Perl调试器不停止在“子例程调用的100个深层”中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆