Paul Serikov
Paul Serikov

Reputation: 3131

How to redirect debug trace of perl script to file when using NonStop debugger option?

I'm using the standard Perl debugger to trace calls:

$ cat test.pl 
sub test { print "Hello world" }
test();
$ PERLDB_OPTS="NonStop frame=1" perl -d test.pl > /dev/null
Package test.pl.
  entering DB::Obj::_init
  entering main::test

How to redirect output to file?

If I make

PERLDB_OPTS="NonStop frame=1" perl -d test.pl > /dev/null 2>trace.txt

trace.txt is empty.

It doesn't look like that debug output printed on standard streams (STDERR or STDOUT both).

Upvotes: 4

Views: 541

Answers (1)

Pradeep
Pradeep

Reputation: 3153

Use Perl option LineInfo=db.out to output to a file.

Example:

PERLDB_OPTS="NonStop frame=1 LineInfo=db.out" perl -d ./test.pl

Sample output:

entering CODE(0x14c53f0)
entering CODE(0x14ce788)
 entering CODE(0x164f2a0)
  entering strict::import
 entering CODE(0x164f270)
  entering warnings::import
 entering CODE(0x16168b8)
  entering CODE(0x16160f0)
   entering CODE(0x15fc378)
   entering CODE(0x1601a10)
    Package /usr/share/perl5/warnings/register.pm.

More info at https://perldoc.perl.org/perldebug.html#Configurable-Options

Upvotes: 8

Related Questions