[mercury-users] Debugging info?

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Oct 22 13:17:54 AEST 1999


On 22-Oct-1999, Robert Ernst Johann JESCHOFNIK <rejj at cat.cs.mu.OZ.AU> wrote:
> Is there any way to compile and include debugging info in the executable
> (like a gcc -g), so that when, for example, an array out-of-bounds
> occours a more meaningful message than "array__lookup: out of bounds"
> could be given? (like module name/line number)

Yes.  You can use `mmc --debug' or put `MCFLAGS=--debug' in your Mmakefile.
Then run your program under mdb.  When it halts, the error message will
include the last debugger event number.  Run your program under mdb
a second time, using the "goto" command to skip to the last event number
before the crash, and then use the `stack' command to print out the program's
stack trace.

Here's a sample session.

 | $ mmc --debug example
 | $ ./example
 | Mercury runtime: array__lookup: array index out of bounds
 | $ mdb ./example
 | Melbourne Mercury Debugger, mdb version rotd-1999-10-21.
 | Copyright 1998 The University of Melbourne, Australia.
 | mdb is free software, covered by the GNU General Public License.
 | There is absolutely no warranty for mdb.
 |        1:      1  1 CALL pred example:main/2-0 (det) 
 | mdb> c
 | Mercury runtime: array__lookup: array index out of bounds
 | Last trace event was event #4.
 | $ mdb ./example
 | Melbourne Mercury Debugger, mdb version rotd-1999-10-21.
 | Copyright 1998 The University of Melbourne, Australia.
 | mdb is free software, covered by the GNU General Public License.
 | There is absolutely no warranty for mdb.
 |        1:      1  1 CALL pred example:main/2-0 (det) 
 | mdb> goto 4
 |        4:      3  2 CALL pred array:lookup/3-0 (det) 
 | mdb> stack
 |    0       pred array:lookup/3-0 (det)
 |    1       pred example:main/2-0 (det)
 | mdb> 

See the "Debugging" chapter of the Mercury user's guide for more details.

-- 
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 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list