[m-rev.] diff: bug fix for exception.m

Mark Brown dougl at cs.mu.OZ.AU
Thu Oct 10 15:50:06 AEST 2002


Estimated hours taken: 4 (mostly finding the bug)
Branches: main

library/exception.m:
	Ensure that MR_trace_from_full is set correctly before calling a
	Mercury exception handler.  Failing to set this global can lead to
	bogus events being sporadically generated from shallow traced code.

tests/debugger/declarative/Mmakefile:
	Enable the 'catch' test case in debug grades.  The test case was
	previously failing because bogus events were causing event numbers
	to be different after a retry, but the declarative debugger assumes
	the same event sequence will be generated after a retry, as it
	should.

	Allow the 'catch' test case to have an alternative input in debug
	grades.

tests/debugger/declarative/catch.exp2:
tests/debugger/declarative/catch.inp2:
	Alternative input and expected output for 'catch'.

Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.70
diff -u -r1.70 exception.m
--- library/exception.m	11 Sep 2002 07:20:22 -0000	1.70
+++ library/exception.m	9 Oct 2002 17:02:11 -0000
@@ -2003,6 +2003,13 @@
 	MR_r4 = exception;	/* This is our one input argument */
 
 	/*
+	** The handler is effectively being called from try/2 or one of
+	** its variants.  Since this caller is in the standard library,
+	** it won't be deep traced.
+	*/
+	MR_trace_from_full = MR_FALSE;
+
+	/*
 	** If the catch was semidet, we need to set the success indicator
 	** MR_r1 to MR_TRUE and return the result in MR_r2; otherwise, we return
 	** the result in MR_r1, which is where mercury__do_call_closure puts
Index: tests/debugger/declarative/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/Mmakefile,v
retrieving revision 1.45
diff -u -r1.45 Mmakefile
--- tests/debugger/declarative/Mmakefile	9 Oct 2002 09:25:21 -0000	1.45
+++ tests/debugger/declarative/Mmakefile	9 Oct 2002 18:02:40 -0000
@@ -11,6 +11,7 @@
 	backtrack		\
 	big			\
 	browse_arg		\
+	catch			\
 	comp_gen		\
 	deep_warning		\
 	dependency		\
@@ -41,14 +42,7 @@
 
 # The following should not be run in `debug' grades.
 #
-# XXX 'catch' test case does not work properly in debug grades, due to some
-# unknown bug.  The result of this bug is that the declarative debugger
-# gives a warning about missed events and refuses to start.  Since the
-# previous behaviour was to throw a software error, this is not really
-# a regression, but we would still like to find the bug and fix it.
-#
 NONDEBUG_DECLARATIVE_PROGS=	\
-	catch			\
 	untraced_subgoal
 
 # XXX 'ho3' and 'ho4' test cases fail due to an attempt to compare higher
@@ -59,12 +53,16 @@
 	ho3			\
 	ho4
 
+# Some of the test cases require a different input in debug grades,
+# so we set INP to the appropriate extension to use for those tests.
+# All other tests ignore this variable.
+#
 ifneq "$(findstring .debug,$(GRADE))" ""
     PROGS_2=$(DECLARATIVE_PROGS)
-    SOLUTIONS_INP=solutions.inp2
+    INP=inp2
 else
     PROGS_2=$(DECLARATIVE_PROGS) $(NONDEBUG_DECLARATIVE_PROGS)
-    SOLUTIONS_INP=solutions.inp
+    INP=inp
 endif
 
 # Debugging does not work in MLDS (hl*) and deep profiling (profdeep) grades.
@@ -133,8 +131,8 @@
 browse_arg.out: browse_arg browse_arg.inp
 	$(MDB) ./browse_arg < browse_arg.inp > browse_arg.out 2>&1
 
-catch.out: catch catch.inp
-	$(MDB) ./catch < catch.inp > catch.out 2>&1
+catch.out: catch catch.$(INP)
+	$(MDB) ./catch < catch.$(INP) > catch.out 2>&1
 
 comp_gen.out: comp_gen comp_gen.inp
 	$(MDB) ./comp_gen < comp_gen.inp > comp_gen.out 2>&1
@@ -212,8 +210,8 @@
 small.out: small small.inp
 	$(MDB) ./small < small.inp > small.out 2>&1
 
-solutions.out: solutions $(SOLUTIONS_INP)
-	$(MDB) ./solutions < $(SOLUTIONS_INP) > solutions.out 2>&1
+solutions.out: solutions solutions.$(INP)
+	$(MDB) ./solutions < solutions.$(INP) > solutions.out 2>&1
 
 special_term_dep.out: special_term_dep special_term_dep.inp
 	$(MDB) ./special_term_dep < special_term_dep.inp \
Index: tests/debugger/declarative/catch.exp2
===================================================================
RCS file: tests/debugger/declarative/catch.exp2
diff -N tests/debugger/declarative/catch.exp2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/catch.exp2	9 Oct 2002 18:10:24 -0000
@@ -0,0 +1,40 @@
+       1:      1  1 CALL pred catch:main/2-0 (cc_multi) catch.m:8
+mdb> echo on
+Command echo enabled.
+mdb> register --quiet
+mdb> break p
+ 0: + stop  interface pred catch:p/2-0 (cc_multi)
+mdb> continue
+       2:      2  2 CALL pred catch:p/2-0 (cc_multi) catch.m:18 (catch.m:9)
+mdb> finish
+      11:      2  2 EXIT pred catch:p/2-0 (cc_multi) catch.m:18 (catch.m:9)
+mdb> dd
+p(1, exception(univ_cons("q: bad input")))
+Valid? no
+try(q(1), exception(univ_cons("q: bad input")))
+Valid? no
+Sorry, the diagnosis cannot continue because it requires support for
+the following: code that catches exceptions.
+The debugger is a work in progress, and this is not supported in the
+current version.
+      11:      2  2 EXIT pred catch:p/2-0 (cc_multi) catch.m:18 (catch.m:9)
+mdb> continue
+exception(univ_cons("q: bad input"))
+      16:      8  2 CALL pred catch:p/2-0 (cc_multi) catch.m:18 (catch.m:12)
+mdb> finish
+      23:      8  2 EXIT pred catch:p/2-0 (cc_multi) catch.m:18 (catch.m:12)
+mdb> dd
+p(2, succeeded(2))
+Valid? no
+try(q(2), succeeded(2))
+Valid? no
+q(2, 2)
+Valid? yes
+Found incorrect contour:
+try(q(2), succeeded(2))
+Is this a bug? yes
+      22:      9  3 EXIT pred exception:try/2-0 (cc_multi) exception.m:321 (catch.m:19)
+mdb> continue
+      23:      8  2 EXIT pred catch:p/2-0 (cc_multi) catch.m:18 (catch.m:12)
+mdb> continue
+succeeded(2)
Index: tests/debugger/declarative/catch.inp2
===================================================================
RCS file: tests/debugger/declarative/catch.inp2
diff -N tests/debugger/declarative/catch.inp2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/catch.inp2	9 Oct 2002 18:10:05 -0000
@@ -0,0 +1,17 @@
+echo on
+register --quiet
+break p
+continue
+finish
+dd
+no
+no
+continue
+finish
+dd
+no
+no
+yes
+yes
+continue
+continue
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list