The purpose of lab today is to get you familiar with how to debug pointers in GDB.
Download the https://www.cs.unm.edu/~vasek/cs241/lab/bintree.c file. We’re going to be debugging this code today.
Compile the code using the normal flags as well as the flag needed for GDB to work. (Remember this from lab 4? https://www.cs.unm.edu/~vasek/cs241/lab/lab4.html)
run a b c will run your code, piping a b c as command line arguments.
Try compiling and using GDB to run the bintree.c file. You need to pass in a sequence of numbers to the program.
The print command can not only tell you the current value of a variable, but also the value of different parts of a struct or the value that a pointer points to. The syntax is similar to that in c.
If you’re in the middle of the program you can do the following:
You can use the commands command. commands 1 will allow you to write some code to execute each time you hit the first breakpoint you defined.
You will need to write a number of commands in GDB, save them into a textfile called “gdbpointers.txt”.
Each of the following is worth some points towards your three points. For each, you will need to write the commands needed to produce your answer:
It’s ok not to finish this assignment – get through as much as you can.
Zip up your gdbpointers.txt file into a zip file entitled yourCSUsername.zip. Then drop the zip file into the dropbox under the lab-07 folder..