Set breakpoint from .perldb init file

梦想的初衷 提交于 2021-01-27 23:21:33

问题


I am experimenting with the .perldb rc file and trying to set a breakpoint. Here is a small sample script that I use for testing (p.pl):

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

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

Then, I created the following .perldb file in the current directory:

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

(Note that this file should not have write permission by other than yourself (i.e. : chmod 644 .perldb) or else the debugger will not load it). Then I run the script under the debugger:

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

As seen the breakpoint at line 7 is not respected. What can be the problem here?


回答1:


Changing your ".perldb-File" to

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

should do the job.

$ 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";


来源:https://stackoverflow.com/questions/61571488/set-breakpoint-from-perldb-init-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!