如何从 .perldb 初始化文件在所需模块中设置断点?

How to set breakpoint in a required module from a .perldb init file?

的后续问题。我正在尝试在 运行 时间加载的模块中设置断点。出于测试目的,我创建了以下文件:

/home/hakon/test/perl/perldb/p.pl:

use feature qw(say);
use strict;
use warnings;
use lib "./lib";

say "Line 6";
say "Line 7";
require My::Module;
say "Line 9";

/home/hakon/test/perl/perldb/lib/My/Module.pm

package My::Module;
use feature qw(say);
use strict;
use warnings;

say "MM Line 6";
say "MM Line 7";
say "MM Line 8";

1;

/home/hakon/test/perl/perldb/.perldb

sub afterinit {
    push @DB::typeahead,
      "b p.pl:8",
      "c",
      "b /home/hakon/test/perl/perldb/lib/My/Module.pm:7",
      "c"
      ;
}

当我使用调试器 运行 脚本时,我得到:

$ perl -d p.pl

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

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

main::(p.pl:6): say "Line 6";
auto(-4)  DB<1> b p.pl:8
auto(-3)  DB<2> c
Line 6
Line 7
main::(p.pl:8): require My::Module;
auto(-2)  DB<2> b /home/hakon/test/perl/perldb/lib/My/Module.pm:7
auto(-1)  DB<3> c
MM Line 6
MM Line 7
MM Line 8
Line 9
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.

所以Module.pm第7行的断点被忽略了。如何让调试器在断点处停止?

似乎不​​能在编译之前在所需模块中设置断点,但可以通过先使用 b load filename 命令,然后设置断点来解决此问题所需的模块已经编译:

sub afterinit {
    push @DB::typeahead,
      "b p.pl:8",
      "c",
      "b load lib/My/Module.pm",
      "c",
      "b lib/My/Module.pm:7",
      "c"
      ;
}

这对我有用。

注:

如果我用过

use FindBin qw/$Bin/;
use lib "$Bin/lib";

而不是

use lib './lib';

在脚本 p.pl 中,我必须在 b 命令中使用绝对路径而不是相对路径:

sub afterinit {
    push @DB::typeahead,
      "b p.pl:8",
      "c",
      "b load /home/hakon/test/perl/perldb/lib/My/Module.pm",
      "c",
      "b /home/hakon/test/perl/perldb/lib/My/Module.pm:7",
      "c"
      ;
}