Is it possible to set a breakpoint in the Perl debugger without changing the source?

I go through the code of another user to find what breaks mine under a certain, unchecked (do not ask me why the test environment gives different results from using it live, which I am trying to find out). Every time I go a little deeper into the code before I crash, is there any way to set a breakpoint without changing the source code? so I don’t need to do the next, step, next, next, next, every time? or change the source every time. Also note that I need to go through several files, as these programs use libraries extensively, and the error itself is in one of these libraries. So, for example, I know that I need to continue execution until I press the line number of the file. In addition, libraries load libraries, I had at least 3-5 libraries in depth of the last one that I checked.

Note: I'm new to debuggers in general

+4
source share
2 answers

It looks like you want the b command in the Perl interactive debugger, which you can use to set future breakpoints. Or maybe c , which works like GDB until if an argument is given.

You can also automatically set specific breakpoints every time you start the debugger with afterinit in .perldb . Or use the R command, which restarts the debugger (and the program being debugged), while maintaining breakpoints and other information.

+6
source

You can use a combination of command b , command f , the contents of % INC and c to quickly navigate your code.

c allows you to continue execution until you reach this line. This makes it easy to jump to an arbitrary point.

If you want to break a specific point in a module, look at the entry for that module in % INC (the key will be β€œSome / Module.pm” if the module was Some :: Module ). The value for this key is the file from which the module was loaded. If the module is not already loaded, you can use it on the debugger command line, then see % INC .

After you have the file containing the code where you want to set the breakpoint, execute f filename to switch the debugger l (list) and text search commands ( / and ? - forward and backward, respectively) to look at this file, then set the desired breakpoint and c .

+3
source

Source: https://habr.com/ru/post/1335713/


All Articles