I needed to run the debugger on a long-running process, and the conditional breakpoint required was too hairy for my poor brain to figure out. After a bit of spelunking in perldoc perldebug and perldoc DB I came up with the code below.
There are a few things to be aware of:
In my real-life example, the setting of $DB::single involved opening sockets to remote machine and database lookups, but in essence was doing nothing more than the example below. It might make more sense to say $DB::single = maybe_breakpoint($foo, $bar, $rat,...) and encapsulate the mess in a subroutine.
Also note that XML::SAX::PurePerl is really, really slow under the debugger. Do not adjust your terminal, it will respond... eventually :)
#! /usr/bin/perl -wd use strict; for my $step( 0..9 ) { print "$step\n"; $DB::single = 1 if $step == 5; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Invoking the debugger on yourself
by fizbin (Chaplain) on Jan 02, 2004 at 19:30 UTC |