Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP 1921 Programming Project 2021-2022

GDB Debugging Exercise

This exercise is designed to give you some practical experience using the GDB command-line debugger.  You should log into feng-gps using three separate terminal windows from              whatever machine you are working on.  These windows will be used as follows:

1.   Execution Window

2.   Code Editing Window

3.   Documentation Window

Part I:                You will be provided with a small piece of bad code which does not do what it

should. Your task is to debug it so that it produces the correct result, using only the following command-line tools, without adding print statements to the code:

more

cat

man

diff

vi

make

gcc

gdb

hexdump (optional)

If after 90 minutes, you have not succeeded, you should stop trying and switch to Part II.

Part II:               Spend 30 minutes (at most) analysing the code, and asking:

a.    What did the programmer do wrong technically?

b.   What did the programmer do right technically?

c.    What could the programmer have done to make your job easier?

d.   What should the programmer have done to make your job easier?

This exercise will not be handed in or assessed, but will form the background for the               lectures in the third week, so please make sure that you at least attempt it.  Be warned!  It is not easy.

The Code:        Takes an image file in a very simple format called .pgm, reads it in, stores it, then outputs it to a different file, using command-line parameters to specify the files:

./pgmEcho inputImage outputImage

You have been provided with one test file: slice0a.pgm, which you can look at using cat, more or vi.  Details of the file format can be found at

http://netpbm.sourceforge.net/doc/pgm.html

Details of any of the command-line tools or of functions in the standard libraries can be        found using the man command, which gives you a text description on the command line. It  should not be necessary for you to Google anything, and Googling is likely to slow you down rather than speeding you up.