When your program is misbehaving, you have a lot of tools at your disposal to capture the information you need to understand the problem and fix it. You can categorize these into levels. Level one is to use is a debugger in single stepping mode. Sometimes, though, it's hard to get to the exact place where the problem is occurring so level two would be to add in conditional breakpoints. If breakpoints interfere with the operation, level three is to use watchpoints. If your application is deployed and you can't use debugging tools, then level four is to output a walkback to a file at the time of the crash. If the program isn't actually crashing then level five is to output information to log files that you can analyze. If logging to a file is too slow, level six is to instrument the code with event tracing buffers stored in memory that capture interesting events when they happen. In rare cases years ago, I've had to resort to level seven hardware assisted debugging where I used a logic analyzer on the processor or a chip to see what it's doing. As the level of debugging tool goes up, it becomes harder to use and harder to analyze but they give you debugging options when the going gets tough.
Download