CSCI 240
Quincy C++ Debugging System


Overview

The Quincy IDE has a full-featured and extremely useful set of features to help analyze the behavior of a program.

For example, you can:

Debugger Commands

There are several basic commands available to you in the debugger, as well as some advanced commands. The basic commands are quite useful, and are explained below.

Before starting the debugger, compile and build your program and correct any problems until you have 0 errors.

Next, go to Tools/Options/Build and make sure that "Debugging Information Added" is checked.

But - before handing in a floppy disk with your program, you may have to recompile and rebuild with debugging information turned off so the .exe file will fit on a floppy disk. To do this, uncheck the "Debugging Information Added" checkbox and recompile and rebuild for the floppy version.

Before you go any further, notice that you will want to see both the DOS Window and the Quincy Edit window. If the Quincy window is full screen, when you click on the Quincy window, the DOS window will "hide" behind the Quincy window. This is inconvenient.

You should probably re-size the Quincy window so you can see the DOS window (one on the left and one on the right). If Quincy is full-screen, click on the restore button (at the upper right of the Quincy window, there are 3 small icons: an _ and a two-rectangle things, and an X. The restore icon is the two-rectangle thing. Now you should be able to see the sides of the Quincy window. Position the mouse over the side (border) of the window and notice that it turns into a two-headed arrow. You can now drag (i.e. press and hold down the button and move) the mouse to make the window narrower. You can likewise change the width of the DOS window. Position them so you can see both.

Now move the cursor to the first executable line in your source code (or a later line if you prefer). Choose Debug/Step to Cursor (or press F10). The program will start up and execute until the instruction where your cursor is. It will then pause.

Notice that there is a little green arrow in the Quincy source code window indicating the next instruction that will be executed. Also notice that in your DOS window you only see any output produced up to the instruction you are stopped at.

Click in the Quincy window to make it active (so the top title bar is colored, not gray). Now you have several choices:

Notes

Debugging "Quiz"

Type in the following code, exactly as shown, compile it, and run it under the debugger. Hand in a printed copy of the source code, stapled together with a standard-sized sheet of paper answering the questions that follow the code. Do not hand in a disk. This assignment is due in recitation at the beginning of the hour. If you make a mistake typing in the code, your answers could be wrong, so double-check what you type.

The comments ( //1 //2 etc.) are the "line numbers" referred to below.

#include <iostream>

using namespace std;

int main()
{
int i, j, k;
int ans;
string s;

i = 4;   // 1
j = 7;   // 2
ans = 4 * j/i + 9;   // 3
i = 0;   // 4

while (ans > 0)   // 5
{
i++;   // 6
ans--;   // 7
}

if (j % 2 / 2)  // 8
  ans = 1;   // 9
else
  ans = 2;   // 10

ans += k;   // 11

return 0;
}

The Questions

  1. What is the value of ans after line 2 has executed?

  2. What is the value of ans after line 3 has executed?

  3. What is the value of i just before line 8 has executed?

  4. Does line 9 or line 10 execute?

  5. What is the value of k before line 11 is executed? Why?

  6. What is the value of ans after line 11 has executed?