Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

a perldbg question about breaks

by misterperl (Scribe)
on Oct 27, 2020 at 16:11 UTC ( #11123218=perlquestion: print w/replies, xml ) Need Help??

misterperl has asked for the wisdom of the Perl Monks concerning the following question:

I know I can set
dbg> b myclass::mymethod
anywhere. Which is very useful. And I can set
dbg> b 123
to break at line 123 in my current scope. But, can I set a break at a line in another class, like
dbg> b myclass::123
(I know THAT doesn't work) but is there a syntax to do that? TY

Replies are listed 'Best First'.
Re: a perldbg question about breaks
by haj (Curate) on Oct 27, 2020 at 16:27 UTC
    What I usually do in this case:
    f myclass.pm b 123
    The f command takes a regular expression, so depending on how many classes you've already loaded, you might be able to abbreviate it to f myc. The debugger will tell you which file it selected so that you can redo the command with a refined regular expression to eliminate unexpected choices.
Re: a perldbg question about breaks
by Fletch (Chancellor) on Oct 27, 2020 at 16:22 UTC

    Don't know if there's a quicker way, but you can use the f filename debugger command to change the context to the myclass.pm file then set a breakpoint with a line number and it'll be relative to the current file.

    I actually did just this the other day so I'm interested if there's a faster way or alternate syntax as well.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: a perldbg question about breaks
by LanX (Cardinal) on Oct 27, 2020 at 16:30 UTC
      OK you explicitly asked about the "package" not the "file". But that's not how it works because the same package can be present in different files. (think of main:: for instance)

      Assuming the normal case that the package scope is only in one single file...

      If this is only a one-time application, finding the correct file-path shouldn't be a problem.

      Otherwise one could write an alias which finds the filename for a provided package and sets the breakpoint.

      Compare also %INC which lists the filenames for used modules.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        ALL replies are ++'s guys TY. I never knew about the f command...

        Bless you all (into the class of angels!)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11123218]
Approved by LanX
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-12-05 17:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?