[mercury-users] Debugging & Tracing
fjh at cs.mu.OZ.AU
Wed Aug 5 01:32:56 AEST 1998
On 04-Aug-1998, Ralph Becket <rwab1 at cam.sri.com> wrote:
> When debugging programs it would be handy to be able to show debugging and
> tracing information (to stderr), even inside non-deterministic
> procedures (isn't there a quote to the effect that printf is the best
> debugging tool in the programmers' armoury?)
The is a procedure `unsafe_perform_io' in extras/trailed_update/unsafe.m
that you can use for this purpose. This is of course declared `impure' --
see the "Impurity" section of the Mercury language reference manual
for details on how we handle this kind of thing.
There is one problem with this procedure at the moment.
The current implementation of this procedure doesn't work reliably --
it can lead to dangling pointers -- if you use anything other than
the default (conservative) garbage collection, AND you backtrack
over calls to it, AND the I/O that you do includes opening or
closing files or calls to io__set_globals.
However, we've recently added the necessary support to the runtime
to fix this problem, so although it is not fixed yet, the fix is
now very easy and so it will probably be fixed quite soon.
At that point, we'll probably move `unsafe.m' from it's current
rather obscure location in the `extras' directory into the
Mercury standard library.
Of course with the new debugger we're developing there's much less need
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 22.214.171.124 | -- the last words of T. S. Garp.
More information about the users