|
|
|
|
|
by otikik
1206 days ago
|
|
The fact that the author is "commenting things out" makes me think that they don't have access to a debugger on their environment. When I find myself on that particular situation, I tend to: * Add lots of logs (e.g. "entered function X with parameters a, b, c", "exited function X, return value W").
* "Make things explode in a useful way". This is, cause an error on purpose, which halts the program. This is useful for debugging server-like environments where many different things might happen at the same time, so the logs become insufficient. It is way slower than having a debugger doing step-by-step scrutiny, but it can be done. |
|
Your debugger may not work with a multithreaded program. Or it might cause the bug to disappear because it changes scheduling/execution order. Printf is more reliable in this context.
Or they may be debugging hardware, which the debugger can't step into. Or debugging object code without symbols.
Or they may be debugging a distributed system with remote code execution and asynchrony.
Or they may be debugging a language that doesn't have an execution stack.
Or they may be debugging an issue that only happens in production or customer machines that they can't access directly.
Or they may be debugging an issue that only happens very rarely, longer than the patience of a programmer to wait for a breakpoint.
Debuggers are one tool we have available, but hardly the only tool, and definitely not a complete tool.