Debugging Test Cases

When you are developing a new test case for a new feature, you may run into times where VisIt will crash in the compute engine.

Pausing a script

Pausing a script can be done in a bunch of ways. I like to insert a wait_for_file function into my script where I want the script to wait until I'm ready. Sometimes I use this to give me time to attach an external debugger. When I am ready, I type touch filename in the console to create a new file that makes the wait_for_file function return.

def wait_for_file(filename):
    import os
    while 1:
            s = os.stat(filename)
        except OSError:

Using totalview

The runtest script that executes VisIt's testing has a parallel mode that causes a parallel engine to be created for testing. You can force a parallel engine using the -m parallel command line arguments to runtest. When the compute engine is crashing, attaching an external debugger can be enough for serial but you really need a parallel debugger for parallel testing so you can get all processes running in the debugger. Here is a command line that lets you do just that:

./runtest -notrackmem -v -m parallel -vargs "-debug 5 -totalview engine_par" tests/hybrid/

The -vargs argument lets you pass arbitrary command line arguments to VisIt's command line. This lets you tell VisIt to run with debugging logs, or run the engine under totalview. For a full list of arguments that you can add using -vargs, run visit -fullhelp.

Using gdb

You can run different pieces of VisIt under the gdb debugger. In order to start a VisIt component under gdb, you must add an additional argument to the VisIt command line. When you run the runtest script, adding arguments destined for the VisIt command line is done using the -vargs argument.

Debug the CLI in a new xterm window:

./runtest -notrackmem -vargs "-debug 5 -gdb-cli -xterm" tests/hybrid/

Debug the viewer in a new xterm window:

./runtest -notrackmem -vargs "-debug 5 -gdb-viewer -xterm" tests/hybrid/

Debug the engine in a new xterm window:

./runtest -notrackmem -vargs "-debug 5 -gdb-engine -xterm" tests/hybrid/

You can also pass breakpoints on the command line by inserting extra -break location commands into the string that you're passing to VisIt via -vargs.