Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

debugging

perl

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).

like image 929
Paul Serikov Avatar asked Jan 27 '23 18:01

Paul Serikov


1 Answers

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

like image 132
Pradeep Avatar answered Jan 29 '23 15:01

Pradeep