SPUG: Last night's meeting

Michael R. Wolf MichaelRWolf at att.net
Wed Mar 17 13:57:08 CST 2004


Tim Maher <tim at consultix-inc.com> writes:

[...]

> IMHO, the humble print statement has a significant advantage over
> any interactive-debugging based strategy, which is simply that it
> will still be there if/when the program breaks again, and it can
> easily be re-activated to deliver its benefits again.

I like that. They read like assertions. I know that Tim doesn't like
the "backwards" if statement, but I code them like this:

================
They start out like this:

sub XXX {
    ...
    print "Important debugging info goes here";
    ...
}    

================
I disable them for production release like this:

my $debug = 0;
...
sub XXX {
    print "Entering XXX function\n" if $debug;
    ...
    print "Important debugging info goes here" if $debug;
    ...
    print "Exiting XXX function\n" if $debug;
}    


================
On rare occasions, if my debug output gets too voluminous, I create 2
or 3 levels of verbosity, and shush the yappy ones by creating a
thresshold like this.

my $debug = 1;
...

sub XXX {
    print "Entering XXX function\n" if $debug > 2;
    ...
    print "Important debugging info goes here" if $debug;
    ...
    print "Exiting XXX function\n" if $debug > 2;
}    


I agree that keeping the statements in is useful. They can be enabled
for future debugging, *and* they draw attention to the places that
required analysis in the past. That's great knowledge for the future,
should a bug creep back in.


> AFAIK, there's no way to preserve the activities of an
> interactive debugging session, and replay them at a future time.

I've seen and heard of debugging environments that had huge "profiles"
and "support scripts". They were an IDE in and of themselves. I'm not
confident that they were usable. I haven't seen them lately, but that
doesn't mean that they don't exist. I think that automated regression
tests can serve the same purpose as automated debugging environments.


-- 
Michael R. Wolf
    All mammals learn by playing!
        MichaelRWolf at att.net





More information about the spug-list mailing list