Search code examples
perlperldb

Set breakpoint from .perldb init file


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?


Solution

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