next up previous contents
Next: Documentation Up: Code Debugging Previous: Code Re-compilation   Contents

Multiple Source Code Directories

The most difficult problem of debugging Psi 3 code is that object code and source code generally reside in separate directories. This allows one to maintain objects for several achitectures simultaneously. In addition, library codes are kept separate from binary (module) codes. Most interactive debuggers allow the programmer to specify multiple source code search directories using simple command-line options. For example, if one were debugging the cscf program, and needed access to the libciomr.a library source code in addition to that of cscf, one could use gdb's ``dir'' command to search several source code directories:
dir ~/psi3_dist/src/bin/cscf ~/psi3_dist/src/lib/libciomr
Additionally, such commands can be placed in the user's .gdbinit file. In dbx the ``use'' command specifies multiple source directories. More recent versions of the gdb debugger can determine the full path name of each source file compiled with a -g flag. This is very convenient and makes gdb the preferred debugger in general.

Psi 3 Fortran modules can be significantly more difficult to debug. This is because the Fortran source code (.F suffix) must be preprocessed by psipp before it is passed to the compiler (see section [*]). Additionally, the preprocessed files (.f suffix) are usually automatically deleted when the compilation stops due to the make program's defaults (all such intermediate files are deleted). So, if the programmer tries to use the unprocessed code with the debugger, line numbers won't match and basically he or she will be wasting his or her time! To keep the preprocessed source files, tt make must be told that they are important; add the following line to the Makefile in the Fortran module's object code directory:

.PRECIOUS: %.f
This is a GNU make directive which prevents deletion of all intermediate .f files when the compilation stops. Then add the current directory to the debugger's source directory search path, and plow ahead. Note, however, that any changes made to .f files must be duplicated the corresponding unprocessed source file to be permanent.


next up previous contents
Next: Documentation Up: Code Debugging Previous: Code Re-compilation   Contents
Micah Abrams 2001-11-02