Download

Anti-bug tools

The most standard debugging tool on UNIX is the GNU Debugger gdb. Its main functionnality is to display the piece of code which procuced a crash. To do it, compile your code with the -g option, so that debugging information will be added to the executable. This information is mainly a correspondance between the machine langage instructions and locations in the source. Then, execute the program from gdb.

For instance

int main(int argc, char **argv) {int size = 100;

int a[size];

for(int i = 0; i < 100 * size; i++) a[i] = i;

}

> g++ -o bang -g bang.cc

> gdb ./bang

GNU gdb 6.1-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux"...\
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run
Starting program: /tmp/bang