Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: Debugging a program

by perrin (Chancellor)
on Aug 06, 2008 at 16:52 UTC ( #702681=note: print w/replies, xml ) Need Help??

in reply to Re: Debugging a program
in thread Debugging a program

You could just run your code in the debugger and do this when you find a warning you want to stop on:
$DB::single = 1;

Replies are listed 'Best First'.
Re^3: Debugging a program
by hexcoder (Chaplain) on Aug 06, 2008 at 17:22 UTC
    Thanks, that saves the action of setting a breakpoint.

    But even better, I could shift the signal handler code into the debugger initialization file .perldb. Then I do not have to modify the original source code. Works great!

    This is the content of file .perldb (place it in the current or in the home directory):

    sub afterinit { $::SIG{'__WARN__'} = sub { my $warning = shift; if ( $warning =~ m{\s at \s \S+ \s line \s \d+ \. $}xms ) { $DB::single = 1; # debugger stops here automatically } warn $warning; }; print "sigwarn handler installed!\n"; return; }
      ... and under Windows save it to file perldb.ini in your %HOMEDRIVE%%HOMEPATH% directory.

      Then make sure to set the file attributes to read-only. That way it is safe and the debugger is happy.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://702681]
[stevieb]: can anyone recommend a good IDE for C programming that has *proper* vim plugin support? I've tried Eclipse, Netbeans etc and just can't get anything to work properly on Linux. I'm open to paying, but not on some monthly/yearly plan (just a one-off cost)
[stevieb]: I'd go with CLion as it's very similar to what I use already (intelliJ for Perl, Pycharm for Python), but it's a recurring fee every year

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-01-18 19:12 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (163 votes). Check out past polls.