On Sun, May 12, 2024 at 10:26:55PM +0200, Tomasz Rola wrote: > I am sure gdb has some merits but for whatever C programs I wrote so > far, a much more useful debugging technique was putting printf in > right places and isolate the problem, and after that doing some mental > work to actually understand why this seemingly correct line does > something so wrong.
Exactly. What you describe is likely the best method to fully understand the code, what it's supposed to do and what it actually does, and by extension avoid making the same coding mistakes in the future. Finding and fixing a single error with gdb doesn't have the same educational benefit, nor in many cases such a guarantee that other nearby bugs have also been noticed. > Besides, all debuggers introduce their own perturbation and thus > certain classes of error will be very hard to catch with them, if > ever. But you do realise that adding printf() calls to the code can also change, for example, the memory layout that the compiler uses, so certain memory allocation bugs might become more or less easily triggerable?