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
Key debugging tasks
• Working with breakpoints
• Stepping through the code
• Inspecting variables and expressions
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
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
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
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
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
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