Lab 6 Solution

$29.99 $18.99

The main purpose of this lab is to give you some practice using the debugger. Before that, we have one more string function for you to write. As usual, go to Lab6 on Markus and then pull your repo to trigger the downloading of the starter code. Complete the program copy.c according to the instructions…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

The main purpose of this lab is to give you some practice using the debugger. Before that, we have one more string function for you to write.

As usual, go to Lab6 on Markus and then pull your repo to trigger the downloading of the starter code.

Complete the program copy.c according to the instructions in the starter code.

It’s common for programmers to debug using print, at least for simple issues, but debugging with print statements will become increasingly difficult as we delve into systems programming. Now is the time to learn how to use a common C debugger, gdb . It’ll seem hard at first, but you’ll be thankful for these skills at the end of this course and in courses like CSC369.

To demonstrate that you’ve completed the lab, you’ll submit a script record of your interactions on the command line to your git repository. Try it out by typing script then typing a few unix commands. Perhaps make a directory for your work on this lab or list the files in your current directory or whatever you wish… Then after you’ve done something, type exit . This will stop recording your actions and save them in a file named typescript . Check out the man page for script to see that you can give it a filename as an argument to override this default name.

The file overflow.c (in your repo in Lab6 ) contains a program to explore. You will change the values of SIZE and OVERFLOW to see what happens when OVERFLOW is bigger than SIZE .

First, read through the program and explain what it is doing aloud to yourself (or to some unsuspecting bystander, if you prefer). Notice that we are printing the addresses of the variables. The purpose of doing that is to show where the variables are placed in memory.

Next, compile and run the program as shown here:

$ gcc ‐Wall ‐std=gnu99 ‐g ‐o overflow overflow.c

$ ./overflow

Don’t miss the ‐g flag or gdb won’t work properly. Check the values of before, a, and after – did the program

3页 共3 2019/3/23 14:08