Subject: [Announcement] gdb Date: Wed, 21 Feb 2001 15:50:03 -0500 From: Igor Markov Organization: U. of Michigan, EECS Newsgroups: umich.eecs.class.380 If your program crashes with a "Bus Error" message or a "Segmentation Fault" message (or says anything about SIGSEGV or SIGBUS), you may want to run it through a debugger. Note that crashes due to memory corruption, which are among possible reasons for segmentation faults and bus errors can be non-deterministic. They may depend on whether you compiled your program with -g or -O3, whether you are running it inside gdb or standalone, etc. In any case, if there is an error message in one of those cases, there is probably an error in your code. If there is no error message, you can't say for sure that everything is allright -- some bugs may be silent forever. Below I will cover gdb (the GNU debugger), which is not graphic, and thus can be used through telnet/ssh. If you want a graphic debugger, you can use ddd, which is a front end to gdb (it basically translates mouseclicks into gdb commands). Both are installed on CAEN machines. Unlike MicroSoft VC++ or CodeWarrior, gdb and ddd are free (gdb comes with most Linux distributions, ddd with some). If you are only interested in ddd, then just fire it up (with the same arrangements as gnuplot) and click on help. Otherwise, read on. To debug a program in gdb/ddd, make sure you compile your code with -g and w/o -O3. Produce an executable (OliverMaze) and type gdb OliverMaze this will load OliverMaze and print a banner. When you see a gdb prompt, type run -Stack (imagine that you are launching OliverMaze and giving it parameters, except that "run" stands for "OliverMaze"), or run -Queue depending on what you need. If there are any serious problems, there will be a message to that effect and it is likely to contain a filename and line number. you can then use the list command list 300 will show line 300 and several lines next to it in the current file (gdb loads the right after in most cases). You can specify the filename too, type help list for more details. You can type help for general help and learn more commands. quit does the obvious print variableName ditto A gdb tutorial can be found at http://www.info.ucl.ac.be/etudiants/outils/cornell/gdb/ I added it to the list of additional refs gdb has several graphic front ends: xxgdb (so-so), ddd(excellent), etc.