Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: "omniscient debugging" for Perl

by magog (Beadle)
on Jul 05, 2005 at 19:18 UTC ( [id://472569]=note: print w/replies, xml ) Need Help??


in reply to "omniscient debugging" for Perl

A perl tool that sorta kinda works this way is Devel::Trace

perl -d:Trace program.pl

Mind you, it only prints out the flow of execution; it doesn't actually let you inspect variables or anything like that. It's still pretty useful, though. I just wish I could find a way to switch it on and off at runtime under mod_perl. :)

Michael

Replies are listed 'Best First'.
Re^2: "omniscient debugging" for Perl
by pemungkah (Priest) on Jul 05, 2005 at 23:34 UTC
    A quick glance at the source shows that MJD is using the global $TRACE to decide if the trace output should be printed. Just set $TRACE = 0 at the top of your program, set it to a non-zero value when trace should start, and back to zero again when you want it off again.

    Simple.

      Thanks for the tip, pemungkah!

      The other problem is how to get the -d:Trace option to work under mod_perl.

      Here's how to do it:

      Add the following section to httpd.conf:

      <Perl> $Devel::Trace::TRACE = 0; </Perl>

      And start the server like this:

      $ PERL5OPT=-d:Trace sudo /etc/init.d/httpd restart

      Then in your code you can write:

      $Devel::Trace::TRACE = 1; # some buggy code $Devel::Trace::TRACE = 0;

      Problems:

      • Server spits out a mess of trace info before $TRACE is set to 0
      • Trace info (and there's a lot of it) goes to the error log, which is hard to manage

      I think I'll try making a patch to allow turning off $TRACE via the command line, and to allow sending the trace info to a different file.

      Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://472569]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found