Introductory Debugging Session

Now we will present a complete debugging session. As mentioned, the sample program is in the source file ins.c and does an insertion sort. This is not an efficient sorting method, of course, but the simplicity of the code makes it good for illustrating the debugging operations. Here is the code:

// // insertion sort, several errors // // usage: insert_sort num1 num2 num3 ..., where the numi are the numbers to // be sorted int x[10], // input array y[10], // workspace array num_inputs, // length of input array num_y = 0; // current number of elements in y void get_args(int ac, char **av) { int i; num_inputs = ac - 1; for (i = 0; i < num_inputs; i++) x[i] = atoi(av[i+1]); } void scoot_over(int jj) { int k; ...

Get The Art of Debugging with GDB, DDD, and Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.