调用Perl调试器,使其运行到第一个断点
|
当我使用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>
换句话说,我的调试器会跳过打印“你好吗?”,而是在程序完成后停止,这不是我想要的. 我想要的是调试器运行我的代码而不停止任何地方(也不是在我的脚本的开头和结尾),除非我明确地有一个$DB :: single = 1;声明,在这种情况下,我希望它在运行下一行之前停止.有什么办法吗? 作为参考,我正在使用: $perl --version This is perl 5,version 14,subversion 1 (v5.14.1) built for x86_64-linux 解决方法
放
$DB::single = 1; 在任何在代码中设置永久断点的语句之前. 要让调试器自动启动代码,您可以在.perldb文件或代码中的编译时(BEGIN)块中操作@DB :: typeahead数组.例如: # .perldb file push @DB::typeahead,"c"; 要么 BEGIN { push @DB::typeahead,"p 'Hello!'","c" }
...
$DB::single = 1;
$x = want_to_stop_here();
您还可以在.perldb或PERLDB_OPTS环境变量中设置“NonStop”选项: PERLDB_OPTS=NonStop perl -d myprogram.pl 所有这些(以及更多)都在 更新: 解决最近更新中提出的问题.在./perldb中使用以下内容: print "Reading ~/.perldb options.n";
push @DB::typeahead,"c";
parse_options("inhibit_exit=0");
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
