Alan
Alan

Reputation: 2178

How do I restrict Perl debugger output to lines in my own script?

I'm running the debugger in noninteractive mode, with the output written to a file. I want to print out each line of my Perl script as it executes, but only lines in the script itself. I don't want to see the library code (File::Basename, Exporter::import, etc.) that the script calls. This seems like the sort of thing that should be easy to do, but the documentation for perldebug only discusses limiting the depth for dumping structures. Is what I want possible, and if so, how?

Note that I'm executing my program as follows:

PERLDB_OPTS="LineInfo=temp.txt NonStop=1 AutoTrace=1 frame=2" perl -dS myprog.pl arg0 arg1

Upvotes: 3

Views: 156

Answers (2)

mob
mob

Reputation: 118605

By default, Devel::DumpTrace doesn't step into system modules, and you can exercise fine control over what modules the debugger will step into (it's not easy, but it's possible). Something like

DUMPTRACE_FH=temp.txt perl -d:DumpTrace=quiet myprog.pl 

would be similar to what you're apparently trying to do.

Devel::DumpTrace also does a lot more processing on each line -- figuring out variable values and including them in the output -- so it may be overkill and run a lot slower than perl -dS ...

(Crikey, that's now two plugs for Devel::DumpTrace this week!)

Upvotes: 6

Andy Lester
Andy Lester

Reputation: 93666

Are you talking about not wanting to step through functions outside of your own program? For that, you want to use n instead of s.

From perldebug:

   s [expr]    Single step.  Executes until the beginning of another
               statement, descending into subroutine calls.  If an
               expression is supplied that includes function calls, it too
               will be single‐stepped.

   n [expr]    Next.  Executes over subroutine calls, until the beginning
               of the next statement.  If an expression is supplied that
               includes function calls, those functions will be executed
               with stops before each statement.

Upvotes: 1

Related Questions