[m-rev.] for review: a better approximation to rational debugging

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Jul 6 23:53:06 AEST 2005


For review by Mark or Zoltan.

There may be a few tests which still need updating.  I am bootchecking the
other debugging grades now.

Estimated hours taken: 0.5
Branches: main

Do not include EXIT nodes which don't produce any output when searching
for child nodes on a stratum.
Also do not bother searching inside negations which succeed (i.e. the negated
goal fails) when searching for child nodes on a stratum.
The reason is that if a goal succeeds, but doesn't produce any bindings, then
it cannot be the cause of the FAIL, NEGF or ELSE node achoring the end of the
stratum it appears in.

browser/declarative_tree.m:
	Check if exit events produce bindings and ignore them if they do
	when searching a stratum for child nodes.

tests/debugger/declarative/family.exp:
tests/debugger/declarative/family.inp:
	This test was previously diagnosing the wrong bug in the sense
	that the found buggy node was not the cause of the erroneous behaviour
	in the ancestor.

tests/debugger/declarative/input_term_dep.exp:
tests/debugger/declarative/input_term_dep.inp:
	This test now does not ask about sb, since it succeeds in a
	missing answer context without producing any bindings.

Index: browser/declarative_tree.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_tree.m,v
retrieving revision 1.28
diff -u -r1.28 declarative_tree.m
--- browser/declarative_tree.m	19 Jun 2005 02:14:17 -0000	1.28
+++ browser/declarative_tree.m	6 Jul 2005 13:45:26 -0000
@@ -616,8 +616,7 @@
 		throw(internal_error("stratum_children_2",
 			"unexpected start of contour"))
 	;
-		( Node = exit(_, _, _, _, _, _, _)
-		; Node = fail(_, _, _, _, _)
+		( Node = fail(_, _, _, _, _)
 		; Node = excp(_, _, _, _, _, _)
 		)
 	->
@@ -633,20 +632,37 @@
 			%
 		contour_children(normal, Store, Prec, NestedStartId, Ns0, Ns1)
 	;
-		( Node = else(Prec, NestedStartId, _)
-		; Node = neg_succ(Prec, NestedStartId, _)
-		)
+		Node = else(Prec, NestedStartId, _)
 	->
 			%
 			% There is a nested failed context.
 			%
 		stratum_children(Store, Prec, NestedStartId, Ns0, Ns1)
 	;
+		Node = exit(_, CallId, _, _, _, _, _)
+	->
+			%
+			% Only include an exit node as a missing answer child
+			% if it produces output.  If the exit event doesn't
+			% produce output then the only way the call could have
+			% behaved differently is by failing, which won't change
+			% the FAIL, NEGS or ELSE anchoring the end of the
+			% current stratum.
+			%
+			( calls_arguments_are_all_ground(Store, CallId) ->
+				Ns1 = Ns0
+			;
+				Ns1 = [dynamic(NodeId) | Ns0]
+			)
+	;
 			%
-			% This handles the following cases:
-			% redo, switch, first_disj, later_disj and
-			% then.  Also handles cond when the status
-			% is anything other than failed.
+			% This handles the following cases: redo, switch,
+			% first_disj, later_disj, then and neg_succ.  Also
+			% handles cond when the status is anything other than
+			% failed.  We skip neg_succ nodes since they cannot
+			% bind anything, so could not be the cause of the
+			% FAIL, NEGS or ELSE anchoring the end of the
+			% current stratum.
 			%
 		Ns1 = Ns0
 	),
@@ -1769,6 +1785,24 @@
 	call_node_from_id(Store, CallId, Call),
 	Atom = get_trace_call_atom(Call),
 	user_arg_num(ArgPos, Atom, ArgNum).
+
+:- pred calls_arguments_are_all_ground(S::in, R::in) is semidet
+	<= annotated_trace(S, R).
+
+calls_arguments_are_all_ground(Store, CallId) :-
+	call_node_from_id(Store, CallId, Call),
+	Args = Call ^ call_atom_args,
+	%
+	% XXX The following won't work for partially instantiated arguments.
+	%
+	all [Arg] (
+		(
+			list.member(Arg, Args),
+		  	Arg = arg_info(yes, _, _)
+		)
+	=>
+		Arg = arg_info(_, _, yes(_))
+	).

 %-----------------------------------------------------------------------------%

Index: tests/debugger/declarative/family.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/family.exp,v
retrieving revision 1.7
diff -u -r1.7 family.exp
--- tests/debugger/declarative/family.exp	20 May 2005 05:40:23 -0000	1.7
+++ tests/debugger/declarative/family.exp	6 Jul 2005 12:11:39 -0000
@@ -75,8 +75,15 @@
 	half_siblings(a, b)
 	half_siblings(b, a)
 Complete? no
+siblings(b, a)
+Valid? yes
+Call siblings(_, _)
+Solutions:
+	siblings(a, b)
+	siblings(b, a)
+Complete? no
 Found partially uncovered atom:
 common_father(_, _)
 Is this a bug? yes
-      86:     15  4 FAIL pred family.common_father/2-0 (nondet) family.m:58 (family.m:77)
+     693:    110  4 FAIL pred family.common_father/2-0 (nondet) family.m:58 (family.m:70)
 mdb> quit -y
Index: tests/debugger/declarative/family.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/family.inp,v
retrieving revision 1.4
diff -u -r1.4 family.inp
--- tests/debugger/declarative/family.inp	20 May 2005 05:40:23 -0000	1.4
+++ tests/debugger/declarative/family.inp	6 Jul 2005 12:10:06 -0000
@@ -32,5 +32,6 @@
 dd -d 3 -n 7
 no
 yes
+no
+yes
 quit -y
-
Index: tests/debugger/declarative/input_term_dep.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/input_term_dep.exp,v
retrieving revision 1.9
diff -u -r1.9 input_term_dep.exp
--- tests/debugger/declarative/input_term_dep.exp	20 May 2005 05:40:26 -0000	1.9
+++ tests/debugger/declarative/input_term_dep.exp	6 Jul 2005 12:17:28 -0000
@@ -85,14 +85,10 @@
 Valid? no
 sa(1, 7)
 Valid? skip
-sb(7)
-Valid? skip
 sc(7)
 Valid? browse 1
 browser> mark
 sa(1, 7)
-Valid? yes
-sb(7)
 Valid? yes
 Found inadmissible call:
 Parent s(1)
Index: tests/debugger/declarative/input_term_dep.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/input_term_dep.inp,v
retrieving revision 1.3
diff -u -r1.3 input_term_dep.inp
--- tests/debugger/declarative/input_term_dep.inp	20 May 2005 05:40:26 -0000	1.3
+++ tests/debugger/declarative/input_term_dep.inp	6 Jul 2005 12:16:47 -0000
@@ -38,10 +38,8 @@
 dd -d 3 -n 7
 no
 skip
-skip
 browse 1
 mark
-yes
 yes
 yes
 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