Scripts and Utilities -- Gcc lab


This lab will consist of you using the gcc compiler, the gdb debugger, and the programs purify and quantify. You will need to copy all the files in /home/cs300/labs/Gcc to some directory of your own.

Do the following in your cs300/lab2 directory:

unix> cp ~cs300/labs/Gcc/* .
unix> ls

You should see the files:
first.c* how.c* sample.c* what.c* get_input.c* large* small* why.c*

Compiling and Debugging:

1. Create the executable -- get_input. Use the source file get_input.c. The program takes an integer as an argument and then reads in and prints back out that number of lines. I want to know if there is an error in the program. If so I want to know which line. I also require the gdb error message and the stack trace.

2. Create the executable -- first_try. Use the source file first.c. This will require that you tell me the correct command line to compile the program without errors, so that it prints error messages and is ready for debugging. You will have to examine the source file to see what is happening. As a note to those of you who are CS majors, think what would have happened had this been a very large source program with no comments to indicate what or why things are done the way they are. And you are asked to FIX IT.

This next one is a little more difficult but represents the type of problem you may encounter.

3. Create the executable -- how. Use the source file how.c This takes an integer argument and returns the square root. I want to know what steps you would take to solve the problem of getting this to compile assuming that you had not had the lecture to refer to. What information would have been necessary to the solution? And "asking someone else" is not a valid answer.

Analysis:

4. Create the executable -- sample. Use the source file sample.c. This will take no arguments and prints out a string of random characters then attempts to print out the exact same string again. I want you to use purify to tell me exactly which line number(s) the error(s) occur on and I want a copy of the program's output without purify and with purify. I want here sample's output not purify's.

5. Create the executables -- what_not and why_not. Use the source files what.c and why.c. I want you to give me an analysis of their performance relative to each other. The programs read from standard in and echo what they read to standard out. I want you to use the files small and large as test input. Bottom line, which program should I use for my personal version of cat and why? Those of you who are not programmers or computer science majors should not be at a handicap here. I want you to examine the data produced by quantify and make a decision based on that data. Knowledge of the underlying concepts is not necessary. You must support all of your opinion with facts.

example result might be of the sort -

 what_not - uses 23 functions that quantify can access. 
 Total time for input 'small' on a hydra machine is 2 seconds, 
 75% of that in system calls. Spent 53% of its time reading, 43% writing.

Note: These results will differ wildly from any you ran or may run in the future.