Question:
When debugging an application, why would you not want to single-step through every procedure or function?
2014-03-03 09:46:30 UTC
When debugging an application, why would you not want to single-step through every procedure or function?
Three answers:
Andrew S
2014-03-03 10:08:23 UTC
It takes time and bogs you down in utterly irrelevant details about code that is already tested and working. Even a moderately sized program may need to execute millions of instructions before it reaches the point of interest if it has complex initialisation or has to create large data structure first before you can test them. That simply isn't practical. Instead you have a number of techniques for breaking off execution under programmer control - inserting breakpoints, executing a function until it returns, backtracing from a failed assert() or (on many systems at least) using watchpoints which trigger when a particular variable has a certain value. Each of these allow you to quickly skip over irrelevant code and quickly isolate the particular point of interest.
Albert0
2014-03-03 10:29:31 UTC
As the others noted, single stepping taskes a lot of time (could be infinite time, in fact) but another consideration is that having execute every line of code doesn't come close to exercising every function. For instance, every decision has to properly handle values that aren't near the decision point, values adjacent tp the decision point on each side, and the value equal to the decision point... so full testing of a single decision would take at least 5 passes through the code -- BUT since any faulty function can hide faults in other functions, to fully test the program, you would have to do all of those tests for every combination of conditions that could preced it in the program's execution.



So, lets say you have a program with only 5 decision points -- testing each 5 ways with all of the combinations of tests for the others would involve over 3,000 executions of the program... so multipy that imes the length of time it takes to run one execution and it becomes really obvious why there is no practical way to verify your program is correct by single stepping through it.
?
2014-03-03 09:50:04 UTC
Because it takes ages.

A computer program typically executed millions of commands per second, and running a program one command per second will take hours just to get to the part you want to debug.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...