808 Part VI . Programming in (Free web hosting with ftp) Linux Starting

808 Part VI . Programming in Linux Starting GDB To start a debugging session, simply type gdb progname, replacing progname with the name of the program you want to debug. Using a core file is optional but will enhance GDB s debugging capabilities. Of course, you ll need a program on which to try out GDB debugging, so Listing 29-5 provides one: debugme.c. Listing 29-5: A Buggy Program /* * debugme.c - poorly written program to debug */ #include #define BIGNUM 5000 #define SZ 100 void index_to_the_moon(int ary[]); int main(int argc, char *argv[]) { int intary[100]; index_to_the_moon(intary); return 0; } void index_to_the_moon(int ary[]) { int i; for (i = 0; i < BIGNUM; ++i) ary[i] = i; } Compile this program using the command gcc -g debugme.c -o debugme. Then, execute the program using the command ./debugme. $ ./debugme Segmentation fault (core dumped) $ file core core: ELF 32-big LSB core file Intel 80386, version 1 (SYSV ), SVR4-style, SVR4-stylee, from debugme On most systems, when you execute ./debugme, it immediately causes a segmentation fault and dumps core, as shown in the output listing.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply