Outline for May 31, 2002
Handouts: The Dynamic Debbugger gdb
Reading: Johnsonbaugh and Kalin, pp. 679-702 (appendix of useful functions)
-
Greetings and felicitations!
-
Miscellaneous
-
terminate program (exit); include <stdlib.h>
-
sort array of data (qsort); include <stdlib.h>
-
time of day (time, ctime); include <time.h>
-
execute cvommand (system); include <stdlib.h>
-
Debugging
-
programs have bugs; find and fix them
-
static debugging: insert debugging code into source, recompile and run
-
dynamic debugging: look at the program as it runs, observing (and maybe changing) variables, etc.
-
Static debugging
-
using printf to print variable values; mention %p (prints pointer value, usually as a hex integer)
-
using printf to print where you are (ie, on function entry printf("in function\n");
-
#ifdef DEBUG ... #endif around the printfs so you can leave them in the source if you need them again
-
assert(x) macro: assert(0 <= i && i <= n) causes program to exit with error message if (0 <= I && I <= n) is false; must include <assert.h>. To delete, say #define NDEBUG and they will not be in the compiled code.
-
Dynamic debugging
-
debugging tool instruments executable program so it can be stopped, examined, altered, and continued interactively
-
go through the handout
-
mention the "where" command which shows you the program stack