Wednesday, March 16, 2011

Tracking down bugs

This is basic, but anyways this is how I do it.

Put a breakpoint before the error occurs (your best guess). Step OVER code (not going into any code) until you run into the exception. Then, set the breakpoint at that procedure call, remove the previous breakpoint, step into that part, and repeat above until you find the bug.

Eventually you end up with a single line of code where the error occurs, that has no function calls. Simplify the call by removing any nested procedure calls and serializing them. E.g. instead of f1(f2(f3)) do x = f3; y = f2(x); z = f1(y). This makes it easier to step and watch the variables.

No comments:

Post a Comment