1 / 55

Lecture 9

Lecture 9. Introduction to Debugging. Precision: The High Standards of Computing. Humans are imprecise and error-prone Computers demand precision. Be Accurate. Developing an awareness for mistakes l for 1, O for 0, for /, and so forth Corbel zero (o) and oh (o)

candie
Download Presentation

Lecture 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 9 Introduction to Debugging

  2. Precision: The High Standards of Computing • Humans are imprecise and error-prone • Computers demand precision

  3. Be Accurate • Developing an awareness for mistakes • l for 1, O for 0, \ for /, and so forth • Corbel zero (o) and oh (o) • Special characters: “, ”, ‘, ’ • Case sensitivity

  4. Be Observant • Pay attention to computer feedback • Browser’s formatting of web page • Warning dialogs

  5. What’s the Problem? • Debugging • Process to figure out why something isn’t working properly • “Troubleshooting” • Debugging relies on • Logical reasoning • Experience

  6. Whose Problem Is It? • Weare almost always part of the problem • Two of the three possible problems involve us • wrong data • wrong command • broken system – less likely

  7. Steps to Debugging • Check that error is reproducible • Computers are deterministic • Start by trying to reproduce the problem

  8. Steps to Debugging • Know exactly what the problem is • Pinpoint • Sequence of operations may occur after an error

  9. Steps to Debugging • Check all of the “obvious” error sources • Checking inputs, connections, links, etc.

  10. Steps to Debugging • Isolate the problem by dividing the operation into working and non-working parts • Theorize about where the problem is located • Collect information • Limit untested assumptions** • Eliminate possibilities

  11. Debugging Recap Guidelines • Key points to debug • Reproduce • Determine the problem exactly • Eliminate the “obvious” • Isolate problem • If stuck, check assumptions and conclusions** • Make predictions about what should happen and verify

  12. A Debugging Case Study • HTML page • Want page to look like this

  13. Look Closely At the Page Working Page Not Working Page..Firefox

  14. Look Closely At the Page Working Page Not Working Page..Safari

  15. Look Closely At the Page Working Page Not Working Page..Chrome

  16. Look Closely At the Page Working Page Not Working Page..IE

  17. Look Closely At the Page • Study output closely • What’s right and wrong? • Browsers display buggy page differently • Correct pages should render same way

  18. Reproduce the Error • Begin debugging the HTML • Can we reproduce the error? • Close the browser and reopen the file • Definitely a problem with our HTML!

  19. Determine the Exact Problem • Pinpoint • Look at the displayed page • Pick one error to focus on

  20. Eliminate the Obvious • Once problem is known • Look for the “obvious” causes • Most obvious problem with missing image? • File isn’t where it should be • Is image in the pic folder? Yes

  21. Eliminate the Obvious • Next most obvious error is … • Spelling the file name • Oops, path doesn’t mention ‘pic’ folder • Fix tag and image appears! • One down!

  22. Focusing the Search • Identify next problem • Pinpoint • Eliminate the obvious • Divide up the process

  23. The “Divide Up the Process” Process • Go through style section • For each element • Delete the entire element • Save the file; refresh the display • What changed? • If only removed element, then undo deletion and continue

  24. The “Divide Up the Process” Process • Stop when removing element restores other formatting • We’ve separated broken from unbroken

  25. The “Divide Up the Process” Process • Drill down on CSS element • Repeat division process for parts of line • Sometimes easier to reenter text

  26. (Tools > Web Developer > Error Console) • In Firefox, go to Error Console • Clear whatever errors have accumulated • Refresh the page

  27. Find the Error(s) img{padding:6; border-width:1px;border-style:solid; border-color:burlywood;} table{outline:solidburlywood thin; font-size:14px} th (text-align:center;border-width:1px; border-style:solid; border-color:burlywood:padding:3px}

  28. Find the Error(s) (2) img{ padding: 6; border-width: 1px; border-style: solid; border-color: burlywood; } table { outline: solid burlywood thin; font-size: 14px } Easier now?

  29. Find the Error(s) (3) th ( text-align: center; border-width: 1px; border-style: solid; border-color: burlywood: padding: 3px }

  30. Errors in HTML <span class=“au”>golds </span> in long jump, and a long jump <span class=“au”>gold </spam> in the Pan American Games. She also played starting forward all four years of college at UCLA in basketball.

  31. Errors in HTML (2) <p> ... <span style=“font-size;small”> Jackie Joyner Kersee Competing in High Jump</span><br/></p>

  32. Debugging the Page:A Postmortem • We applied these debugging guidelines • Checked if image file was in the pic folder—it was. • Checked spelling of filename. Fixed. • Checked that the end tags were all present—they were. • Looked at Error Console.

  33. Debugging the Page:A Postmortem • Applied debugging guidelines • Checked that the closing braces were all present—they were. • Separated working from failing code by a process of delete, check, undo—found th had stopped styling. • Checked the th element, and eventually spotted the opening parenthesis. Fixed.

  34. Debugging the Page:A Postmortem • Applied debugging guidelines • Looked at the Error Console again • Checked padding, and noticed that the unit had not been set. Fixed. • Looked up “caption-align” property to find it is “caption-side.” Fixed.

  35. Debugging the Page:A Postmortem • Applied debugging guidelines • Checked the wrongly colored text, and spotted a typo in the end tag. Fixed. • Checked the caption’s small font specification, and spotted a colon typo. Fixed.

  36. Debugging the Page:A Postmortem • Sometimes we “correct” working code • May change correct to correct • May change correct to incorrect • “back out”

  37. Debugging the Page:A Postmortem • Errors may hide other errors

  38. Debugging the Page:A Postmortem • Asking the System to Help • Browser’s Error Console feature • May get hard to understand messages • View page source in browser shows color- and font-coded HTML source

  39. No Printer Output… • You try to print a document and nothing happens… • Debugging process • Reproduce the error, • Pinpoint the problem • Check the obvious causes • Isolate

  40. No Printer Output… • Try to pinpoint • check printer’s control panel, paper, etc. • canothers print if it’sa shared printer, and • can you print a different document

  41. No Printer Output… • Isolate the problem • You’ve printed before your computer is configured correctly • Try to print a plain text file– fails • Unplug and try again • Look at print queue

  42. The Print Queue • Print queue • Consists of jobs waiting to print • Clear jobs, and restart • Ensure computer is reconnectedto printer

  43. Ensuring Software Reliability • Software • Will have bugs • Will often crash • Consequences of errors • Annoyance • More serious if occur in life-support systems, medical apparatus, airplanes, nuclear power plants, weapons systems, etc.

  44. Hardware Failures • Dealing with hardware failures • Redundancy • Burn in • Most errors show up after few hours • Record of successful operation indicates likeliness of continued operation

  45. Software Failures • Software is amazingly complex • Possible configurations are typically very large • All states cannot be examined for correctness • How can s/w engineers be sure program works correctly?

  46. Software Failures • Programmers begin with a specification of • the input • how system should behave • how output should be produced • Specification states correct behavior • Not how it should be achieved

More Related