[m-rev.] For review: Include failed COND events in sub-term tracking contour.

Ian MacLarty maclarty at cs.mu.OZ.AU
Thu Nov 18 10:16:06 AEDT 2004


For review by anyone.

Estimated hours taken: 2
Branches: main

Include failed COND events in contours.  This is required when tracking an
input sub-term marked inside a failed if-then-else condition.

browser/declarative_tree.m
	Include COND events in the contour used to track sub-term dependencies 
	whether they failed or not.  
	
	When searching for the CALL event from within the body of a call, step
	over failed COND events.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/failed_cond.exp
tests/debugger/declarative/failed_cond.inp
tests/debugger/declarative/failed_cond.m
	Add regression test.  This test threw an exception previously.

Index: browser/declarative_tree.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_tree.m,v
retrieving revision 1.7
diff -u -r1.7 declarative_tree.m
--- browser/declarative_tree.m	21 Jul 2004 07:25:11 -0000	1.7
+++ browser/declarative_tree.m	17 Nov 2004 23:03:35 -0000
@@ -645,8 +645,20 @@
 	( Node = call(_, _, _, _, _, _, _, _, _) ->
 		ParentCallNode = Node
 	;
-		( Node = neg(NegPrec, _, _) ->
+		%
+		% We wish to step through negated contexts, so we handle NEGE
+		% and COND events seperately, since step_left_in_contour/2
+		% will throw an exception if it reaches the boundary of a
+		% negated context.
+		%
+		( 
+			Node = neg(NegPrec, _, _)
+		->
 			PrevNodeId = NegPrec
+		;	
+			Node = cond(CondPrec, _, _)
+		->
+			PrevNodeId = CondPrec
 		;
 			PrevNodeId = step_left_in_contour(Store, Node)
 		),
@@ -662,8 +674,19 @@
 	( Node = call(_, _, _, _, _, _, _, _, _) ->
 		Nodes = Nodes0
 	;
-		( Node = neg(NegPrec, _, _) ->
+		%
+		% We include NEGE and (possibly failed) COND events in the
+		% contour so we can track input sub-terms through negated
+		% contexts.
+		%
+		(
+			Node = neg(NegPrec, _, _)
+		->
 			PrevNodeId = NegPrec
+		;
+			Node = cond(CondPrec, _, _)
+		->
+			PrevNodeId = CondPrec
 		;
 			PrevNodeId = step_left_in_contour(Store, Node)
 		),
Index: tests/debugger/declarative/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/Mmakefile,v
retrieving revision 1.64
diff -u -r1.64 Mmakefile
--- tests/debugger/declarative/Mmakefile	7 Jul 2004 05:26:16 -0000	1.64
+++ tests/debugger/declarative/Mmakefile	17 Nov 2004 22:10:58 -0000
@@ -18,6 +18,7 @@
 	dependency		\
 	dependency2		\
 	empty_command		\
+	failed_cond		\
 	family			\
 	filter			\
 	func_call		\
@@ -170,6 +171,9 @@
 
 family.out: family family.inp
 	$(MDB) ./family < family.inp > family.out 2>&1
+
+failed_cond.out: failed_cond failed_cond.inp
+	$(MDB_STD) ./failed_cond < failed_cond.inp > failed_cond.out 2>&1
 
 filter.out: filter filter.inp
 	$(MDB_STD) ./filter < filter.inp > filter.out 2>&1
Index: tests/debugger/declarative/failed_cond.exp
===================================================================
RCS file: tests/debugger/declarative/failed_cond.exp
diff -N tests/debugger/declarative/failed_cond.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/failed_cond.exp	17 Nov 2004 22:09:11 -0000
@@ -0,0 +1,22 @@
+      E1:     C1 CALL pred failed_cond.main/2-0 (det) failed_cond.m:12
+mdb> mdb> Contexts will not be printed.
+mdb> echo on
+Command echo enabled.
+mdb> step
+      E2:     C2 CALL pred failed_cond.p/1-0 (det)
+mdb> finish
+      E3:     C2 EXIT pred failed_cond.p/1-0 (det)
+mdb> dd
+p(b)
+Valid? no
+q(c, b)
+Valid? no
+Call r(c)
+No solutions.
+Complete? browse 1
+browser> mark
+Found incorrect contour:
+q(c, b)
+Is this a bug? yes
+      E4:     C3 EXIT pred failed_cond.q/2-0 (det)
+mdb> quit -y
Index: tests/debugger/declarative/failed_cond.inp
===================================================================
RCS file: tests/debugger/declarative/failed_cond.inp
diff -N tests/debugger/declarative/failed_cond.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/failed_cond.inp	17 Nov 2004 22:08:48 -0000
@@ -0,0 +1,12 @@
+register --quiet
+context none
+echo on
+step
+finish
+dd
+no
+no
+browse 1
+mark
+yes
+quit -y
Index: tests/debugger/declarative/failed_cond.m
===================================================================
RCS file: tests/debugger/declarative/failed_cond.m
diff -N tests/debugger/declarative/failed_cond.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/failed_cond.m	17 Nov 2004 22:06:00 -0000
@@ -0,0 +1,36 @@
+% Test tracking the origin of a sub-term from a failed if-then-else condition.
+:- module failed_cond.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+main(!IO) :-
+	p(X),
+	write(X, !IO),
+	nl(!IO).
+
+:- type t ---> a ; b ; c.
+
+:- pred p(t::out) is det.
+
+p(Y) :- X = c, q(X, Y).
+
+:- pred q(t::in, t::out) is det.
+
+q(X, Y) :-
+	(
+		r(X)
+	->
+		Y = a
+	;
+		Y = b
+	).
+
+:- pred r(t::in) is semidet.
+
+r(a).
--------------------------------------------------------------------------
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