rdos wrote:If the code debugged depends on timing, any insertion of code of whatever triviality might change the behavior. Printf is just a major distrurber because it takes time to execute.
To be honest, the worst type of these bugs is where different threads are interacting with each other (race conditions etc.). Both printf debugging, and single stepping threads will move/hide these bugs. As may just running the code again.
That said, both printf and single-step debugging are essential in different circumstances.
Most of the code I write is computational chemistry code, and often the place where a bug shows up (where you notice a numerical discrepancy) is very different to what caused a slight numerical slip, which may be very deeply hidden far from any data output. I find stepwise debugging here next to useless, as generally all of the sections of the code seem to be doing something reasonable - and even isolating which bit to step through is not easy in 70000 odd lines of code. Careful use of printf statements to check consistency between elements of input and output of different sections is far easier to isolate the problem to a section - and then the bug is often obvious to inspection, not needing single-stepping line by line. Lines of code do tend to do what they say they will, after all...