Presentation is loading. Please wait.

Presentation is loading. Please wait.

Debugging CSCE 121.

Similar presentations


Presentation on theme: "Debugging CSCE 121."— Presentation transcript:

1 Debugging CSCE 121

2 Early Bug Hopper received her PhD in Mathematics from Yale University in She left a faculty position at Vassar to join the Navy in 1943, and was assigned to work on the “Mark I Electromechanical Computing Machine.” It was 51 feet long, 8 feet high, and 8 feet deep. From there, Hopper went on to work in academia, industry, and the military, staying on the cutting edge of computing. Her best known innovation is the compiler, but she is also responsible for COBOL, FORTRAN, and many other computing innovations. Whether or not Hopper coined the term “computer bug” is a source of some controversy. The Navy promotes the idea that it was Hopper that squashed the first computer bug; there is an actual photo of the offending insect on Hopper’s US Navy webpage: (image in slide) Somehow, “computer moth” just doesn’t have the same resonance. If you dig a little deeper, though, it appears the use of “bug” to describe a technical problem has a complex history–and in fact, may not have originated with Grace Hopper at all: “The OED Supplement records sense (4b) of the noun bug (“a defect or fault in a machine, plan, or the like”) as early as In that year the Pall Mall Gazette reported (11 Mar: 1) that ‘Mr. Edison … had been up the two previous nights discovering a ‘bug’ in his phonograph–an expression for solving a difficulty, and implying that some imaginary insect has secreted itself inside and is causing all the trouble.’…. This meaning was common enough by 1934 to be recognized in Webster’s New International Dictionary: ‘bug, n…. 3. A defect in apparatus or its operation… Slang, U.S.’” (citation) So, the “actual bug” notation in the lab notebook above probably reflects the amusement of the technician at finding a physical bug, when the word bug was already in use as slang for a problem. It does appear that the term “debugging” came into use around Hopper's time period, but I haven’t seen any evidence firmly tying it to this particular moth. Oh well. BTW, The Grace Hopper Celebration of Women in Computingis the largest technical conference for women in computing. Get involved!

3 “If debugging is the process of removing software bugs, then programming must be the process of putting them in.” Edsger Dijkstra

4 Debugging Figuring out what is wrong with the code we wrote…
Analyze problem Compare program results with hand executed results. A couple of tools Judicious use of print statements (i.e. cout) Careful use of debugging tool.

5 Print Statements Sometimes you have no choice.
Print out data at different points in the program. Make certain you can determine where a particular output comes from. Examples “Starting function X” “Ending function X” “Value(s) before processing/calculation” “Value(s) after processing/calculation”

6 Debuggers Allow you to look at things while the program is running.
At any point in the program, you can see the call stack. Local variables and parameter values.

7 Breakpoints Breakpoints can be placed on any executable statement in your code. When the program executes, it will pause at a breakpoint. You can look at variable values, etc.

8 Moving Through Code Once stopped you can execute the code line by line. Three options Step Over Move to the following statement. This will not enter any functions called on the current line (unless it finds another breakpoint in a function called before the next line). Step Into Go into the next function on the current line (if there is one.) Note: functions may be nested. Step Out Stop going line by line in the current function and move to the next line of code in the calling function.

9 More? There is a lot more out there regarding debugging.
However, these basics should help you tremendously as you gain experience programming. If you find you need more, you can do some self-teaching!


Download ppt "Debugging CSCE 121."

Similar presentations


Ads by Google