Set arbitrary breakpoint in debugger

390 views Asked by At

I have been using the perl interactive debugger (basically perl -d script)
I have a script that has quite a lot of modules imported and I need to debug a problem.
What I do is start the debugger and go over lines, stepping into where necessary.
But this is tedious as I need to step into many lines of code and function calls.

Question: Let's say that after going over the lines of code I eventually step into function A::B::C::foo() of some module where is the problem I am debugging.
Is there a way to set a break point in that function in the beginning of the debugging session so that I jump there directly instead of going over the code line by line until I reach there?
I know that I can add a break point in the same file my debugger is currently but how can I add a breakpoint in a line that is outside of the debugger's scope at this point (to some arbitrary file/module that eventually the debugger would have reached)?

Note:
Just to clarify: It is not like A::B::C::foo() is in line X of the script. It is eventually called after going down the call chain of a lot other functions in many modules

3

There are 3 answers

0
Kim Ryan On BEST ANSWER

You may set a break point by defining file name and then line number

b YourModule.pm:line_number

where line number is inside the module function you want to break at.

2
choroba On

You can set a breakpoint to a subroutine with the documented b sub syntax. In this case, just use

b A::B::C::foo
c
0
JGNI On

You can even put a breakpoint on a sub that hasn't been loaded/defined yet using the postpone option:

b postpone Name::Of::Sub::Yet::To::Be::Created