$Id$ How to debug GRASS modules and libraries with GNU gdb and DDD: Re-compile the modules and libraries you want to debug with the -g switch to the gcc compiler and without the -s switch to the linker: 1. Edit src/CMD/head/head and head.in for the above configuration 2. Run "make clean" from the sorce code root directory 3. Run "make" to recompile the code Now you can start a grass5 session, start up the DDD debugger (ddd&) and select the module to debug. The binary in $GISBASE/bin/ is not what you want to look at, as this only switches between the interactive version and the command line version of the module in many cases. The command line version of the module is in $GISBASE/etc/bin/main/cmd, the interactive version in $GISBASE/etc/bin/main/inter. For the "contributed" modules, the executable is found in $GISBASE/etc/bin/contrib/inter or $GISBASE/etc/bin/contrib/cmd respectively. -- Andreas Lange, andreas.lange@rhein-main.de ------------------------------------------------------------------------ Debugging tools: gdb: GNU debugger. GDB, the GNU Project debugger, allows you to see what is going on 'inside' another program while it executes -- or what another program was doing at the moment it crashed. http://sources.redhat.com/gdb/ Start gdb like this (after following above compile steps): gdb /usr/local/grass5/etc/bin/ r The "where" command in gdb will give a traceback after a crash or break. Example: gdb /usr/local/grass5/etc/bin/cmd/r.in.tiff r in=map.tiff out=map where ddd: GNU DDD is a graphical front-end for command-line debuggers such as GDB, DBX, WDB, Ladebug, JDB, XDB, the Perl debugger, or the Python debugger. Besides `usual'' front-end features such as viewing source texts, DDD has become famous through its interactive graphical data display, where data structures are displayed as graphs. http://www.gnu.org/software/ddd/ddd.html startup with module set break point run or use "next" step to go stepwise memprof: Profiling and leak detection. MemProf is a tool for profiling memory usage and finding memory leaks http://people.redhat.com/otaylor/memprof/