[m-rev.] for review: allow retries over builtin_catch

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Dec 7 03:57:42 AEDT 2005


For review by anyone.

Estimated hours taken: 3
Branches: main (and 0.12?)

Allow retries across builtin_catch in mdb.  Previously retries failed
because of an assertion in the debugger that all stack frames should have
their MR_sle_exec_trace fields filled in.  This was not true for
builtin_catch, since the stack frame is created with hand written C code.

The fix is to make a special case of builtin_catch.  This is okay because
the MR_sle_exec_trace field is not needed to do a retry over builtin_catch.

trace/mercury_trace.c:
	Do not expect the MR_sle_exec_trace field to be filled in for
	builtin_catch.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/catch_retry.exp:
tests/debugger/declarative/catch_retry.inp:
tests/debugger/declarative/catch_retry.m:
	Test retries across builtin_catch.

Index: tests/debugger/declarative/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/Mmakefile,v
retrieving revision 1.85
diff -u -r1.85 Mmakefile
--- tests/debugger/declarative/Mmakefile	2 Nov 2005 14:17:37 -0000	1.85
+++ tests/debugger/declarative/Mmakefile	6 Dec 2005 16:38:05 -0000
@@ -84,7 +84,8 @@
 DECLDEBUG_DECLARATIVE_PROGS=	\
 	builtin_call_rep	\
 	sort			\
-	priv_builtin_bug
+	priv_builtin_bug	\
+	catch_retry
 	
 # The following should not be run in decldebug grades.
 #
@@ -229,6 +230,12 @@
 		> catch.out 2>&1 \
 	|| { grep . $@ /dev/null; exit 1; }
 
+catch_retry.out: catch_retry catch_retry.inp
+	$(MDB_STD) ./catch_retry < catch_retry.inp 2>&1 | \
+		sed -e 's/exception.m:[0-9]*/exception.m:NNNN/g' \
+		> catch_retry.out 2>&1 \
+	|| { grep . $@ /dev/null; exit 1; }
+
 closure_dependency.out: closure_dependency closure_dependency.$(DEBUG_INP)
 	$(MDB_STD) ./closure_dependency  < closure_dependency.$(DEBUG_INP) \
 		> closure_dependency.out 2>&1 \
Index: tests/debugger/declarative/catch_retry.exp
===================================================================
RCS file: tests/debugger/declarative/catch_retry.exp
diff -N tests/debugger/declarative/catch_retry.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/catch_retry.exp	6 Dec 2005 16:48:34 -0000
@@ -0,0 +1,8 @@
+      E1:     C1 CALL pred catch_retry.main/2-0 (cc_multi) catch_retry.m:8
+mdb> echo on
+Command echo enabled.
+mdb> exception
+      E2:     C2 EXCP pred exception.throw_impl/1-0 (erroneous) exception.m:NNNN (exception.m:NNNN)
+mdb> retry 10
+      E1:     C1 CALL pred catch_retry.main/2-0 (cc_multi) catch_retry.m:8
+mdb> quit -y
Index: tests/debugger/declarative/catch_retry.inp
===================================================================
RCS file: tests/debugger/declarative/catch_retry.inp
diff -N tests/debugger/declarative/catch_retry.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/catch_retry.inp	6 Dec 2005 16:44:53 -0000
@@ -0,0 +1,4 @@
+echo on
+exception
+retry 10
+quit -y
Index: tests/debugger/declarative/catch_retry.m
===================================================================
RCS file: tests/debugger/declarative/catch_retry.m
diff -N tests/debugger/declarative/catch_retry.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/catch_retry.m	6 Dec 2005 16:35:17 -0000
@@ -0,0 +1,31 @@
+:- module catch_retry.
+:- interface.
+:- import_module io.
+:- pred main(io__state::di, io__state::uo) is cc_multi.
+:- implementation.
+:- import_module exception, int.
+
+main -->
+	{ p(1, R1) },
+	io__write(R1),
+	io__nl,
+	{ p(2, R2) },
+	io__write(R2),
+	io__nl.
+
+:- pred p(int::in, exception_result(int)::out) is cc_multi.
+
+p(N, R) :-
+	try(q(N), R).
+
+:- pred q(int::in, int::out) is det.
+
+q(N, M) :-
+	(
+		N > 1
+	->
+		M = N
+	;
+		throw("q: bad input")
+	).
+
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.91
diff -u -r1.91 mercury_trace.c
--- trace/mercury_trace.c	2 Nov 2005 14:17:40 -0000	1.91
+++ trace/mercury_trace.c	6 Dec 2005 16:28:21 -0000
@@ -1526,8 +1526,27 @@
 MR_maybe_record_call_table(const MR_Proc_Layout *level_layout,
     MR_Word *base_sp, MR_Word *base_curfr)
 {
-    MR_TrieNode     call_table;
-    MR_EvalMethod   eval_method;
+    MR_TrieNode             call_table;
+    MR_EvalMethod           eval_method;
+    const MR_User_Proc_Id   *user;
+
+    if (! MR_PROC_LAYOUT_HAS_EXEC_TRACE(level_layout)) {
+        if (MR_PROC_LAYOUT_HAS_PROC_ID(level_layout)) {
+            if (! MR_PROC_LAYOUT_IS_UCI(level_layout)) {
+                user = &level_layout->MR_sle_user;
+                if (MR_streq(user->MR_user_decl_module, "exception") &&
+                    MR_streq(user->MR_user_name, "builtin_catch") &&
+                    (user->MR_user_arity == 3))
+                {
+                    /*
+                    ** builtin_catch doesn't fill in the MR_sle_exec_trace
+                    ** field, but we know its evaluation method, so we return.
+                    */
+                    return;
+                }
+            }
+        }
+    }
 
     if (! MR_PROC_LAYOUT_HAS_EXEC_TRACE(level_layout)) {
         /*
--------------------------------------------------------------------------
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