4 ms·
If a good debugger is available, it is a great tool to have. But it is just one out of many tools. Some are more effective than others in different situations.
by david-gpu 2y ago
If a good debugger is available, it is a great tool to have. But it is just one out of many tools. Some are more effective than others in different situations.
For example, I rarely used a debugger in my career as an Android driver developer (mostly C), for several reasons.
1. My first step when debugging is looking at the code to build working hypotheses of what sort of issues could be causing the incorrect behavior that is observed.
2. I find assertions to be a great debugging tool. Simply add extra assertions in various places to have my expectations checked automatically by the computer. They can typically unwind the stack to see the whole call trace, which is very useful.
3. Often, there only choice was command-line GDB, which iI found much slower than GUI debuggers.
4. Print statements can be placed inside if statements, so that you only print out data when particular conditions occur. Debuggers didn't have as much fine control.
5. Debugging multi threaded code. Prints were somewhat less likely to interfere with race conditions. I sometimes embedded sleep() calls to trigger different orderings to occur.
- mark_undoio 2y agoFWIW if you're stuck on command line GDB it can be worth learning about TUI mode - "layout tui" which gives you side by side code and debug console. It makes command history not work by default but IIRC "focus cmd" fixes that.
- scotty79 2y agoThere are no good debuggers. They all lack a simple feature of what was the value of given watch in all subsequent calls and in context of values of other watches.