【发布时间】:2013-05-06 21:11:50
【问题描述】:
当我使用 perl -d myscript.pl 调用我的 Perl 调试器时,调试器会启动,但它不会执行任何代码,直到我按下 n(下一步)或 c(继续)。
无论如何调用调试器并让它在默认情况下运行代码直到它遇到断点?
如果是这样,我可以在我的代码中使用任何语句作为断点,让调试器在遇到它时停止?
更新:
这是我的 .perldb 文件中的内容:
print "Reading ~/.perldb options.\n";
push @DB::typeahead, "c";
parse_options("NonStop=1");
这是我的hello_world.pl 文件:
use strict;
use warnings;
print "Hello world.\n";
$DB::single=1;
print "How are you?";
这是运行中的调试会话:perl -d hello_world.pl:
Reading ~/.perldb options.
Hello world
main::(hello_world.pl:6): print "How are you?";
auto(-1) DB<1> c
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> v
9563 9564
9565 sub at_exit {
9566==> "Debugged program terminated. Use `q' to quit or `R' to restart.";
9567 }
9568
9569 package DB; # Do not trace this 1; below!
DB<1>
换句话说,我的调试器跳过print "How are you?",而是在程序完成后停止,这不是我想要的。
我想要的是让调试器运行我的代码在任何地方都不会停止(也不是在脚本的开头,也不是在我的脚本结尾),除非我明确有$DB::single=1; 语句,在这种情况下,我希望它在运行下一行之前停止。有什么方法可以做到这一点?
作为参考,我正在使用:
$perl --version
This is perl 5, version 14, subversion 1 (v5.14.1) built for x86_64-linux
【问题讨论】: