HACKER Q&A
📣 tuomeyp

How to Get Better at Debugging?


I think it is the main thing that holds me back as a developer is that I take too long to debug problems. As it is a large part of my job I would like to get better at it.

I have tried * Rubber Ducking - Explaining the problem to your rubber duck * Invert Thinking - What do I think is true about this system that might be incorrect

These techniques have helped me greatly but I was just wondering if anyone had any other tips or perhaps a chapter of a book they could point me to that would be beneficial


  👤 db48x Accepted Answer ✓
Get a better debugger. rr (rr-project.org) can record your program and let you run it both backwards and forwards as you investigate the problem. This is incredibly powerful. Suppose you've discovered that a variable in memory has the wrong value. With rr you can set a watchpoint on the memory location and run the program backwards until it stops at the exact point in the code where that value was written to memory. You can use this to trace all incorrect values back to their source.

Pernosco (pernos.co) is an even more powerful debugger. It takes an rr recording and gives you an omniscient view of it. It's difficult to describe how powerful this is, but you should definitely watch the demos on their webpage. I think that this is what all competitive debuggers will be like in 10 years. (Any debugger that doesn't gain these features will simply fall out of use.)