Chapter 29 . Programming Tools and Utilities 811 (Unlimited web hosting)
Chapter 29 . Programming Tools and Utilities 811 function was index_to_the_moon(), so, somewhere in the function, the segmentation fault occurred. Incidentally, the backtrace also shows that index_to_the_ moon() was called from line 15 of the main() function in debugme.c. It s not necessary to type complete command names while using GDB. Any sufficiently unique abbreviation works. For example, back suffices for backtrace. It would be helpful, however, to have some idea of the context in which the offending line(s) of code exist. For this purpose, use the list command, which takes the general form, list [m,n], where m and n are the starting and ending line numbers you want displayed. For example: (gdb) list 10,32 would display code lines 10 through 32. A bare list command displays 10 lines of code that includes the line where the error was first detected, as illustrated here: (gdb) list 15 index_to_the_moon(intary); 16 17 exit(EXIT_SUCCESS); 18 } 19 20 void index_to_the_moon(int ary[]) 21 { 22 int i; 23 for (i = 0; i < BIGNUM; ++I { 24 ary[i] = i; Examining Data One of GDB s most useful features is its ability to display both the type and the value of almost any expression, variable, or array in the program being debugged. It can print the value of any expression legal in the language in which your program is written. The command is, predictably enough, print. Here are a couple of print commands and their results: (gdb) print i $1 = 724 (gdb) print ary[i] Cannot access memory at address 0xc0000000. This example continues the earlier examples of debugging debugme.c because you are still trying to identify where and why debug me crashed. Although in this example, the program crashed at the point when the counter variable i equaled 724 (the expression $1 refers to an entry in GDB s value history, explained in a moment), Tip
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.