4 ms·
This is one of those funny things. Debuggers are amazingly useful as a print statement machine. You get prints for every line. You can stop and think as the pro
by aunderscored 3y ago
This is one of those funny things. Debuggers are amazingly useful as a print statement machine. You get prints for every line. You can stop and think as the program executes. But at the same time, most bugs can be found with, as said, prints and thought.
I generally reach for a debugger when code is complex enough that I don't know where to begin putting my prints. But often end up reducing to prints and other output when I get close to the issue.
That said. For buggy code, where the bug appears seldomly, conditional breakpoints are a lifesaver.
- CuriousCosmic 3y agoAnother aspect of this is when you only know about the failure after it has happened (such as with segfaults that can't be reproduced with tools like valgrind). Being able to use something like `rr` to record the entire runtime and then rewind it to the point where the program explodes can be a life saver. I'm not big on using a debugger but when all else fails, having access to one can be the difference between a swiftly identified and resolved bug and weeks or months of hair pulling and stress.
- aunderscored 3y agoAgreed. Much too useful to decry as useless. But also like everything, entirely timing specific