代码之家  ›  专栏  ›  技术社区  ›  Schwern

如何让Perl调试器不停在“子例程调用的100级”上

  •  31
  • Schwern  · 技术社区  · 14 年前

    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调试器不关心堆栈有多大?

    2 回复  |  直到 14 年前
        1
  •  46
  •   paxdiablo    14 年前

    添加行:

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

    开始你的计划。

    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;

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

    已经成功测试了高达50000的堆叠深度(在 if 语句和集合 $DB::deep 至50001)。如果堆栈深度大于 ,我想你应该重新设计而不是调试:-)

    顺便说一下,如果您根本不想接触代码,可以在运行代码之前在调试器中更改该值-只需输入 $Db::deep=500; 在你进去之前 c .perldb 文件:

    BEGIN {$DB::deep = 500;}
    
        2
  •  4
  •   Ovid    14 年前

    Schwern:正如在对“最佳答案”的评论中所指出的,它肯定是一个缺乏文档记录的系统的一部分。不过,如果你真的想帮忙,看看 DB::Pluggable DB::Pluggable::Dumper 它的插件。有很多伟大的工作可以做,使调试器几乎有趣的工作。