These commands allow you to type in queries (goals) interactively in the debugger. When you use one of these commands, the debugger will respond with a query prompt (‘?-’ or ‘run <--’), at which you can type in a goal; the debugger will then compile and execute the goal and display the answer(s). You can return from the query prompt to the ‘mdb>’ prompt by typing the end-of-file indicator (typically control-D or control-Z), or by typing ‘quit.’.
The module names module1, module2, ... specify which modules will be imported. Note that you can also add new modules to the list of imports directly at the query prompt, by using a command of the form ‘[module]’, e.g. ‘[int]’. You need to import all the modules that define symbols used in your query. Queries can only use symbols that are exported from a module; entities which are declared in a module's implementation section only cannot be used.
The three variants differ in what kind of goals they allow. For goals which perform I/O, you need to use ‘io_query’; this lets you type in the goal using DCG syntax. For goals which don't do I/O, but which have determinism ‘cc_nondet’ or ‘cc_multi’, you need to use ‘cc_query’; this finds only one solution to the specified goal. For all other goals, you can use plain ‘query’, which finds all the solutions to the goal.
For ‘query’ and ‘cc_query’, the debugger will print out all the variables in the goal using ‘io.write’. The goal must bind all of its variables to ground terms, otherwise you will get a mode error.
The current implementation works by compiling the queries on-the-fly and then dynamically linking them into the program being debugged. Thus it may take a little while for your query to be executed. Each query will be written to a file named mdb_query.m in the current directory, so make sure you don't name your source file mdb_query.m. Note that dynamic linking may not be supported on some systems; if you are using a system for which dynamic linking is not supported, you will get an error message when you try to run these commands.
You may also need to build your program using shared libraries for interactive queries to work. With Linux on the Intel x86 architecture, the default is for executables to be statically linked, which means that dynamic linking won't work, and hence interactive queries won't work either (the error message is rather obscure: the dynamic linker complains about the symbol ‘__data_start’ being undefined). To build with shared libraries, you can use ‘MGNUCFLAGS=--pic-reg’ and ‘MLFLAGS=--shared’ in your Mmakefile. See the README.Linux file in the Mercury distribution for more details.