CS12

Lab 5


Lab Tasks

Use this lab to get familiar with the Linux Debugger. Use your Assignment 3 as a test file for running the debugger. Make sure you compiled the file with the g++ -g option. You should be able to show the TA that you can trace through your program and know the meaning of "next" "step" "run" and "breakpoints". Also make sure you can demonstrate that you know how to display variables. Go through your program and display your array of CDs. Trace through your program into your functions that set the data for the CD. You should be able to see your data as it get's set and changes. This lab should be short as you do not have to write any new program.

Data Display Debugger Mini Reference

If you compiled your program with the -g option then you can run it through a debugger. Debuggers are THE MOST USEFUL tool a programmer can use to find why their program is not working. You should really get familiar with the debugger and all it's features.

Starting the debugger

You can drag and drop an executable onto the DDD icon. You can also start the debugger from a console by running:

    ddd filename

Once ddd has started you should be able to see your code on the main screen. To set breakpoints you can right click on the line you want your program to stop and select "set breakpoint". After you set a breakpoint you can click on "Run" and your program will run until it gets to that line. You will see the output of your program on the window on the bottom. You can also type input there.The other basic commands you should no is the "step" and "next" buttons. They are used to go though your code line by line. The "next" command will skip over functions (the function will still execute but you won't go through all the steps). The "step" command will follow the code into the function so you'll go through all the steps. You can view variables and classes by double clicking on them (or right clicking on the variable and select "Display variablename". DDD has lot's of features and lot's of things you can customize. It also has extensive help files. You should learn how to use this tool well, as it will save you lot's of time.