COMP2012H

Honors OOP and Data Structures

 

Bonus Lab 2: Debugging with Eclipse

Topics

Download

List Access Problem

In this problem, we are given a linked list of city names.

Together with a sequence of requested accesses:

Algorithms

Transpose

Move-to-Front (MTF)

Debugging with Eclipse

kconsole_setting121

Copy the files into the project "listaccess". Note that the project is buggy.

kconsole_setting122

Click the build button (i.e. the hammer icon):

kconsole_setting123

Compile the project and get ready to use the debugger.

kconsole_setting124

Choose the gdb debugger from the dialog:

kconsole_setting125

Allow Eclipse to switch to the Debug Perspective (The default is C++ Perspective). Debug Perspective is useful for debugging, and you can switch back to C++ Perspective after the debug process:

kconsole_setting126

A console is opened when the project is executed.

kconsole_setting127

The program halts at the default breakpoint and we will do step-by-step debugging. Choose Step Over or press F6 from the keyboard

kconsole_setting128

The program halts. A bug is spotted.

kconsole_setting129

Set a breakpoint at the problematic line. Right click the line and choose toggle breakpoint. A breakpoint icon is added on that line.

kconsole_setting130

Terminate (by clicking the stop button) and then Launch (by clicking the debug button) the debugging process again.

kconsole_setting131

The program halts at the default breakpoint. Resume it.

kconsole_setting132

Go to the buggy line (breakpoint) and "step into" it. Step into will enter the function and trace the codes inside the function.

kconsole_setting133

In the buggy function List::Delete do step-by-step debugging (using step over)

kconsole_setting134

Reach an infinite loop (the bug we are looking for). Think about what we have missed!

kconsole_setting135

Switch back to the C++ Perspective after the debugging process

kconsole_setting136


Lab Task

Demo to the TAs:  (Bold is the input)

Before the modifications

After the modifications

List Accessing Problem

Type Cities to Access and end with '#' (q to exit)

 e.g. London HongKong Paris ... HongKong #

HongKong Paris NewYork Sydney London Rome Moscow Hamburg SaoPaulo Seoul

Cities > Seoul Seoul Seoul #

Cost:27

HongKong Paris NewYork Sydney London Rome Seoul Moscow Hamburg SaoPaulo

List Accessing Problem

Type Cities to Access and end with '#' (q to exit)

 e.g. London HongKong Paris ... HongKong #

HongKong Paris NewYork Sydney London Rome Moscow Hamburg SaoPaulo Seoul

Cities > Seoul Seoul Seoul #

Cost:12

Seoul HongKong Paris NewYork Sydney London Rome Moscow Hamburg SaoPaulo

 

References