GDB is a command line debugger. Google GDB tutorial. Here's a sample run:
Code:
~/sandbox/foo/$ cat > test.cpp
int main(void) {
int x = 5, y = 0;
int z = x/y;
return 0;
}
~/sandbox/foo/$ g++ -g -o test test.cpp
~/sandbox/foo/$ gdb test
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL3rh)
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-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run
Starting program: /home/xxxxx/sandbox/foo/test
Program received signal SIGFPE, Arithmetic exception.
0x08048384 in main () at test.cpp:3
3 int z = x/y;
(gdb) quit
The program is running. Exit anyway? (y or n) y
~/sandbox/foo/$
You can also specify a core file with the binary, and it will just tell you where it failed. From the GDB man page:
You can also start with both an executable program and a core file
specified:
gdb program core
Hope this helps. If you're going to be using OpenGL or doing anything beyond some silly single-file exercise, you really need to learn to use a debugger anyway (and while gdb isn't really the easiest to use, it's a good learning tool).
Bookmarks