+ All Categories
Home > Documents > Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu...

Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu...

Date post: 08-Aug-2020
Category:
Upload: others
View: 12 times
Download: 0 times
Share this document with a friend
9
Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu) Paolo Tonella (tonella at fbk dot eu) Mariano Ceccato (ceccato at fbk dot eu) Academic Year 2011-2012 Trento 21/09/2011
Transcript
Page 1: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Lab1: Debugging with Eclipse

Software Analysis and TestingCu Nguyen Duy (cunduy at fbk dot eu)

Alessandro Marchetto (marchetto at fbk dot eu)Paolo Tonella (tonella at fbk dot eu)

Mariano Ceccato (ceccato at fbk dot eu)

Academic Year 2011-2012Trento 21/09/2011

Page 2: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Key debugging tasks

• Working with breakpoints

• Stepping through the code

• Inspecting variables and expressions

Page 3: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Breakpoints• The simplest kind of breakpoint is a

line breakpoint.

• To create one, double-click in the margin next to a line of code.

• Double-click the icon to remove it.

• A method breakpoint stops when the debugger enters or exits a particular method.

• You can set an exception breakpoint on a particular Java exception (caught or uncaught)

ref: http://csis.pace.edu/~ogotel/teaching/IBM04-Eclipse%20Debugger.ppt

Page 4: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Stepping through the code

1. Step Into (F5) – Steps into a method and executes its first line of code

2. Step Over (F6) – Executes the next line of code in the current method

3. Step Return (F7) – Continues execution until the end of the current method (until a return)

4. Step to Line (Cmd [Ctrl] + R) - Continues until the line of the current cursor

5. Resume (F8) – Continues execution until

Page 5: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Inspecting variables and expressions

• Variables view shows all the variables currently in scope.

• You can change the values of those variables

• Expressions view lets you evaluate Java expressions.

op.eval() = 11.2

Page 6: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Exercise 1

1. download HelloDebugger source http://selab.fbk.eu/swat/projects/HelloDebugger.zip

2. run the program, identify the failures

3. add breakpoints

4. step through the code by debugging, locate the faults

5. identify the lines of code that’s not executed

Report: - describe the fault and its location- class, lines of code that are not executed

Page 7: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Exercise 2

1. Download project: http://selab.fbk.eu/swat/projects/Exercise2.zip

2. Report all the values of the array account[], of class CurrentAccount, during execution

3. Find faults and fix them

Report: - table of the values of account[] - describe the faults and fixes

Page 8: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Exercise 3Ex 2: pair game (2 students)

- Individually

1. download the exercise http://selab.fbk.eu/swat/projects/Exercise1.zip

2. complete the main() method of the Main class of the exercise 1, make use of the other 3 classes

3. fix the existing faults

4. inject a new fault

- with your opponent6. locate the fault injected by the other student

Report: - describe the implemented code of the main method- describe faults identified and fixes

Page 9: Lab1: Debugging with Eclipse - FBK · Lab1: Debugging with Eclipse Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu)

Where to send reports

[email protected] , subject: [SWAT-20011] Project Exercises


Recommended