how to set break point in specific file using 'perl -d'

Viewed 312

I used the following command to debug program.

perl -d -I "./Dev/lib/" -I "./TestCases/Dev/" ./Dev/bin/mytest.pl

I want to use 'perl -d ' to debug mytest.pl, and there are many *.pm files. I want to use 'f *.pm' to load this pm file and set a break in this pm file, but it shows 'No file matching'. I give the full path of this pm file and the path exactly exists.

DB<4> f /automation_code/TestCases/Tests/Dev/testcase1.pm

No file matching '/automation_code/TestCases/Tests/Dev/testcase1.pm' is loaded.

But if i give the path composed by ./Dev/bin, it will be loaded successfully.

DB<2> f /automation_code/Dev/bin/../lib/Setup.pm



DB<3> f /automation_code/Dev/lib/Setup.pm

No file matching '/automation_code/Dev/lib/Setup.pm' is loaded.
2 Answers

You can see all the files loaded into your program with the command

x values %INC

Edit

the b command in the debugger takes several options.

  • b load *filename* breaks when the file is loaded
  • b compile *subname* breaks when the subroutine is compiled
  • b postpone *subname* will put a breakpoint on a subroutine that doesn't currently exist.

If your framework is trying to emulate the Object oriented approach and the perl file is used as package, then you can try below option:

DB<1> use <package_name_of_file>
DB<2> b <package_name_of_file>::sub_routine_where_you_want_to_break

It worked for me when b postpone and f <file_name> were not working to debug a routine which was going to be loaded at much later point in time.

Related