When
everything else
fails, you're left with
printf(). Maybe your program takes 3
hours to get to its failure point
when optimised, and will never get there if you
compile with
symbolic information. Or maybe doing that moves data around, and a
memory overflow that was crashing your
program no longer does, so the debugger doesn't help.
Whatever the reason, you need printf(). Just remember to call it fprintf(stderr,...), so your log isn't on a buffered stream.