Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Breakpoint on warn or die in the debugger

by bikeNomad (Priest)
on Jul 14, 2001 at 23:04 UTC ( #96764=snippet: print w/replies, xml ) Need Help??
Description: The Perl debuger is a wonderful tool. By setting its warnlevel or dielevel you can get it to print out a stack trace on a warn or a die. But what if you want to breakpoint on those events? This snippet (when put into a ./.perldb or ~/.perldb file) allows you to set breakpoints (after printing the warn/dielevel stack traces, if any) on these events. Just type sow to stop on warn, or sod to stop on die.

update: made it pass args to oldWarn/oldDie

# Stop on warn (sow)
$DB::oldWarn = $SIG{__WARN__};
$DB::alias{sow} = 's/^sow/\$SIG{__WARN__} = sub { \$DB::oldWarn->(@_) 
+if (\$DB::oldWarn); \$DB::single = 1 }/';
# Stop on die (sod)
$DB::oldDie = $SIG{__DIE__};
$DB::alias{sod} = 's/^sod/\$SIG{__DIE__} = sub { \$DB::oldDie->(@_) if
+ (\$DB::oldDie); \$DB::single = 1 }/';
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://96764]
help
Chatterbox?
[stevieb]: been thinking... if it wasn't for Perl, I believe that I'd be done in tech. I don't do social media or the like, if I'm not coding I'm not on a device at all, and don't miss comms at all when I'm not around. I code for my job (which I like), but I think..
[stevieb]: ...I haven't coughed up my laptop because of Perl.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2017-03-29 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (343 votes). Check out past polls.