// Debugging tools

IDB

To use the debugger, you need to compile the code with debugging command-line options, for example: $ module avail comp/intel
$ module load <module-name>
$ ifort -O0 -g -traceback -fp-stack-check -check bounds -fpe0 -o myexec mypro.f90
$ idb ./myexec

Note: IDB is no longer supported for the recent Intel compilers. Please use gdb-ia instead.

GNU GDB

Similarly, to use the GNU debugger, you compile the code with debugging command-line options and issue gdb, for example: $ gfortran -O0 -g -Wall -fbounds-check -o myexec myprog.f90
$ gdb ./myexec

TotalView

TotalView is a graphical, symbolic debugger for C, C++, F77, F90,and assembler programs. It features special, non-traditional features like debugging of multi-process (MPI) and multi-threaded (OpenMP, pthreads) applications, C++ support (templates, inheritance, inline functions), F90 support (user types, pointers, modules), and 1D and 2D Array Data visualization.

Various TotalView versions are currently available in the Discover systems, which can been seen by: $ module avail tview

You need to load a module before using TotalView: $ module load tview

Follow the steps below to use Totalview to debug your sequential, OpenMP, or MPI applications:

  1. On Discover, set up a few environmental variables in your shell start files, e.g., $HOME/.profile for bash or $HOME/.cshrc for csh/tcsh. For example: $ setenv TVDSVRLAUNCHCMD ssh By default, TotalView attempts to launch a debug server on a remote node with the rsh command. However, rsh commands are blocked on Discover as they are insecure.
    Load necessary modules for TotalView or MPI libraries with "module load".
  2. Build your application as you normally would but add the debug options, for example,"-g -O0 -traceback" for Intel compilers.
  3. Submit an interactive job by issuing, for example: $ xalloc --nodes=2 --time=1:00:00
  4. Once the requested nodes become available, go to the appropriate work directory and launch Totalview:
    • For sequential code, run TotalView as follows. $ totalview
    • For OpenMP code, set the OMP_NUM_THREADS environment variable to the desired number of threads and launch Totalview. $ setenv OMP_NUM_THREADS 8
      $ totalview
    • For MPI code, run Totalview as follows. $ totalview
    • For debugging MPI codes, do not launch Totalview with "mpirun -tv -np " because this command will make Totalview stop deep in the machine code of "mpirun", which is not what users want.
  5. If everything is fine, TotalView pops up three windows: ProcessWindow, TotalView status window, and Startup Parameters window.
    • For sequential and OpenMP codes, simply press the "OK" button on the Startup Parameters window.
    • For MPI code, go to the Startup Parameters window and click the "Parallel" tab. Select the correct MPI in the "Parallel System" dropdown menu, and also select the number of tasks and node. Then press the "OK" button on the "Startup Parameters" window.
  6. You should see your source code in the ProcessWindow, and can enter breakpoints and go, or single-steps, etc. If you only see assembly code, you most likely forgot to compile your code with the "-g" option
  7. When done debugging, click "File/Exit" in the ProcessWindow to close the TotalView session.
    All TotalView documentation provided by the vendor can be found under the "doc" directory of each particular installation of TotalView. Issue the following command, then you may simply copy the pdf files to your own client system. $ ls -altd /usr/local/toolworks/*/toolworks/totalview*/doc/pdf