4 ms·
Print statements are really really good for debugging because they give you a timeline of "things that happened that I was interested in". It's like using Goog
by mark_undoio 5y ago
Print statements are really really good for debugging because they give you a timeline of "things that happened that I was interested in".
It's like using Google Maps to see the general shape of a landscape. A debugger is generally more like Google Streetview - you get strictly more detail and it makes some problems way easier to solve. It's just not always the easiest way to get an overview.
With that in mind, though, GDB's "Dynamic Printf" is pretty cool: https://sourceware.org/gdb/onlinedocs/gdb/Dynamic-Printf.html https://sourceware.org/gdb/onlinedocs/gdb/Dynamic-Printf.htm...
You basically configure GDB to add printfs to the program you're debugging, without having to rebuild it. You just run under GDB and the prints will run. As a bonus, you can also interact using normal debugging commands too.