![]() This is known as using break points and it all revolves around stopping your program at the points you want to inspect. This includes looking at the value of variables in scope, stepping through the code one line or one function at a time, and checking the stack trace. One key concept in using an interactive debugger is the ability to stop your program at certain points so you can observe the current state. Other times, it's an indirect way to resolve the issue. Sometimes, this means eliminating possible causes in order to find the real problem. ![]() This excerpt from The Practice of Programming emphasizes the importance of gathering sufficient data and facts before undertaking the task of debugging. ![]() Once we have a full explanation, we'll know what to fix and, along the way, likely discover a few other things we hadn't expected. So we must think backwards from the result to discover the reasons. Something impossible occurred, and the only solid information is that it really did occur. How could that happen? Reason back from the state of the crashed program to determine what could have caused this.ĭebugging involves backwards reasoning, like solving murder mysteries. Now you know something of what happened, and where. Look at any debugging output before the crash if possible get a stack trace from a debugger. Examine the evidence in the erroneous output and try to infer how it could have been produced. ![]() Experienced programmers would love to do the same, but they know that, realistically, most problems are their own fault.įortunately, most bugs are simple and can be found with simple techniques. Now what?īeginners have a tendency to blame the compiler, the library, or anything other than their own code. My program crashed, or printed nonsense, or seems to be running forever. ![]()
0 Comments
Leave a Reply. |