cs120: debugging...cs120: debugging w.michaelpetullo universityofwisconsin–lacrosse...

3
CS120: Debugging W. Michael Petullo University of Wisconsin–La Crosse As of February 1, 2021

Upload: others

Post on 17-Apr-2021

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS120: Debugging...CS120: Debugging W.MichaelPetullo UniversityofWisconsin–LaCrosse AsofFebruary1,2021

CS120: Debugging

W. Michael Petullo

University of Wisconsin–La Crosse

As of February 1, 2021

Page 2: CS120: Debugging...CS120: Debugging W.MichaelPetullo UniversityofWisconsin–LaCrosse AsofFebruary1,2021

Debugging: Grace Hopper and her bug

Both images are in the public domain

Page 3: CS120: Debugging...CS120: Debugging W.MichaelPetullo UniversityofWisconsin–LaCrosse AsofFebruary1,2021

Debugging: Summary of Think Java Appendix C

The compiler is spewing error messages Syntax errors cascade; focus on the first error.

I’m getting a weird compiler message, and it won’t go away Study the error message,look at the code, search for common syntax errors.

I can’t get my program to compile no matter what I do Ensure you are compiling thefile you intend; apply bisection.

I did what the compiler said, but it still doesn’t work Error messages give evidence,but suggested remedy might be wrong.

My program hangs Infinite loop? Ctrl-C

Program causes exception Fix what gives rise to exception, or add try/catch.

My program doen’t work Study, hypothesise, experiment. Add print statements.

Big hairy expression is broken Simplify into multiple expressions/statements.

I am really stuck Go for a walk. Clean program whitespace and add comments.

Really, really stuck Rubber ducky debugging and then use office hours