perl – 我可以在堆栈中上下移动调试器上下文吗?

前端之家收集整理的这篇文章主要介绍了perl – 我可以在堆栈中上下移动调试器上下文吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
基本上我正在寻找相当于gdb的“up”和“down”命令的perl.如果我打破子程序栏,我有一个看起来像这样的调用堆栈:

foo
  \
   baz
    \
     bar

我希望能够(无需从bar或baz返回)向上导航foo框架并通过操纵变量来查看它正在做什么,因为我通常会使用p或x的参数.

解决方法

使用 y command.

$cat frames.pl
sub bar {
    my $fnord = 42;
    1
}
sub baz { bar }
sub foo {
    my $fnord = 23;
    baz
};
foo;
$perl -d frames.pl

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help,or 'man perldebug' for more help.

main::(frames.pl:10):   foo;
DB<1> c 3
main::bar(frames.pl:3):     1
DB<2> y 2 fnord
$fnord = 23
DB<3> T
. = main::bar() called from file 'frames.pl' line 5
. = main::baz() called from file 'frames.pl' line 8
. = main::foo() called from file 'frames.pl' line 10

猜你在找的Perl相关文章