I'm afraid I couldn't make neither b compile nor b postpone work for me, with different attempts to "compile" a new sub.
Here my experiments using eval , a typeglob and use (applying the technique from Re: Debugger demos/snippets)
Not sure what is going wrong ...
Haven't tested breaking AUTOLOAD tho
use strict;
use warnings;
use Data::Dump qw/pp dd/;
BEGIN {
push @DB::typeahead, split /\n/, <<'__DB__';
B * # delete all Breakpoints
# --- these should fail
b testsub1
b testsub2
b testsub3
b postpone testsub1
b compile testsub1
b postpone testsub2
b compile testsub2
b postpone testsub3
b compile testsub3
L # list breakpoints
use lib '.';
use db_demo_postpone qw(testsub3);
L
c
__DB__
# use after debug-commands
# use lib '.';
# use db_demo_postpone qw(testsub3);
}
eval <<'__CODE__';
sub testsub1 {
warn "inside testsub1";
}
__CODE__
*testsub2 = sub {
warn "inside testsub2";
};
warn "before";
testsub1();
warn "after1";
testsub2();
warn "after2";
testsub3();
warn "after3";
package db_demo_postpone;
use strict;
use warnings;
use Exporter qw(import);
our @EXPORT_OK = qw(testsub3);
sub testsub3 {
warn "inside testsub3";
}
warn "testsub3 compiled";
1;
OUTPUT:
perl -d d:/tmp/pm/db_demo_postpone.pl
Current directory is d:/tmp/pm/
Loading DB routines from perl5db.pl version 1.57
Editor support enabled.
Enter h or 'h h' for help, or 'perldoc perldebug' for more help.
auto(-23) DB<1> B * # delete all
+Breakpoints
Line * # delete all Breakpoints no
+t breakable.
auto(-22) DB<2> # --- these should fail
auto(-21) DB<3> b testsub1
Subroutine main::testsub1 not found.
auto(-20) DB<4> b testsub2
Subroutine main::testsub2 not found.
auto(-19) DB<5> b testsub3
Subroutine main::testsub3 not found.
auto(-18) DB<6>
auto(-17) DB<6> b postpone testsub1
auto(-16) DB<7> b compile testsub1
auto(-15) DB<8>
auto(-14) DB<8> b postpone testsub2
auto(-13) DB<9> b compile testsub2
auto(-12) DB<10>
auto(-11) DB<10> b postpone testsub3
auto(-10) DB<11> b compile testsub3
auto(-9) DB<12>
auto(-8) DB<12> L # list breakp
+oints
Postponed breakpoints in subroutines:
main::testsub3 compile
main::testsub1 compile
main::testsub2 compile
auto(-7) DB<13>
auto(-6) DB<13> use lib '.';
auto(-5) DB<14> use db_demo_postpone qw(testsub3);
testsub3 compiled at db_demo_postpone.pm line 13.
at db_demo_postpone.pm line 13.
require db_demo_postpone.pm called at (eval 17)[c:/Strawberry/perl
+/lib/perl5db.pl:738] line 2
main::BEGIN() called at db_demo_postpone.pm line 0
eval {...} called at db_demo_postpone.pm line 0
eval 'no strict; ($@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;pack
+age main; $^D = $^D | $DB::db_stop;
use db_demo_postpone qw(testsub3);;
' called at c:/Strawberry/perl/lib/perl5db.pl line 738
DB::eval called at c:/Strawberry/perl/lib/perl5db.pl line 3138
DB::DB called at d:/tmp/pm/db_demo_postpone.pl line 45
auto(-4) DB<15>
auto(-3) DB<15> L
Postponed breakpoints in subroutines:
main::testsub3 compile
main::testsub1 compile
main::testsub2 compile
auto(-2) DB<15>
auto(-1) DB<15> c
DB<15> L
Postponed breakpoints in subroutines:
main::testsub3 compile
main::testsub1 compile
main::testsub2 compile
DB<15> c
before at d:/tmp/pm/db_demo_postpone.pl line 57.
at d:/tmp/pm/db_demo_postpone.pl line 57.
inside testsub1 at (eval 20)[d:/tmp/pm/db_demo_postpone.pl:45] line 2.
at (eval 20)[d:/tmp/pm/db_demo_postpone.pl:45] line 2.
main::testsub1() called at d:/tmp/pm/db_demo_postpone.pl line 59
after1 at d:/tmp/pm/db_demo_postpone.pl line 61.
at d:/tmp/pm/db_demo_postpone.pl line 61.
inside testsub2 at d:/tmp/pm/db_demo_postpone.pl line 52.
at d:/tmp/pm/db_demo_postpone.pl line 52.
main::__ANON__[d:/tmp/pm/db_demo_postpone.pl:53]() called at d:/tm
+p/pm/db_demo_postpone.pl line 63
after2 at d:/tmp/pm/db_demo_postpone.pl line 65.
at d:/tmp/pm/db_demo_postpone.pl line 65.
inside testsub3 at db_demo_postpone.pm line 10.
at db_demo_postpone.pm line 10.
db_demo_postpone::testsub3() called at d:/tmp/pm/db_demo_postpone.
+pl line 67
after3 at d:/tmp/pm/db_demo_postpone.pl line 69.
at d:/tmp/pm/db_demo_postpone.pl line 69.
DB<15>
As you can see no break happened :/
|