4 ms·
I found that my use of debugging peaked a few years into my software career, and then fell off rapidly. Debuggers are great for single-threaded code, less usefu
by geophile 6y ago
I found that my use of debugging peaked a few years into my software career, and then fell off rapidly. Debuggers are great for single-threaded code, less useful for multithreaded. And close to useless if your problem spans processes.
As the problems I was debugging got more complex, I found that log files became far more useful. The logging is always there (assuming you do a run with the right logging levels selected). You can get a high-level view of what's going on far more easily than in a debugger, which has you rooting around at a very low level. You don't have the phenomenon where you just miss the critical thing while in a debugger, and then you have to laboriously start over. If you miss the critical thing with logging, you turn on more of it and run it again.
If you have one of those bugs that occurs extremely rarely, just keep running the code, and turn on logging. When the problem occurs, you have the evidence leading up to it.
This assumes you have the right logging there to start with. I put a lot of development time into my logging code -- making it informative, compact, readable, carefully selecting what to log and where and at what logging level. I make sure that I get log rotation right, and then I use some simple scripts to download, consolidate, split and search the log files.
"Desperately perusing source code": Yes, you need to read and understand code in order to debug it. You obviously know that, so I'm not sure what "desperately" is meant to convey.
- nikanj 6y ago>You don't have the phenomenon where you just miss the critical thing while in a debugger, and then you have to laboriously start over. If you miss the critical thing with logging, you turn on more of it and run it again. This is rather confusing to be honest. Are you saying restarting the software is hard, or that restarting it is easy? If you just missed the critical thing, just add a conditional breakpoint ("Stop here if ptr is null") and restart the software.
- geophile 6y agoRestarting is easy. But you know how it is. You get to your breakpoint, go forward carefully, and then step over something you should have stepped into. Oops, start again.