2

我正在试验.perldbrc 文件并尝试设置断点。这是我用于测试的一个小示例脚本(p.pl):

use feature qw(say);
use strict;
use warnings;

say "Line 5";
say "Line 6";
say "Line 7";

.perldb然后,我在当前目录中创建了以下文件:

parse_options("NonStop=1");
sub afterinit { push @DB::typeahead, "b 7" }

(请注意,此文件不应由您自己以外的其他人(即:)拥有写权限,chmod 644 .perldb否则调试器将不会加载它)。然后我在调试器下运行脚本:

$ perl -d p.pl
Line 5
Line 6
Line 7

正如所见,第 7 行的断点不受尊重。这里有什么问题?

4

1 回答 1

2

将您的“.perldb 文件”更改为

#parse_options("NonStop=1");
sub afterinit { push @DB::typeahead, ("b 7", "c") }

应该做的工作。

$ perl -d t.pl

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

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

main::(t.pl:5): say "Line 5";
auto(-2)  DB<1> b 7
auto(-1)  DB<2> c
Line 5
Line 6
main::(t.pl:7): say "Line 7";

DB<2> l
7==>b   say "Line 7";
于 2020-05-03T10:36:55.053 回答