[mercury-users] Debugging Mercury Programs

Fergus Henderson fjh at cs.mu.oz.au
Wed Oct 22 04:34:02 AEST 1997

Ralph Becket, you wrote:
> While the Mercury compiler does seem to produce the most helpful error
> messages in the world, the absense of a debugger and `tracing' IO
> in nondeterministic predicates would seem to make finding logical bugs
> very difficult.
> I was wondering what the Mercury developers and people developing
> applications using Mercury currently use when debugging.

For debugging the Mercury compiler, we use the SICStus Prolog
debugger, as documented in the "Using Prolog" section of the 
Mercury User's Guide.

For debugging Mercury programs that make inherent use of
features that Prolog doesn't support, e.g. the C interface,
I use either non-logical I/O, or gdb.  Using gdb is probably
extremely difficult unless you have a very good understanding
of how the Mercury compiler works, so this technique is not
something I would recommend to anyone other than the Mercury

> Is
> 	--generate-prolog sicstus
> sufficient for the task

No.  That option doesn't work yet.
It probably shouldn't even be mentioned in the documentation at all.

> On the other hand, do people use some nasty impure
> library for tracing IO in non-deterministic predicates,

Yes, sometimes I do that.

In 0.7.2 and greater, there is an implementation of a generic (higher-order)
`unsafe_perform_io' predicate hidden away in extras/trailed_update/unsafe.m.

> While I'm on the subject, is anybody working on a Mercury level debugger?

Yes.  There are in fact two independent efforts in this direction.

The Mercury compiler can generate a high-level bytecode rather than C.
Bert Thompson <aet at cs.mu.oz.au> is working on writing an
interpreter and Mercury-level debugger for this bytecode.

>From what I have heard, Mireille Ducasse and her student Erwan Jahier
are planning to write an "opium"-style trace-based debugger.

Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at         |     -- the last words of T. S. Garp.

More information about the users mailing list