Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl Debugger: setting a breakpoint in another file with 'b'

by hexcoder (Curate)
on May 15, 2015 at 23:20 UTC ( [id://1126826]=note: print w/replies, xml ) Need Help??


in reply to Perl Debugger: setting a breakpoint in another file with 'b'

If you want to stop at a function mod::subname in a not-yet-loaded module, you can use the
b postpone mod::subname [condition] debugger command. It will delay the setting of the breakpoint until the module has been loaded. The filename:linenumber syntax is not available, as far as I know.

So  b postpone UsefulModule::do_stuff should work.

This is described in the book "Pro Perl Debugging" from Richard Foley and Andy Lester.

Replies are listed 'Best First'.
Re^2: Perl Debugger: setting a breakpoint in another file with 'b'
by LanX (Saint) on May 16, 2015 at 10:56 UTC
    no book needed :)

    lanx@lanx-1005HA:~$ perl -de0 Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1> h b b Sets breakpoint on current line) b [line] [condition] Set breakpoint; line defaults to the current execution line; condition breaks if it evaluates to true, defaults to '1'. b subname [condition] Set breakpoint at first line of subroutine. b $var Set breakpoint at first line of subroutine referenced by + $var. b load filename Set breakpoint on 'require'ing the given file. b postpone subname [condition] Set breakpoint at first line of subroutine after it is compiled. b compile subname Stop after the subroutine is compiled. DB<2>

    see also perldebug

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Incidentally, I realised last night that you can even start a Perl debugger REPL using a divide by zero:

      perl -de1/0

      And it still works (i.e. starts the debugger and puts you into a "Perl shell"), although you do get an 'Illegal division by zero' error if you then execute any of the 'stepping' commands.

      So I wonder if there is anything you can put after perl -de that won't let the debugger start?

      Danke sehr, Rolf... I had not tried 'b postpone', only 'b compile' and 'b load', which hadn't apparently worked. I shall try 'b postpone'!

      It was staring me in the face the whole time.

Re^2: Perl Debugger: setting a breakpoint in another file with 'b'
by Dumu (Monk) on May 18, 2015 at 13:56 UTC
    Thanks hexcoder, I shall try to get a copy of that book. I have alredy enjoyed Perl Debugged by Peter Scott and Ed Wright, which is useful despite being a bit of an old book.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126826]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-20 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found