The executables of Mercury programs by default do not invoke the Mercury debugger even if some or all of their modules were compiled with some form of tracing, and even if the grade of the executable is a debugging grade. This is similar to the behaviour of executables created by the implementations of other languages; for example the executable of a C program compiled with ‘-g’ does not automatically invoke gdb or dbx etc when it is executed.
Unlike those other language implementations, when you invoke the Mercury debugger ‘mdb’, you invoke it not just with the name of an executable but with the command line you want to debug. If something goes wrong when you execute the command
prog arg1 arg2 ...
and you want to find the cause of the problem, you must execute the command
mdb [mdb-options] prog arg1 arg2 ...
because you do not get a chance to specify the command line of the program later.
When the debugger starts up, as part of its initialization it executes commands from the following three sources, in order:
mdb will ignore any lines starting with the character # in any of the above mentioned files.
mdb accepts the following options from the command line. The options should be given to mdb before the name of the executable to be debugged.
-t file-name, --tty file-name
Redirect all of the I/O for the debugger to the device specified by file-name. The I/O for the program being debugged will not be redirected. This option allows the contents of a file to be piped to the program being debugged and not to mdb. For example on Linux the command ‘mdb -t /dev/tty ./myprog < myinput’ will cause the contents of myinput to be piped to the program myprog, but mdb will read its input from the terminal.
-w, --window, --mdb-in-window
Run mdb in a new window, with mdb’s I/O going to that window, but with the program’s I/O going to the current terminal. Note that this will not work on all systems.
Run the program in a new window, with the program’s I/O going to that window, but with mdb’s I/O going to the current terminal. Note that input and output redirection will not work with the ‘--program-in-window’ option. ‘--program-in-window’ will work on most UNIX systems running the X Window System, even those for which ‘--mdb-in-window’ is not supported.
-c window-command, --window-command window-command
Specify the command used by the ‘--program-in-window’ option for executing a command in a new window. The default such command is ‘xterm -e’.