英文:
How to set a breakpoint inside a Perl module's function?
问题
根据我的期望和 https://stackoverflow.com/a/26875706/6607497 ,以下代码应该起作用,但实际上没有:
### 使用 Test::More 的复杂测试程序
### ...
ok 5 - 使用 Auth::KeyStore::SQLite;
### ...
### 模块已经加载
DB<9> b Auth::KeyStore::SQLite:827
第 827 行的 'Auth::KeyStore::SQLite' 无法中断。
### 好吧,这意味着该行上没有有效的指令,但是:
DB<10> l Auth::KeyStore::SQLite::get_key
切换到文件 'lib/Auth/KeyStore/SQLite.pm'。
818 {
819: my ($self, $id, $PIN) = @_;
820: my $key_struct = $self->get_keystruct($id, $PIN);
821: my $result = defined $key_struct ? $key_struct->key_data() : undef;
822
823: $self->add_error(EB_NOT_FOUND, "key data not found for $id")
824 unless (defined $result);
825: print "XXX: get_key: ", $result->as_string(), "\n"
826 if (defined $result);
827: return $result
828 }
DB<11> b 827
DB<12>
### 所以实际上第 827 行是可中断的!
~~~
这是当前运行在 x86-64 上的 SLES 12 SP5 上的 Perl (`perl5 (revision 5 version 18 subversion 2)`,`perl-5.18.2-12.23.1.x86_64`)。
英文:
According to my expectation and https://stackoverflow.com/a/26875706/6607497 the following should work, but did not:
### complex test program using Test::More
### ...
ok 5 - use Auth::KeyStore::SQLite;
### ...
### So the module has been loaded
DB<9> b Auth::KeyStore::SQLite:827
Line 827 of 'Auth::KeyStore::SQLite' not breakable.
### OK, that would mean there is no valid instruction on that line, BUT:
DB<10> l Auth::KeyStore::SQLite::get_key
Switching to file 'lib/Auth/KeyStore/SQLite.pm'.
818 {
819: my ($self, $id, $PIN) = @_;
820: my $key_struct = $self->get_keystruct($id, $PIN);
821: my $result = defined $key_struct ? $key_struct->key_data() : undef;
822
823: $self->add_error(EB_NOT_FOUND, "key data not found for $id")
824 unless (defined $result);
825: print "XXX: get_key: ", $result->as_string(), "\n"
826 if (defined $result);
827: return $result
828 }
DB<11> b 827
DB<12>
### So line 827 is actually breakable!
This is the current Perl of SLES 12 SP5 on x86-64 (perl5 (revision 5 version 18 subversion 2)
, perl-5.18.2-12.23.1.x86_64
).
答案1
得分: 2
没有名为 Auth::KeyStore::SQLite
的文件,因此无法在该文件中创建断点。
命令应该是
b lib/Auth/KeyStore/SQLite.pm:827
英文:
There's no file named Auth::KeyStore::SQLite
, thus the inability to create a breakpoint in that file.
The command should be
b lib/Auth/KeyStore/SQLite.pm:827
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论