Originally Posted by
esbo
This is probably why I don't use a debugger, it is easy to get bogged down in the detail,
it is usually better to step back and think about what is going on and often quicker, also
I have known programs which run fine when you compile in debug mode but crash when you
compile it normally!
I manage on a few debug printf statements, more thought, less data which is better than
megabytes of data but little thought about what might be wrong!
Well, we've really strayed from the matter at hand thanks to esbo entirely. Somehow, now we're stuck discussing what you feel to be proper practice. We may as well discuss it somewhat seriously. Maybe we'll change your mind one of these days.
Originally Posted by
esbo
I have known programs which run fine when you compile in debug mode but crash when you compile it normally!
I have
written programs which run fine when you compile in debug mode but crash when you compile it normally!
Fixed!
On the whole I imagine that these programs are simply poorly written on your part. The whole purpose of debug mode is to find and fix problems; I can't imagine why it's okay to do it bass ackwards and expect that a release build makes it possible to encounter all the bugs you sneak in. I mean, I depend on my debugger to break execution when the program is about to crash. At least I likely know the area of the problem after that.
I'm not really against people stepping back and thinking, as you noted, but programmers who deserve to be employed already learn to do that. You're also endorsing a system of development that saps their productivity:
The whole notion that you can effectively debug a large project with printf's seems like a bit of a fallacy to me. I can't imagine working on even an open source project where volunteers were depending on printf to bump into errors. To track down a segmentation fault somewhere without the aid of another tool, for example, you would have to bloat your part of the code base considerably with printf calls and write sufficient wrappers for them so all those extra calls aren't compiled at all when you want to release. You probably won't agree with me here, but that seems like an excellent way to tack on kilos of useless information to your intermediate executables. Such a waste of effort! Because even after all of that you still have to hope that you made an appropriate guess at the problem area, then actually fix it.
I'm assuming one hell of a bug, but they happen to people and programmers quite indiscriminately.