1 / 10

Debugging

Debugging. James Wei Professor Peck 1/24/ 2013 http :// goo.gl / kbbdmP. The E clipse Workbench. Perspective Task list Project Explorer view Outline Problems view. Debugging a P rogram. Debug perspective Select the file Make a breakpoint in your program

xia
Download Presentation

Debugging

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. Debugging James Wei Professor Peck 1/24/2013 http://goo.gl/kbbdmP

  2. The Eclipse Workbench • Perspective • Task list • Project Explorer view • Outline • Problems view

  3. Debugging a Program • Debug perspective • Select the file • Make a breakpoint in your program • Double-click on the LHS • If you can’t see it, right click on the LHS ribbon and select Toggle Breakpoint • Click on the Debug icon.

  4. Debugging a Program • Step Over • Step Into • Step Return • Resume • Terminate

  5. Watching an Expression 1: publicclassMysteryClass { 2: 3:publicstaticvoid main(String args[]) 4: { 5:System.out.println(mysteryMethod(12)); 6: } 7: 8:publicstaticintmysteryMethod(int n) { 9: } }

  6. Watching an Expression 8: publicstaticintmysteryMethod(int n) { 9: boolean array [] = newboolean[n]; 10: 11: for (int i = 0; i < n; i++) 12: { 13: array[i] = true; 14: } 15: 16: for (int i = 2; i < n; i++) 17: { 18: for(int j = 2*i; j<n; j=j+i) 19: array[j] = false; 20: } 21: 22: int count = 0; 23: for (int i = 2; i < n; i++) 24: if(array[i]) 25: count++; 26: 27: 28: return count; 29: } breakpoint

  7. Watching an Expression • Go to Window  Show View  Expressions

  8. Watching an Expression • Add array[i]to the Expressions view. • Addito the Expressions view.

  9. Watching an Expression Step through: you can step over using Each time you step over, watch what happens to the values in the Expressions view in each iteration • What is the value of array[i] when i= 6? • What is the value of array[i] when i= 3? • What is the value of array[i] when i= 5? • What do you think this program is doing?

  10. Enjoy the rest of your Friday! Don’t forget to submit your answers to get credit for today!

More Related