Re: Problem tracking down an error
On Wed, 2 Dec 2009, Arne Vajh?j wrote:
Martin Gregorie wrote:
I have never got on with debuggers, so I tend to load up my programs
with trace statements that output to stderr. So far, so conventional,
however I also add command line options to control debugging detail by
setting a 'debug' integer and always leave this stuff in production
code because the speed impact of testing integer values and skipping
debug statements is minimal and the diagnostic value of this trick
during live running is huge.
I completely agree that debuggers are great for debugging toy programs,
but log output is often much better for real world programs.
I think they're for completely different purposes. Logging is for figuring
out roughly where an problem is - your application is behaving badly, so
you have a look at the logs , and you see warnings suggesting something's
wrong in the furnace or whatever. A debugger is for figuring out why a
component is causing a problem - you attach to the furnace and fire
various inputs at it and follow execution, and see where invariants are
violated, where the wrong branch is being taken, where nulls are creeping
in, etc.
I find i get a lot more use out of the debugger early on in development,
when i'm actually writing something and its internal behaviour is still in
flux. Later on, when things are more about integration and discovering
corner cases, it's often "hmm, i see the turntable is crashing when i load
colours with a lot of blue in them - oh yeah, i only allowed forty bytes
for blue, that's what it is", and you don't even need to look hard at the
code or debug to figure out the solution.
tom
--
If goods don't cross borders, troops will. -- Fr