Recursion and gdb

CS 23

Feb. 24, 1997

  1. Create a new directory and copy the files in ~kelliher/pub/cs23/gdblab to it.

  2. Working in the directory you created, compile the non-pointer version of the program:
    g++ -g -o max main.cc large.cc
    

  3. For your test runs, enter 2 values: 4 and 5 (entered in that order).

  4. Run the program. It will seg fault. Use gdb to locate the problem and then you should correct the problem.

  5. You will now note that the answer is wrong. Again, use gdb to locate and correct the problem.

  6. Now, compile the pointer version of the program:
    g++ -g -o max -DPOINTERS main.cc large.cc
    

  7. Run the program. It will seg fault. Use gdb to locate and correct the problem.

  8. Re-compile the non-pointer of the program. Run it under gdb, setting a breakpoint at MaxArray. Enter 5 values. Draw a call diagram showing which invocations of MaxArray called which, keeping track of the values of begin and end in each call. (This diagram will be a binary tree.)



Thomas P. Kelliher
Sat Feb 22 12:05:59 EST 1997
Tom Kelliher