基本上,我正在寻找与 gdb 的“向上”和“向下”命令等效的 perl。如果我中断子程序 bar
,我有一个看起来像这样的调用堆栈:
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 - 我可以在堆栈中上下移动调试器上下文吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14681472/