1- Introduction to Debuggers (GDB and DDD): Debuggers are probably are one of the most useful tools of programmers
Click here for the Presentation
Type the following to copy examples used during the presentation to your account (don't type the dollar sign, as that indicates a generic prompt, and remember to untar and gunzip the file):
$cp ~c201/public/labs/lab5/examples.tar.gz .
And
Click here for the Tutorial
$cp ~c201/public/labs/lab5/sample.cpp .
1- Use the following command to copy some buggy files into your account
$cp ~c201/public/labs/lab5/buggy1.c .
$cp ~c201/public/labs/lab5/buggy2.c .
Use either GDB or DDD to fix the above files
Note: buggy1.c and buggy2.c are c file (not c++), you need to use gcc to compile these files
(e.g. $gcc -g
buggy1.c )
2-Tree Structures:
The file tree.h and tree.cpp contain an implementation of trees. The
data at each node in the tree is a c-string (char*). Please read the
code for the tree structure and answer the following questions. The
file treeTest.cpp contains a test driver for the Tree structure. The
program reads a tree from the standard input one at a time and prints
the tree on the standard output using the printTree function. Compile
the treeTest.cpp program and run it with tree.txt as the standard input.
Hint: use the following commands:
Copy the tar file into your directory
$cp ~c201/public/labs/lab5/tree.tar.gz .
$tar xzvf tree.tar.gz
Compiling the files:
- Use the g++ command (use -c and -o options), or
- Write a Makefile
Running the program
$./tree < tree.txt
This will produce an error message (segmentation fault). Fix the program (using either GDB or DDD).