3 ms·
I'm trying to get myself to use debuggers more often, but I find that just modifying the code to print stuff, then inspecting the result, allows me to better fi
by hibbelig 5y ago
I'm trying to get myself to use debuggers more often, but I find that just modifying the code to print stuff, then inspecting the result, allows me to better figure out what went wrong. Say I have a small sample data set where I expect a loop to run three times, but it runs four times. It's really easy to see in the printout, but counting the steps in the debugger is tedious.
- chii 5y ago> counting the steps in the debugger is tedious. that's a debugger UX problem - the debugger should have a way of setting conditional breakpoints, and allow you to evaluate expressions (and optionally print out expressions). The only time i've found the debugger lacking is when you have to debug concurrent or async code, and the act of debugging changes the execution to either hide or present a different bug.
- hibbelig 5y agoI have yet to see a debugger that counts the times a breakpoint is hit. But maybe rr and it’s ilk do. I find it really valuable that I can just read a text file to spot some patterns even if I don’t know beforehand which patterns I’m looking for.
- nocturnial 5y agoVisual studio debugger can track hit counts. I would be _very_ surprised if gdb can't do it as well. With gdb you can even script what it needs to do when it hits a breakpoint. So even if it's not built-in, it's scriptable. edit: You can even trigger a break or commands if a breakpoint hits a certain number of times: https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Breakpoint-Commands.html https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Breakpo... So the hit count is definitely stored.