[m-rev.] for review: include label layouts in annotated trace

Ian MacLarty maclarty at cs.mu.OZ.AU
Sun Feb 20 15:39:14 AEDT 2005


For review by anyone.

Estimated hours taken: 7
Branches: main

Record label layouts in the annotated trace.  This does away with the need
to store goal path strings and proc_layouts in the annotated trace, since
both can be obtained from the label layout (we still however need to store the
goal path of a call in its parent for subterm dependency tracking).  

The label layouts will be used for displaying more detailed information
in the declarative debugging session (such as line numbers) and also for
for slicing and dicing in the declarative debugger.

browser/declarative_execution.m
	Add label_layout foreign types and some useful functions on this type.
	
	Add label_layout field to each event in an annotated trace.
	
	Record just the arguments of an atom for call and exit events in the
	annotated trace.  The complete atom can be constructed from the
	label_layout and the arguments.  
	
	When recording argument values add them to the front of the
	argument list instead of inserting them in a specified position in the
	argument list.  This means the arguments must be added in reverse order
	in trace/mercury_trace_declarative.c.  This should, however be a bit
	more efficient than the previous method where the arguments were
	effectively being appended to the end of the argument list each time.

	Adjust the predicates for building the annotated trace to also accept
	a label_layout.

browser/declarative_debugger.m
	Get the proc_layout from the label_layout.

browser/declarative_tree.m
	Make adjustments for the extra field.

trace/mercury_trace_declarative.c
	Pass the label_layout when constructing pieces of the annotated trace.

	Construct only the atoms arguments.  Also when adding the arguments
	add them in reverse order, because of the change in 
	browser/declarative_execution mentioned above.

Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.51
diff -u -r1.51 declarative_debugger.m
--- browser/declarative_debugger.m	1 Feb 2005 07:11:26 -0000	1.51
+++ browser/declarative_debugger.m	19 Feb 2005 09:19:11 -0000
@@ -746,8 +746,9 @@
 write_origin(wrap(Store), Origin, !IO) :-
 	(Origin = output(dynamic(NodeId), ArgPos, TermPath) ->
 		exit_node_from_id(Store, NodeId, ExitNode),
-		ProcLabel = get_proc_label_from_layout(
-			ExitNode ^ exit_atom ^ proc_layout),
+		ProcLayout = get_proc_layout_from_label_layout(
+			ExitNode ^ exit_label),
+		ProcLabel = get_proc_label_from_layout(ProcLayout),
 		ProcName = get_proc_name(ProcLabel),
 		io.write_string("output(", !IO),
 		io.write_string(ProcName, !IO),
Index: browser/declarative_execution.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_execution.m,v
retrieving revision 1.37
diff -u -r1.37 declarative_execution.m
--- browser/declarative_execution.m	7 Feb 2005 11:41:04 -0000	1.37
+++ browser/declarative_execution.m	20 Feb 2005 03:03:57 -0000
@@ -40,7 +40,7 @@
 			call_last_interface	:: R,
 						% Last EXIT, REDO, FAIL or
 						% EXCP event.
-			call_atom		:: trace_atom,
+			call_atom_args		:: list(trace_atom_arg),
 						% Atom that was called.
 			call_seq		:: sequence_number,
 						% Call sequence number.
@@ -51,8 +51,9 @@
 			call_proc_rep		:: maybe(proc_rep),
 						% Body of the called procedure.
 			call_goal_path		:: goal_path_string,
-						% Path for this event *in the
-						% caller*.
+						% The goal path of the call 
+						% *in its parent*.
+			call_label		:: label_layout,
 			call_io_seq_num		:: int
 						% The I/O action sequence
 						% number at the time of the
@@ -65,10 +66,11 @@
 						% CALL event.
 			exit_prev_redo		:: R,
 						% Previous REDO event, if any.
-			exit_atom		:: trace_atom,
+			exit_atom_args		:: list(trace_atom_arg),
 						% Atom in its final state.
 			exit_event		:: event_number,
 						% Trace event number.
+			exit_label		:: label_layout,
 			exit_io_seq_num		:: int
 						% The I/O action sequence
 						% number at the time of the
@@ -79,8 +81,9 @@
 						% Preceding event.
 			redo_exit		:: R,
 						% EXIT event.
-			redo_event		:: event_number
+			redo_event		:: event_number,
 						% REDO event number.
+			redo_label		:: label_layout
 		)
 	;	fail(
 			fail_preceding		:: R,
@@ -89,8 +92,9 @@
 						% CALL event.
 			fail_redo		:: R,
 						% Previous REDO event, if any.
-			fail_event		:: event_number
+			fail_event		:: event_number,
 						% Trace event number.
+			fail_label		:: label_layout
 		)
 	;	excp(
 			excp_preceding		:: R,
@@ -101,34 +105,31 @@
 						% Previous redo, if any.
 			excp_value		:: term_rep,
 						% Exception thrown.
-			excp_event		:: event_number
+			excp_event		:: event_number,
 						% Trace event number.
+			excp_label		:: label_layout
 		)
 	;	switch(
 			switch_preceding	:: R,
 						% Preceding event.
-			switch_goal_path	:: goal_path_string
-						% Path for this event.
+			switch_label		:: label_layout
 		)
 	;	first_disj(
 			first_disj_preceding	:: R,
 						% Preceding event.
-			first_disj_goal_path	:: goal_path_string
-						% Path for this event.
+			first_disj_label	:: label_layout
 		)
 	;	later_disj(
 			later_disj_preceding	:: R,
 						% Preceding event.
-			later_disj_goal_path	:: goal_path_string,
-						% Path for this event.
+			later_disj_label	:: label_layout,
 			later_disj_first	:: R
 						% Event of the first DISJ.
 		)
 	;	cond(
 			cond_preceding		:: R,
 						% Preceding event.
-			cond_goal_path		:: goal_path_string,
-						% Path for this event.
+			cond_label		:: label_layout,
 			cond_status		:: goal_status
 						% Whether we have reached
 						% a THEN or ELSE event.
@@ -136,19 +137,21 @@
 	;	then(
 			then_preceding		:: R,
 						% Preceding event.
-			then_cond		:: R
+			then_cond		:: R,
 						% COND event.
+			then_label		:: label_layout
 		)
 	;	else(
 			else_preceding		:: R,
 						% Preceding event.
-			else_cond		:: R
+			else_cond		:: R,
 						% COND event.
+			else_label		:: label_layout
 		)
 	;	neg(
 			neg_preceding		:: R,
 						% Preceding event.
-			neg_goal_path		:: goal_path_string,
+			neg_label		:: label_layout,
 						% Path for this event.
 			neg_status		:: goal_status
 						% Whether we have reached
@@ -157,14 +160,16 @@
 	;	neg_succ(
 			neg_succ_preceding	:: R,
 						% Preceding event.
-			neg_succ_enter		:: R
+			neg_succ_enter		:: R,
 						% NEGE event.
+			neg_succ_label		:: label_layout
 		)
 	;	neg_fail(
 			neg_fail_preceding	:: R,
 						% Preceding event.
-			neg_fail_enter		:: R
+			neg_fail_enter		:: R,
 						% NEGE event.
+			neg_fail_label		:: label_layout
 		).
 
 :- type trace_atom_arg
@@ -193,7 +198,15 @@
 						% handle partially instantiated
 						% data structures.
 		).
- 
+
+:- func get_trace_exit_atom(trace_node(R)) = trace_atom.
+:- mode get_trace_exit_atom(in(trace_node_exit)) = out is det.
+:- mode get_trace_exit_atom(in) = out is semidet.
+
+:- func get_trace_call_atom(trace_node(R)) = trace_atom.
+:- mode get_trace_call_atom(in(trace_node_call)) = out is det.
+:- mode get_trace_call_atom(in) = out is semidet.
+
 :- type proc_layout. 
 
 :- func get_proc_label_from_layout(proc_layout) = proc_label.
@@ -209,6 +222,12 @@
 :- pred get_pred_attributes(proc_label::in, module_name::out, string::out, 
 	int::out, pred_or_func::out) is det.
 
+:- type label_layout.
+
+:- func get_proc_layout_from_label_layout(label_layout) = proc_layout.
+
+:- func get_goal_path_from_label_layout(label_layout) = goal_path_string.
+
 %-----------------------------------------------------------------------------%
 
 	% If the following type is modified, some of the macros in
@@ -274,13 +293,13 @@
 :- pred det_trace_node_from_id(S::in, R::in, trace_node(R)::out) is det
 	<= annotated_trace(S, R).
 
-:- inst trace_node_call ---> call(ground, ground, ground, ground,
+:- inst trace_node_call ---> call(ground, ground, ground, ground, ground,
 	ground, ground, ground, ground, ground).
 
 :- pred call_node_from_id(S::in, R::in, trace_node(R)::out(trace_node_call)) 
 	is det <= annotated_trace(S, R).
 
-:- inst trace_node_redo ---> redo(ground, ground, ground).
+:- inst trace_node_redo ---> redo(ground, ground, ground, ground).
 
 	% maybe_redo_node_from_id/3 fails if the argument is a
 	% NULL reference.
@@ -290,7 +309,7 @@
 	<= annotated_trace(S, R).
 
 :- inst trace_node_exit ---> exit(ground, ground, ground, ground,
-	ground, ground).
+	ground, ground, ground).
 
 :- pred exit_node_from_id(S::in, R::in, trace_node(R)::out(trace_node_exit)) 
 	is det <= annotated_trace(S, R).
@@ -579,10 +598,40 @@
 
 %-----------------------------------------------------------------------------%
 
-step_left_in_contour(Store, exit(_, Call, _, _, _, _)) = Prec :-
+:- pragma foreign_type("C", label_layout, "const MR_Label_Layout *",
+	[can_pass_as_mercury_type, stable]).
+:- pragma foreign_type("Java", label_layout, "Object", []). % stub only
+
+:- pragma foreign_proc("C", get_proc_layout_from_label_layout(Label::in)
+	= (ProcLayout::out),
+	[will_not_call_mercury, thread_safe, terminates, promise_pure],
+"
+	ProcLayout = Label->MR_sll_entry;
+").
+
+:- pragma foreign_proc("C", get_goal_path_from_label_layout(Label::in)
+	= (GoalPath::out),
+	[will_not_call_mercury, thread_safe, terminates, promise_pure],
+"
+	GoalPath = (MR_String)MR_label_goal_path(Label);
+").
+
+%-----------------------------------------------------------------------------%
+
+get_trace_exit_atom(exit(_, _, _, AtomArgs, _, Label, _)) = Atom :-
+	ProcLayout = get_proc_layout_from_label_layout(Label),
+	Atom = atom(ProcLayout, AtomArgs).
+
+get_trace_call_atom(call(_, _, AtomArgs, _, _, _, _, _, Label, _)) = Atom :-
+	ProcLayout = get_proc_layout_from_label_layout(Label),
+	Atom = atom(ProcLayout, AtomArgs).
+
+%-----------------------------------------------------------------------------%
+
+step_left_in_contour(Store, exit(_, Call, _, _, _, _, _)) = Prec :-
 	call_node_from_id(Store, Call, CallNode),
 	Prec = CallNode ^ call_preceding.
-step_left_in_contour(Store, excp(_, Call, _, _, _)) = Prec :-
+step_left_in_contour(Store, excp(_, Call, _, _, _, _)) = Prec :-
 	call_node_from_id(Store, Call, CallNode),
 	Prec = CallNode ^ call_preceding.
 step_left_in_contour(_, switch(Prec, _)) = Prec.
@@ -598,16 +647,16 @@
 	;
 		Node = Prec
 	).
-step_left_in_contour(_, then(Prec, _)) = Prec.
-step_left_in_contour(Store, else(_, Cond)) = Prec :-
+step_left_in_contour(_, then(Prec, _, _)) = Prec.
+step_left_in_contour(Store, else(_, Cond, _)) = Prec :-
 	cond_node_from_id(Store, Cond, cond(Prec, _, _)).
-step_left_in_contour(Store, neg_succ(_, Neg)) = Prec :-
+step_left_in_contour(Store, neg_succ(_, Neg, _)) = Prec :-
 	neg_node_from_id(Store, Neg, neg(Prec, _, _)).
 	%
 	% The following cases are possibly at the left end of a contour,
 	% where we cannot step any further.
 	%
-step_left_in_contour(_, call(_, _, _, _, _, _, _, _, _)) = _ :-
+step_left_in_contour(_, call(_, _, _, _, _, _, _, _, _, _)) = _ :-
 	throw(internal_error("step_left_in_contour", "unexpected CALL node")).
 step_left_in_contour(_, neg(Prec, _, Status)) = Next :-
 	(
@@ -628,13 +677,13 @@
 	% step to the previous contour instead.
 	%
 step_left_in_contour(Store, Node) = Prec :-
-	Node = fail(_, _, _, _),
+	Node = fail(_, _, _, _, _),
 	find_prev_contour(Store, Node, Prec).
 step_left_in_contour(Store, Node) = Prec :-
-	Node = redo(_, _, _),
+	Node = redo(_, _, _, _),
 	find_prev_contour(Store, Node, Prec).
 step_left_in_contour(Store, Node) = Prec :-
-	Node = neg_fail(_, _),
+	Node = neg_fail(_, _, _),
 	find_prev_contour(Store, Node, Prec).
 
 	% Given any node which is not on a contour, find a node on
@@ -645,36 +694,36 @@
 :- mode find_prev_contour(in, in(trace_node_reverse), out) is det.
 
 :- inst trace_node_reverse
-	---> 	fail(ground, ground, ground, ground)
-	;	redo(ground, ground, ground)
-	;	neg_fail(ground, ground).
+	---> 	fail(ground, ground, ground, ground, ground)
+	;	redo(ground, ground, ground, ground)
+	;	neg_fail(ground, ground, ground).
 
-find_prev_contour(Store, fail(_, Call, _, _), OnContour) :-
+find_prev_contour(Store, fail(_, Call, _, _, _), OnContour) :-
 	call_node_from_id(Store, Call, CallNode),
 	OnContour = CallNode ^ call_preceding.
-find_prev_contour(Store, redo(_, Exit, _), OnContour) :-
+find_prev_contour(Store, redo(_, Exit, _, _), OnContour) :-
 	exit_node_from_id(Store, Exit, ExitNode),
 	OnContour = ExitNode ^ exit_preceding.
-find_prev_contour(Store, neg_fail(_, Neg), OnContour) :-
+find_prev_contour(Store, neg_fail(_, Neg, _), OnContour) :-
 	neg_node_from_id(Store, Neg, neg(OnContour, _, _)).
 	%
 	% The following cases are at the left end of a contour,
 	% so there are no previous contours in the same stratum.
 	%
-find_prev_contour(_, call(_, _, _, _, _, _, _, _, _), _) :-
+find_prev_contour(_, call(_, _, _, _, _, _, _, _, _, _), _) :-
 	throw(internal_error("find_prev_contour", "reached CALL node")).
 find_prev_contour(_, cond(_, _, _), _) :-
 	throw(internal_error("find_prev_contour", "reached COND node")).
 find_prev_contour(_, neg(_, _, _), _) :-
 	throw(internal_error("find_prev_contour", "reached NEGE node")).
 
-step_in_stratum(Store, exit(_, Call, MaybeRedo, _, _, _)) =
+step_in_stratum(Store, exit(_, Call, MaybeRedo, _, _, _, _)) =
 	step_over_redo_or_call(Store, Call, MaybeRedo).
-step_in_stratum(Store, fail(_, Call, MaybeRedo, _)) =
+step_in_stratum(Store, fail(_, Call, MaybeRedo, _, _)) =
 	step_over_redo_or_call(Store, Call, MaybeRedo).
-step_in_stratum(Store, excp(_, Call, MaybeRedo, _, _)) =
+step_in_stratum(Store, excp(_, Call, MaybeRedo, _, _, _)) =
 	step_over_redo_or_call(Store, Call, MaybeRedo).
-step_in_stratum(Store, redo(_, Exit, _)) = Next :-
+step_in_stratum(Store, redo(_, Exit, _, _)) = Next :-
 	exit_node_from_id(Store, Exit, ExitNode),
 	Next = ExitNode ^ exit_preceding.
 step_in_stratum(_, switch(Next, _)) = Next.
@@ -688,18 +737,18 @@
 	;
 		Next = Prec
 	).
-step_in_stratum(_, then(Next, _)) = Next.
-step_in_stratum(Store, else(_, Cond)) = Next :-
+step_in_stratum(_, then(Next, _, _)) = Next.
+step_in_stratum(Store, else(_, Cond, _)) = Next :-
 	cond_node_from_id(Store, Cond, cond(Next, _, _)).
-step_in_stratum(Store, neg_succ(_, Neg)) = Next :-
+step_in_stratum(Store, neg_succ(_, Neg, _)) = Next :-
 	neg_node_from_id(Store, Neg, neg(Next, _, _)).
-step_in_stratum(Store, neg_fail(_, Neg)) = Next :-
+step_in_stratum(Store, neg_fail(_, Neg, _)) = Next :-
 	neg_node_from_id(Store, Neg, neg(Next, _, _)).
 	%
 	% The following cases mark the boundary of the stratum,
 	% so we cannot step any further.
 	%
-step_in_stratum(_, call(_, _, _, _, _, _, _, _, _)) = _ :-
+step_in_stratum(_, call(_, _, _, _, _, _, _, _, _, _)) = _ :-
 	throw(internal_error("step_in_stratum", "unexpected CALL node")).
 step_in_stratum(_, neg(_, _, _)) = _ :-
 	throw(internal_error("step_in_stratum", "unexpected NEGE node")).
@@ -710,7 +759,7 @@
 	(
 		maybe_redo_node_from_id(Store, MaybeRedo, Redo)
 	->
-		Redo = redo(Next, _, _)
+		Redo = redo(Next, _, _, _)
 	;
 		call_node_from_id(Store, Call, CallNode),
 		Next = CallNode ^ call_preceding
@@ -728,7 +777,7 @@
 call_node_from_id(Store, NodeId, Node) :-
 	(
 		trace_node_from_id(Store, NodeId, Node0),
-		Node0 = call(_, _, _, _, _, _, _, _, _)
+		Node0 = call(_, _, _, _, _, _, _, _, _, _)
 	->
 		Node = Node0
 	;
@@ -738,7 +787,7 @@
 maybe_redo_node_from_id(Store, NodeId, Node) :-
 	trace_node_from_id(Store, NodeId, Node0),
 	(
-		Node0 = redo(_, _, _)
+		Node0 = redo(_, _, _, _)
 	->
 		Node = Node0
 	;
@@ -749,7 +798,7 @@
 exit_node_from_id(Store, NodeId, Node) :-
 	(
 		trace_node_from_id(Store, NodeId, Node0),
-		Node0 = exit(_, _, _, _, _, _)
+		Node0 = exit(_, _, _, _, _, _, _)
 	->
 		Node = Node0
 	;
@@ -846,7 +895,7 @@
 
 call_node_get_last_interface(Call) = Last :-
 	(
-		Call = call(_, Last0, _, _, _, _, _, _, _)
+		Call = call(_, Last0, _, _, _, _, _, _, _, _)
 	->
 		Last = Last0
 	;
@@ -862,7 +911,7 @@
 
 call_node_set_last_interface(Call0, Last) = Call :-
 	(
-		Call0 = call(_, _, _, _, _, _, _, _, _)
+		Call0 = call(_, _, _, _, _, _, _, _, _, _)
 	->
 		Call1 = Call0
 	;
@@ -926,46 +975,44 @@
 :- pragma export(trace_node_port(in) = out,
 		"MR_DD_trace_node_port").
 
-trace_node_port(call(_, _, _, _, _, _, _, _, _)) = call.
-trace_node_port(exit(_, _, _, _, _, _))	= exit.
-trace_node_port(redo(_, _, _))		= redo.
-trace_node_port(fail(_, _, _, _))	= fail.
-trace_node_port(excp(_, _, _, _, _))	= exception.
-trace_node_port(switch(_, _))		= switch.
-trace_node_port(first_disj(_, _))	= disj.
-trace_node_port(later_disj(_, _, _))	= disj.
-trace_node_port(cond(_, _, _))		= ite_cond.
-trace_node_port(then(_, _))		= ite_then.
-trace_node_port(else(_, _))		= ite_else.
-trace_node_port(neg(_, _, _))		= neg_enter.
-trace_node_port(neg_succ(_, _))		= neg_success.
-trace_node_port(neg_fail(_, _))		= neg_failure.
-
-:- func trace_node_path(trace_node_store, trace_node(trace_node_id))
-		= goal_path_string.
-:- pragma export(trace_node_path(in, in) = out,
-		"MR_DD_trace_node_path").
-
-% XXX fix the returned path for interface events other than calls.
-
-trace_node_path(_, call(_, _, _, _, _, _, _, P, _)) = P.
-trace_node_path(_, exit(_, _, _, _, _, _)) = "".
-trace_node_path(_, redo(_, _, _)) = "".
-trace_node_path(_, fail(_, _, _, _)) = "".
-trace_node_path(_, excp(_, _, _, _, _)) = "".
-trace_node_path(_, switch(_, P)) = P.
-trace_node_path(_, first_disj(_, P)) = P.
-trace_node_path(_, later_disj(_, P, _)) = P.
-trace_node_path(_, cond(_, P, _)) = P.
-trace_node_path(S, then(_, Cond)) = P :-
-	cond_node_from_id(S, Cond, cond(_, P, _)).
-trace_node_path(S, else(_, Cond)) = P :-
-	cond_node_from_id(S, Cond, cond(_, P, _)).
-trace_node_path(_, neg(_, P, _)) = P.
-trace_node_path(S, neg_succ(_, Neg)) = P :-
-	neg_node_from_id(S, Neg, neg(_, P, _)).
-trace_node_path(S, neg_fail(_, Neg)) = P :-
-	neg_node_from_id(S, Neg, neg(_, P, _)).
+trace_node_port(call(_, _, _, _, _, _, _, _, _, _))	= call.
+trace_node_port(exit(_, _, _, _, _, _, _))		= exit.
+trace_node_port(redo(_, _, _, _))			= redo.
+trace_node_port(fail(_, _, _, _, _))			= fail.
+trace_node_port(excp(_, _, _, _, _, _))			= exception.
+trace_node_port(switch(_, _))				= switch.
+trace_node_port(first_disj(_, _))			= disj.
+trace_node_port(later_disj(_, _, _))			= disj.
+trace_node_port(cond(_, _, _))				= ite_cond.
+trace_node_port(then(_, _, _))				= ite_then.
+trace_node_port(else(_, _, _))				= ite_else.
+trace_node_port(neg(_, _, _))				= neg_enter.
+trace_node_port(neg_succ(_, _, _))			= neg_success.
+trace_node_port(neg_fail(_, _, _))			= neg_failure.
+
+:- func trace_node_path(trace_node(trace_node_id)) = goal_path_string.
+:- pragma export(trace_node_path(in) = out, "MR_DD_trace_node_path").
+
+trace_node_path(Node) = Path :-
+	Label = get_trace_node_label(Node),
+	Path = get_goal_path_from_label_layout(Label).
+
+:- func get_trace_node_label(trace_node(R)) = label_layout.
+
+get_trace_node_label(call(_, _, _, _, _, _, _, _, Label, _)) = Label.
+get_trace_node_label(exit(_, _, _, _, _, Label, _)) = Label.
+get_trace_node_label(redo(_, _, _, Label)) = Label.
+get_trace_node_label(fail(_, _, _, _, Label)) = Label.
+get_trace_node_label(excp(_, _, _, _, _, Label)) = Label.
+get_trace_node_label(switch(_, Label)) = Label.
+get_trace_node_label(first_disj(_, Label)) = Label.
+get_trace_node_label(later_disj(_, Label, _)) = Label.
+get_trace_node_label(cond(_, Label, _)) = Label.
+get_trace_node_label(then(_, _, Label)) = Label.
+get_trace_node_label(else(_, _, Label)) = Label.
+get_trace_node_label(neg(_, Label, _)) = Label.
+get_trace_node_label(neg_succ(_, _, Label)) = Label.
+get_trace_node_label(neg_fail(_, _, Label)) = Label.
 
 :- pred trace_node_seqno(trace_node_store::in, trace_node(trace_node_id)::in,
 		sequence_number::out) is semidet.
@@ -988,12 +1035,12 @@
 
 :- pragma export(trace_node_call(in, in, out), "MR_DD_trace_node_call").
 
-trace_node_call(_, exit(_, Call, _, _, _, _), Call).
-trace_node_call(S, redo(_, Exit, _), Call) :-
+trace_node_call(_, exit(_, Call, _, _, _, _, _), Call).
+trace_node_call(S, redo(_, Exit, _, _), Call) :-
 	exit_node_from_id(S, Exit, ExitNode),
 	Call = ExitNode ^ exit_call.
-trace_node_call(_, fail(_, Call, _, _), Call).
-trace_node_call(_, excp(_, Call, _, _, _), Call).
+trace_node_call(_, fail(_, Call, _, _, _), Call).
+trace_node_call(_, excp(_, Call, _, _, _, _), Call).
 
 :- pred trace_node_first_disj(trace_node(trace_node_id)::in, 
 	trace_node_id::out) is semidet.
@@ -1056,85 +1103,88 @@
 	% that the back end can build an execution tree.
 	%
 
-:- func construct_call_node(trace_node_id, trace_atom, sequence_number,
-		event_number, bool, string, int) = trace_node(trace_node_id).
-:- pragma export(construct_call_node(in, in, in, in, in, in, in) = out,
-		"MR_DD_construct_call_node").
-
-construct_call_node(Preceding, Atom, SeqNo, EventNo, MaxDepth, Path, IoSeqNum)
-		= Call :-
-	Call = call(Preceding, Answer, Atom, SeqNo, EventNo, MaxDepth,
-		no, Path, IoSeqNum),
+:- func construct_call_node(trace_node_id, list(trace_atom_arg), 
+	sequence_number, event_number, bool, string, label_layout, int) 
+	= trace_node(trace_node_id).
+:- pragma export(construct_call_node(in, in, in, in, in, in, in, in) = out,
+	"MR_DD_construct_call_node").
+
+construct_call_node(Preceding, AtomArgs, SeqNo, EventNo, MaxDepth, Path, Label, 
+		IoSeqNum) = Call :-
+	Call = call(Preceding, Answer, AtomArgs, SeqNo, EventNo, MaxDepth,
+		no, Path, Label, IoSeqNum),
 	null_trace_node_id(Answer).
 
-:- func construct_call_node_with_goal(trace_node_id, trace_atom,
-		sequence_number, event_number, bool, proc_rep, string, int)
-		= trace_node(trace_node_id).
-:- pragma export(construct_call_node_with_goal(in, in, in, in, in, in, in, in)
-		= out, "MR_DD_construct_call_node_with_goal").
-
-construct_call_node_with_goal(Preceding, Atom, SeqNo, EventNo, MaxDepth,
-		ProcRep, Path, IoSeqNum) = Call :-
-	Call = call(Preceding, Answer, Atom, SeqNo, EventNo, MaxDepth,
-		yes(ProcRep), Path, IoSeqNum),
+:- func construct_call_node_with_goal(trace_node_id, list(trace_atom_arg),
+	sequence_number, event_number, bool, proc_rep, string, label_layout, 
+	int) = trace_node(trace_node_id).
+:- pragma export(construct_call_node_with_goal(in, in, in, in, in, in, in, in,
+	in) = out, "MR_DD_construct_call_node_with_goal").
+
+construct_call_node_with_goal(Preceding, AtomArgs, SeqNo, EventNo, MaxDepth,
+		ProcRep, Path, Label, IoSeqNum) = Call :-
+	Call = call(Preceding, Answer, AtomArgs, SeqNo, EventNo, MaxDepth,
+		yes(ProcRep), Path, Label, IoSeqNum),
 	null_trace_node_id(Answer).
 
 :- func construct_exit_node(trace_node_id, trace_node_id, trace_node_id,
-		trace_atom, event_number, int) = trace_node(trace_node_id).
-:- pragma export(construct_exit_node(in, in, in, in, in, in) = out,
-		"MR_DD_construct_exit_node").
+	list(trace_atom_arg), event_number, label_layout, int) 
+	= trace_node(trace_node_id).
+:- pragma export(construct_exit_node(in, in, in, in, in, in, in) = out,
+	"MR_DD_construct_exit_node").
+
+construct_exit_node(Preceding, Call, MaybeRedo, AtomArgs, EventNo, Label, 
+		IoSeqNum) = 
+	exit(Preceding, Call, MaybeRedo, AtomArgs, EventNo, Label, IoSeqNum).
+
+:- func construct_redo_node(trace_node_id, trace_node_id, event_number,
+	label_layout) = trace_node(trace_node_id).
+:- pragma export(construct_redo_node(in, in, in, in) = out,
+	"MR_DD_construct_redo_node").
 
-construct_exit_node(Preceding, Call, MaybeRedo, Atom, EventNo, IoSeqNum)
-	= exit(Preceding, Call, MaybeRedo, Atom, EventNo, IoSeqNum).
-
-:- func construct_redo_node(trace_node_id, trace_node_id, event_number)
-		= trace_node(trace_node_id).
-:- pragma export(construct_redo_node(in, in, in) = out,
-		"MR_DD_construct_redo_node").
-
-construct_redo_node(Preceding, Exit, Event) = redo(Preceding, Exit, Event).
+construct_redo_node(Preceding, Exit, Event, Label) 
+	= redo(Preceding, Exit, Event, Label).
 
 :- func construct_fail_node(trace_node_id, trace_node_id, trace_node_id,
-		event_number) = trace_node(trace_node_id).
-:- pragma export(construct_fail_node(in, in, in, in) = out,
-		"MR_DD_construct_fail_node").
+	event_number, label_layout) = trace_node(trace_node_id).
+:- pragma export(construct_fail_node(in, in, in, in, in) = out,
+	"MR_DD_construct_fail_node").
 
-construct_fail_node(Preceding, Call, Redo, EventNo) =
-		fail(Preceding, Call, Redo, EventNo).
+construct_fail_node(Preceding, Call, Redo, EventNo, Label) =
+		fail(Preceding, Call, Redo, EventNo, Label).
 
 :- pred construct_excp_node(trace_node_id::in, trace_node_id::in, 
-	trace_node_id::in, univ::in, event_number::in, 
+	trace_node_id::in, univ::in, event_number::in, label_layout::in,
 	trace_node(trace_node_id)::out) is cc_multi.
-:- pragma export(construct_excp_node(in, in, in, in, in, out),
-		"MR_DD_construct_excp_node").
+:- pragma export(construct_excp_node(in, in, in, in, in, in, out),
+	"MR_DD_construct_excp_node").
 
-construct_excp_node(Preceding, Call, MaybeRedo, Exception, EventNo, Excp) :-
-		term_rep.univ_to_rep(Exception, ExceptionRep),
-		Excp = excp(Preceding, Call, MaybeRedo, ExceptionRep, EventNo).
+construct_excp_node(Preceding, Call, MaybeRedo, Exception, EventNo, Label, 
+		Excp) :-
+	term_rep.univ_to_rep(Exception, ExceptionRep),
+	Excp = excp(Preceding, Call, MaybeRedo, ExceptionRep, EventNo, Label).
 
-:- func construct_switch_node(trace_node_id, goal_path_string)
+:- func construct_switch_node(trace_node_id, label_layout)
 		= trace_node(trace_node_id).
 :- pragma export(construct_switch_node(in, in) = out,
 		"MR_DD_construct_switch_node").
 
-construct_switch_node(Preceding, Path) =
-		switch(Preceding, Path).
+construct_switch_node(Preceding, Label) = switch(Preceding, Label).
 
-:- func construct_first_disj_node(trace_node_id, goal_path_string)
+:- func construct_first_disj_node(trace_node_id, label_layout)
 		= trace_node(trace_node_id).
 :- pragma export(construct_first_disj_node(in, in) = out,
 		"MR_DD_construct_first_disj_node").
 
-construct_first_disj_node(Preceding, Path) =
-		first_disj(Preceding, Path).
+construct_first_disj_node(Preceding, Label) = first_disj(Preceding, Label).
 
 :- func construct_later_disj_node(trace_node_store, trace_node_id,
-		goal_path_string, trace_node_id) = trace_node(trace_node_id).
+		label_layout, trace_node_id) = trace_node(trace_node_id).
 :- pragma export(construct_later_disj_node(in, in, in, in) = out,
 		"MR_DD_construct_later_disj_node").
 
-construct_later_disj_node(Store, Preceding, Path, PrevDisj)
-		= later_disj(Preceding, Path, FirstDisj) :-
+construct_later_disj_node(Store, Preceding, Label, PrevDisj)
+		= later_disj(Preceding, Label, FirstDisj) :-
 	disj_node_from_id(Store, PrevDisj, PrevDisjNode),
 	(
 		PrevDisjNode = first_disj(_, _),
@@ -1143,47 +1193,49 @@
 		PrevDisjNode = later_disj(_, _, FirstDisj)
 	).
 
-:- func construct_cond_node(trace_node_id, goal_path_string)
+:- func construct_cond_node(trace_node_id, label_layout)
 		= trace_node(trace_node_id).
 :- pragma export(construct_cond_node(in, in) = out,
 		"MR_DD_construct_cond_node").
 
-construct_cond_node(Preceding, Path) = cond(Preceding, Path, undecided).
+construct_cond_node(Preceding, Label) = cond(Preceding, Label, undecided).
 
-:- func construct_then_node(trace_node_id, trace_node_id)
+:- func construct_then_node(trace_node_id, trace_node_id, label_layout)
 		= trace_node(trace_node_id).
-:- pragma export(construct_then_node(in, in) = out,
+:- pragma export(construct_then_node(in, in, in) = out,
 		"MR_DD_construct_then_node").
 
-construct_then_node(Preceding, Cond) = then(Preceding, Cond).
+construct_then_node(Preceding, Cond, Label) = then(Preceding, Cond, Label).
 
-:- func construct_else_node(trace_node_id, trace_node_id)
+:- func construct_else_node(trace_node_id, trace_node_id, label_layout)
 		= trace_node(trace_node_id).
-:- pragma export(construct_else_node(in, in) = out,
+:- pragma export(construct_else_node(in, in, in) = out,
 		"MR_DD_construct_else_node").
 
-construct_else_node(Preceding, Cond) = else(Preceding, Cond).
+construct_else_node(Preceding, Cond, Label) = else(Preceding, Cond, Label).
 
-:- func construct_neg_node(trace_node_id, goal_path_string)
+:- func construct_neg_node(trace_node_id, label_layout)
 		= trace_node(trace_node_id).
 :- pragma export(construct_neg_node(in, in) = out,
 		"MR_DD_construct_neg_node").
 
-construct_neg_node(Preceding, Path) = neg(Preceding, Path, undecided).
+construct_neg_node(Preceding, Label) = neg(Preceding, Label, undecided).
 
-:- func construct_neg_succ_node(trace_node_id, trace_node_id)
+:- func construct_neg_succ_node(trace_node_id, trace_node_id, label_layout)
 		= trace_node(trace_node_id).
-:- pragma export(construct_neg_succ_node(in, in) = out,
+:- pragma export(construct_neg_succ_node(in, in, in) = out,
 		"MR_DD_construct_neg_succ_node").
 
-construct_neg_succ_node(Preceding, Neg) = neg_succ(Preceding, Neg).
+construct_neg_succ_node(Preceding, Neg, Label) 
+	= neg_succ(Preceding, Neg, Label).
 
-:- func construct_neg_fail_node(trace_node_id, trace_node_id)
+:- func construct_neg_fail_node(trace_node_id, trace_node_id, label_layout)
 		= trace_node(trace_node_id).
-:- pragma export(construct_neg_fail_node(in, in) = out,
+:- pragma export(construct_neg_fail_node(in, in, in) = out,
 		"MR_DD_construct_neg_fail_node").
 
-construct_neg_fail_node(Preceding, Neg) = neg_fail(Preceding, Neg).
+construct_neg_fail_node(Preceding, Neg, Label) 
+	= neg_fail(Preceding, Neg, Label).
 
 :- pred null_trace_node_id(trace_node_id::out) is det.
 
@@ -1196,39 +1248,36 @@
 null_trace_node_id(_) :-
 	private_builtin.sorry("null_trace_node_id").
 
-:- func construct_trace_atom(proc_layout, int) = trace_atom.
-:- pragma export(construct_trace_atom(in, in) = out,
-		"MR_DD_construct_trace_atom").
-
-construct_trace_atom(ProcLabel, Arity) = atom(ProcLabel, Args) :-
-	list.duplicate(Arity, dummy_arg_info, Args).
-
-	% add_trace_atom_arg_value(ArgNum, HldsNum, ProgVis, Val, !Atom):
-	% Register the fact that argument number ArgNum in Atom is the HLDS
-	% variable whose number is HldsNum and whose value is Val. ProgVis
-	% is a C boolean, which is true iff variable HldsNum is a user visible
+:- func init_trace_atom_args = list(trace_atom_arg).
+
+:- pragma export(init_trace_atom_args = out, "MR_DD_init_trace_atom_args").
+
+init_trace_atom_args = [].
+
+	% add_trace_atom_arg_value(HldsNum, ProgVis, Val, !AtomArgs):
+	% Add the argument with value Val and HLDS number HldsNum to the
+	% beginning of a list of arguments for an atom.  ProgVis is a C
+	% boolean, which is true iff variable HldsNum is a user visible
 	% variable.
-:- pred add_trace_atom_arg_value(int::in, int::in, int::in, univ::in, 
-	trace_atom::in, trace_atom::out) is cc_multi.
-:- pragma export(add_trace_atom_arg_value(in, in, in, in, in, out),
-		"MR_DD_add_trace_atom_arg_value").
+	%
+:- pred add_trace_atom_arg_value(int::in, int::in, univ::in, 
+	list(trace_atom_arg)::in, list(trace_atom_arg)::out) is cc_multi.
+:- pragma export(add_trace_atom_arg_value(in, in, in, in, out),
+	"MR_DD_add_trace_atom_arg_value").
 
-add_trace_atom_arg_value(ArgNum, HldsNum, ProgVis, Val, atom(P, Args0),
-		atom(P, Args)) :-
+add_trace_atom_arg_value(HldsNum, ProgVis, Val, Args, [Arg | Args]) :-
 	term_rep.univ_to_rep(Val, Rep),
-	Arg = arg_info(c_bool_to_merc_bool(ProgVis), HldsNum, yes(Rep)),
-	list.replace_nth_det(Args0, ArgNum, Arg, Args).
+	Arg = arg_info(c_bool_to_merc_bool(ProgVis), HldsNum, yes(Rep)).
 
 	% Like add_trace_atom_arg_value, except that the specified variable
 	% has no value (i.e. it is not bound).
-:- func add_trace_atom_arg_no_value(trace_atom, int, int, int) = trace_atom.
-:- pragma export(add_trace_atom_arg_no_value(in, in, in, in) = out,
+:- pred add_trace_atom_arg_no_value(int::in, int::in, 
+	list(trace_atom_arg)::in, list(trace_atom_arg)::out) is det.
+:- pragma export(add_trace_atom_arg_no_value(in, in, in, out),
 		"MR_DD_add_trace_atom_arg_no_value").
 
-add_trace_atom_arg_no_value(atom(P, Args0), ArgNum, HldsNum, ProgVis)
-		= atom(P, Args) :-
-	Arg = arg_info(c_bool_to_merc_bool(ProgVis), HldsNum, no),
-	list.replace_nth_det(Args0, ArgNum, Arg, Args).
+add_trace_atom_arg_no_value(HldsNum, ProgVis, Args, [Arg | Args]) :-
+	Arg = arg_info(c_bool_to_merc_bool(ProgVis), HldsNum, no).
 
 	% This code converts a C bool (represented as int) to a Mercury bool.
 :- func c_bool_to_merc_bool(int) = bool.
@@ -1347,20 +1396,20 @@
 	%
 :- func preceding_node(trace_node(T)) = T.
 
-preceding_node(call(P, _, _, _, _, _, _, _, _)) = P.
-preceding_node(exit(P, _, _, _, _, _))	= P.
-preceding_node(redo(P, _, _))		= P.
-preceding_node(fail(P, _, _, _))	= P.
-preceding_node(excp(P, _, _, _, _))	= P.
-preceding_node(switch(P, _))		= P.
-preceding_node(first_disj(P, _))	= P.
-preceding_node(later_disj(P, _, _))	= P.
-preceding_node(cond(P, _, _))		= P.
-preceding_node(then(P, _))		= P.
-preceding_node(else(P, _))		= P.
-preceding_node(neg(P, _, _))		= P.
-preceding_node(neg_succ(P, _))		= P.
-preceding_node(neg_fail(P, _))		= P.
+preceding_node(call(P, _, _, _, _, _, _, _, _, _)) = P.
+preceding_node(exit(P, _, _, _, _, _, _))	= P.
+preceding_node(redo(P, _, _, _))		= P.
+preceding_node(fail(P, _, _, _, _))		= P.
+preceding_node(excp(P, _, _, _, _, _))		= P.
+preceding_node(switch(P, _))			= P.
+preceding_node(first_disj(P, _))		= P.
+preceding_node(later_disj(P, _, _))		= P.
+preceding_node(cond(P, _, _))			= P.
+preceding_node(then(P, _, _))			= P.
+preceding_node(else(P, _, _))			= P.
+preceding_node(neg(P, _, _))			= P.
+preceding_node(neg_succ(P, _, _))		= P.
+preceding_node(neg_fail(P, _, _))		= P.
 
 %-----------------------------------------------------------------------------%
 
Index: browser/declarative_tree.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_tree.m,v
retrieving revision 1.20
diff -u -r1.20 declarative_tree.m
--- browser/declarative_tree.m	7 Feb 2005 11:41:04 -0000	1.20
+++ browser/declarative_tree.m	19 Feb 2005 09:19:33 -0000
@@ -75,7 +75,7 @@
 	<= annotated_trace(S, R).
 
 exit_node_decl_atom(IoActionMap, Store, ExitNode) = DeclAtom :-
-	ExitAtom = ExitNode ^ exit_atom,
+	ExitAtom = get_trace_exit_atom(ExitNode),
 	CallId = ExitNode ^ exit_call,
 	call_node_from_id(Store, CallId, Call),
 	CallIoSeq = Call ^ call_io_seq_num,
@@ -87,7 +87,7 @@
 
 call_node_decl_atom(Store, CallId) = DeclAtom :-
 	call_node_from_id(Store, CallId, CallNode),
-	CallAtom = CallNode ^ call_atom,
+	CallAtom = get_trace_call_atom(CallNode),
 	DeclAtom = init_decl_atom(CallAtom).
 
 :- func make_io_actions(io_action_map, int, int) = list(io_action).
@@ -106,13 +106,13 @@
 get_edt_node_initial_atom(Store, Ref, Atom) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = exit(_, CallId, _, _, _, _),
+		Node = exit(_, CallId, _, _, _, _, _),
 		Atom = call_node_decl_atom(Store, CallId)
 	;
-		Node = fail(_, CallId, _, _),
+		Node = fail(_, CallId, _, _, _),
 		Atom = call_node_decl_atom(Store, CallId)
 	;
-		Node = excp(_, CallId, _, _, _),
+		Node = excp(_, CallId, _, _, _, _),
 		Atom = call_node_decl_atom(Store, CallId)
 	).
 
@@ -122,11 +122,11 @@
 get_edt_node_event_number(Store, Ref, Event) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = exit(_, _, _, _, Event, _)
+		Node = exit(_, _, _, _, Event, _, _)
 	;
-		Node = fail(_, _, _, Event)
+		Node = fail(_, _, _, Event, _)
 	;
-		Node = excp(_, _, _, _, Event)
+		Node = excp(_, _, _, _, Event, _)
 	).
 
 %-----------------------------------------------------------------------------%
@@ -137,17 +137,17 @@
 trace_question(IoActionMap, wrap(Store), dynamic(Ref), Root) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = fail(_, CallId, RedoId, _),
+		Node = fail(_, CallId, RedoId, _, _),
 		DeclAtom = call_node_decl_atom(Store, CallId),
 		get_answers(IoActionMap, Store, RedoId, [], Answers),
 		Root = missing_answer(dynamic(Ref), DeclAtom, Answers)
 	;
-		Node = exit(_, CallId, _, _, _, _),
+		Node = exit(_, CallId, _, _, _, _, _),
 		InitDeclAtom = call_node_decl_atom(Store, CallId),
 		FinalDeclAtom = exit_node_decl_atom(IoActionMap, Store, Node),
 		Root = wrong_answer(dynamic(Ref), InitDeclAtom, FinalDeclAtom)
 	;
-		Node = excp(_, CallId, _, Exception, _),
+		Node = excp(_, CallId, _, Exception, _, _),
 		DeclAtom = call_node_decl_atom(Store, CallId),
 		Root = unexpected_exception(dynamic(Ref), DeclAtom, Exception)
 	).
@@ -158,7 +158,7 @@
 
 get_answers(IoActionMap, Store, RedoId, DeclAtoms0, DeclAtoms) :-
 	(
-		maybe_redo_node_from_id(Store, RedoId, redo(_, ExitId, _))
+		maybe_redo_node_from_id(Store, RedoId, redo(_, ExitId, _, _))
 	->
 		exit_node_from_id(Store, ExitId, ExitNode),
 		NextId = ExitNode ^ exit_prev_redo,
@@ -175,18 +175,18 @@
 trace_get_e_bug(IoActionMap, wrap(Store), dynamic(Ref), Bug) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = exit(_, CallId, _, _, Event, _),
+		Node = exit(_, CallId, _, _, Event, _, _),
 		InitDeclAtom = call_node_decl_atom(Store, CallId),
 		FinalDeclAtom = exit_node_decl_atom(IoActionMap, Store, Node),
 		get_exit_atoms_in_contour(IoActionMap, Store, Node, Contour),
 		Bug = incorrect_contour(InitDeclAtom, FinalDeclAtom, Contour, 
 			Event)
 	;
-		Node = fail(_, CallId, _, Event),
+		Node = fail(_, CallId, _, Event, _),
 		DeclAtom = call_node_decl_atom(Store, CallId),
 		Bug = partially_uncovered_atom(DeclAtom, Event)
 	;
-		Node = excp(_, CallId, _, Exception, Event),
+		Node = excp(_, CallId, _, Exception, Event, _),
 		DeclAtom = call_node_decl_atom(Store, CallId),
 		Bug = unhandled_exception(DeclAtom, Exception, Event)
 	).
@@ -217,11 +217,11 @@
 trace_last_parent(wrap(Store), dynamic(Ref), dynamic(Parent)) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = fail(_, CallId, _, _)
+		Node = fail(_, CallId, _, _, _)
 	;
-		Node = exit(_, CallId, _, _, _, _)
+		Node = exit(_, CallId, _, _, _, _, _)
 	;
-		Node = excp(_, CallId, _, _, _)
+		Node = excp(_, CallId, _, _, _, _)
 	),
 	call_node_from_id(Store, CallId, Call),
 	CallPrecId = Call ^ call_preceding,
@@ -235,14 +235,14 @@
 	det_edt_return_node_from_id(Store, Ref1, Node1),
 	det_edt_return_node_from_id(Store, Ref2, Node2),
 	(
-		Node1 = exit(_, _, _, _, Event, _),
-		Node2 = exit(_, _, _, _, Event, _)
+		Node1 = exit(_, _, _, _, Event, _, _),
+		Node2 = exit(_, _, _, _, Event, _, _)
 	;
-		Node1 = fail(_, _, _, Event),
-		Node2 = fail(_, _, _, Event)
+		Node1 = fail(_, _, _, Event, _),
+		Node2 = fail(_, _, _, Event, _)
 	;
-		Node1 = excp(_, _, _, _, Event),
-		Node2 = excp(_, _, _, _, Event)
+		Node1 = excp(_, _, _, _, Event, _),
+		Node2 = excp(_, _, _, _, Event, _)
 	).
 
 :- pred trace_topmost_node(wrap(S)::in, edt_node(R)::in) is semidet
@@ -251,14 +251,14 @@
 trace_topmost_node(wrap(Store), dynamic(Ref)) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = exit(_, CallId, _, _, _, _)
+		Node = exit(_, CallId, _, _, _, _, _)
 	;
-		Node = fail(_, CallId, _, _)
+		Node = fail(_, CallId, _, _, _)
 	;
-		Node = excp(_, CallId, _, _, _)
+		Node = excp(_, CallId, _, _, _, _)
 	),
 	% The node is topmost of the call sequence number is 1.
-	call_node_from_id(Store, CallId, call(_, _, _, 1, _, _, _, _, _)).
+	call_node_from_id(Store, CallId, call(_, _, _, 1, _, _, _, _, _, _)).
 
 :- pred trace_children(wrap(S)::in, edt_node(R)::in, list(edt_node(R))::out)
 	is semidet <= annotated_trace(S, R).
@@ -266,11 +266,12 @@
 trace_children(wrap(Store), dynamic(Ref), Children) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = fail(PrecId, CallId, _, _),
+		Node = fail(PrecId, CallId, _, _, _),
 		not_at_depth_limit(Store, CallId),
 		stratum_children(Store, PrecId, CallId, [], Children)
 	;
-		Node = exit(PrecId, CallId, _, Atom, _, _),
+		Node = exit(PrecId, CallId, _, _, _, _, _),
+		Atom = get_trace_exit_atom(Node),
 		not_at_depth_limit(Store, CallId),
 		(
 			missing_answer_special_case(Atom)
@@ -282,7 +283,7 @@
 				[], Children)
 		)
 	;
-		Node = excp(PrecId, CallId, _, _, _),
+		Node = excp(PrecId, CallId, _, _, _, _),
 		not_at_depth_limit(Store, CallId),
 		contour_children(exception, Store, PrecId, CallId, [],
 			Children)
@@ -333,19 +334,19 @@
 	det_trace_node_from_id(Store, Ref, Final),
 	(
 		(
-			Final = exit(_, CallId, RedoId, _, FinalEvent, _),
+			Final = exit(_, CallId, RedoId, _, FinalEvent, _, _),
 			NewRecordDups = RecordDups
 		;
-			Final = fail(_, CallId, RedoId, FinalEvent),
+			Final = fail(_, CallId, RedoId, FinalEvent, _),
 			NewRecordDups = yes
 		;
-			Final = excp(_, CallId, RedoId, _, FinalEvent),
+			Final = excp(_, CallId, RedoId, _, FinalEvent, _),
 			NewRecordDups = yes
 		)
 	->
 		(
 			maybe_redo_node_from_id(Store, RedoId, Redo),
-			Redo = redo(_, ExitId, RedoEvent)
+			Redo = redo(_, ExitId, RedoEvent, _)
 		->
 			(
 				NewRecordDups = yes,
@@ -427,7 +428,7 @@
 	det_trace_node_from_id(Store, NodeId, Node),
 	(
 		( 
-			Node = call(_, _, _, _, _, _, _, _, _)
+			Node = call(_, _, _, _, _, _, _, _, _, _)
 		; 
 			%
 			% A non-failed NEGE could be encountered when gathering
@@ -448,14 +449,14 @@
 		throw(internal_error("contour_children_2",
 			"unexpected start of contour"))
 	;
-		Node = exit(_, _, _, _, _, _)
+		Node = exit(_, _, _, _, _, _, _)
 	->
 			%
 			% Add a child for this node.
 			%
 		Ns1 = [dynamic(NodeId) | Ns0]
 	;
-		Node = fail(_, CallId, _, _)
+		Node = fail(_, CallId, _, _, _)
 	->
 			%
 			% Fail events can be reached here if there
@@ -477,7 +478,7 @@
 		NestedStartId = Call ^ call_preceding,
 		stratum_children(Store, NodeId, NestedStartId, Ns0, Ns1)
 	;
-		Node = neg_fail(Prec, NestedStartId)
+		Node = neg_fail(Prec, NestedStartId, _)
 	->
 			%
 			% There is a nested context.  Neg_fail events can be
@@ -489,8 +490,8 @@
 		contour_children(ContourType, Store, Prec, 
 			NestedStartId, Ns0, Ns1)
 	;
-		( Node = else(Prec, NestedStartId)
-		; Node = neg_succ(Prec, NestedStartId)
+		( Node = else(Prec, NestedStartId, _)
+		; Node = neg_succ(Prec, NestedStartId, _)
 		)
 	->
 			%
@@ -498,7 +499,7 @@
 			%
 		stratum_children(Store, Prec, NestedStartId, Ns0, Ns1)
 	; 
-		Node = excp(_, CallId, _, _, _)
+		Node = excp(_, CallId, _, _, _, _)
 	->
 			%
 			% If the contour ends in an exception, then add this
@@ -560,7 +561,7 @@
 stratum_children_2(Store, NodeId, StartId, Ns0, Ns) :-
 	det_trace_node_from_id(Store, NodeId, Node),
 	(
-		( Node = call(_, _, _, _, _, _, _, _, _)
+		( Node = call(_, _, _, _, _, _, _, _, _, _)
 		; Node = neg(_, _, _)
 		; Node = cond(_, _, failed)
 		)
@@ -568,9 +569,9 @@
 		throw(internal_error("stratum_children_2",
 			"unexpected start of contour"))
 	;
-		( Node = exit(_, _, _, _, _, _)
-		; Node = fail(_, _, _, _)
-		; Node = excp(_, _, _, _, _)
+		( Node = exit(_, _, _, _, _, _, _)
+		; Node = fail(_, _, _, _, _)
+		; Node = excp(_, _, _, _, _, _)
 		)
 	->
 			%
@@ -578,15 +579,15 @@
 			%
 		Ns1 = [dynamic(NodeId) | Ns0]
 	;
-		Node = neg_fail(Prec, NestedStartId)
+		Node = neg_fail(Prec, NestedStartId, _)
 	->
 			%
 			% There is a nested successful context.
 			%
 		contour_children(normal, Store, Prec, NestedStartId, Ns0, Ns1)
 	;
-		( Node = else(Prec, NestedStartId)
-		; Node = neg_succ(Prec, NestedStartId)
+		( Node = else(Prec, NestedStartId, _)
+		; Node = neg_succ(Prec, NestedStartId, _)
 		)
 	->
 			%
@@ -765,9 +766,10 @@
 find_chain_start(Store, Ref, ArgPos, TermPath, ChainStart) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = exit(_, CallId, _, ExitAtom, _, _),
+		Node = exit(_, CallId, _, _, _, _, _),
+		ExitAtom = get_trace_exit_atom(Node),
 		call_node_from_id(Store, CallId, CallNode),
-		CallAtom = CallNode ^ call_atom,
+		CallAtom = get_trace_call_atom(CallNode),
 		( trace_atom_subterm_is_ground(CallAtom, ArgPos, TermPath) ->
 			find_chain_start_inside(Store, CallId, CallNode,
 				ArgPos, ChainStart)
@@ -779,9 +781,9 @@
 				"unbound wrong answer term"))
 		)
 	;
-		Node = fail(_, CallId, _, _),
+		Node = fail(_, CallId, _, _, _),
 		call_node_from_id(Store, CallId, CallNode),
-		CallAtom = CallNode ^ call_atom,
+		CallAtom = get_trace_call_atom(CallNode),
 		( trace_atom_subterm_is_ground(CallAtom, ArgPos, TermPath) ->
 			find_chain_start_inside(Store, CallId, CallNode,
 				ArgPos, ChainStart)
@@ -790,9 +792,9 @@
 				"unbound missing answer term"))
 		)
 	;
-		Node = excp(_, CallId, _, _, _),
+		Node = excp(_, CallId, _, _, _, _),
 		call_node_from_id(Store, CallId, CallNode),
-		CallAtom = CallNode ^ call_atom,
+		CallAtom = get_trace_call_atom(CallNode),
 		%
 		% XXX we don't yet handle tracking of the exception value.
 		%
@@ -811,7 +813,7 @@
 
 find_chain_start_inside(Store, CallId, CallNode, ArgPos, ChainStart) :-
 	CallPrecId = CallNode ^ call_preceding,
-	CallAtom = CallNode ^ call_atom,
+	CallAtom = get_trace_call_atom(CallNode),
 	CallPathStr = CallNode ^ call_goal_path,
 	path_from_string_det(CallPathStr, CallPath),
 	StartLoc = parent_goal(CallId, CallNode),
@@ -829,7 +831,7 @@
 
 find_chain_start_outside(CallNode, ExitNode, ArgPos, ChainStart) :-
 	StartLoc = cur_goal,
-	ExitAtom = ExitNode ^ exit_atom,
+	ExitAtom = get_trace_exit_atom(ExitNode),
 	absolute_arg_num(ArgPos, ExitAtom, ArgNum),
 	TotalArgs = length(ExitAtom ^ atom_args),
 	StartId = ExitNode ^ exit_preceding,
@@ -862,7 +864,7 @@
 
 step_left_to_call(Store, NodeId, ParentCallNode) :-
 	trace_node_from_id(Store, NodeId, Node),
-	( Node = call(_, _, _, _, _, _, _, _, _) ->
+	( Node = call(_, _, _, _, _, _, _, _, _, _) ->
 		ParentCallNode = Node
 	;
 		%
@@ -890,7 +892,7 @@
 	is det <= annotated_trace(S, R).
 
 materialize_contour(Store, NodeId, Node, Nodes0, Nodes) :-
-	( Node = call(_, _, _, _, _, _, _, _, _) ->
+	( Node = call(_, _, _, _, _, _, _, _, _, _) ->
 		
 		Nodes = Nodes0
 	;
@@ -911,7 +913,7 @@
 			PrevNodeId = step_left_in_contour(Store, Node)
 		),
 		det_trace_node_from_id(Store, PrevNodeId, PrevNode),
-		( Node = then(_, _) ->
+		( Node = then(_, _, _) ->
 			% The cond node is enough to tell us which way the
 			% if-then-else went; the then node would just
 			% complicate the job of make_primitive_list.
@@ -937,7 +939,7 @@
 	final_decl_atom::out) is semidet <= annotated_trace(S, R).
 
 get_exit_atom(IoActionMap, Store, _ - Exit, FinalAtom) :-
-	Exit = exit(_, _, _, _, _, _),
+	Exit = exit(_, _, _, _, _, _, _),
 	FinalAtom = exit_node_decl_atom(IoActionMap, Store, Exit).
 
 :- type primitive_list_and_var(R)
@@ -1036,7 +1038,8 @@
 :- pred contour_at_end_path(assoc_list(R, trace_node(R))::in, 
 	maybe(goal_path)::in) is semidet.
 
-contour_at_end_path([_ - call(_,_,_,_,_,_,_, CallPathStr, _)], yes(EndPath)) :-
+contour_at_end_path([_ - call(_, _, _, _, _, _, _, CallPathStr, _, _)], 
+		yes(EndPath)) :-
 	path_from_string_det(CallPathStr, CallPath),
 	CallPath = EndPath.
 
@@ -1103,10 +1106,11 @@
 		(
 			Contour = [_ - ContourHeadNode | ContourTail],
 			( 
-				ContourHeadNode = first_disj(_, DisjPathStr)
+				ContourHeadNode = first_disj(_, Label)
 			; 
-				ContourHeadNode = later_disj(_, DisjPathStr, _)
+				ContourHeadNode = later_disj(_, Label, _)
 			),
+			DisjPathStr = get_goal_path_from_label_layout(Label),
 			path_from_string_det(DisjPathStr, DisjPath),
 			list.append(Path, PathTail, DisjPath),
 			PathTail = [disj(N)]
@@ -1124,7 +1128,8 @@
 		Goal = switch_rep(Arms),
 		(
 			Contour = [_ - ContourHeadNode | ContourTail],
-			ContourHeadNode = switch(_, ArmPathStr),
+			ContourHeadNode = switch(_, Label),
+			ArmPathStr = get_goal_path_from_label_layout(Label),
 			path_from_string_det(ArmPathStr, ArmPath),
 			list.append(Path, PathTail, ArmPath),
 			PathTail = [switch(N)]
@@ -1142,7 +1147,8 @@
 		Goal = ite_rep(Cond, Then, Else),
 		(
 			Contour = [_ - ContourHeadNode | ContourTail],
-			ContourHeadNode = cond(_, CondPathStr, _),
+			ContourHeadNode = cond(_, Label, _),
+			CondPathStr = get_goal_path_from_label_layout(Label),
 			path_from_string_det(CondPathStr, CondPath),
 			list.append(Path, PathTail, CondPath),
 			PathTail = [ite_cond]
@@ -1156,9 +1162,10 @@
 				AllTraced, Primitives0)
 		;
 			Contour = [_ - ContourHeadNode | ContourTail],
-			ContourHeadNode = else(_, ElseCondId),
+			ContourHeadNode = else(_, ElseCondId, _),
 			cond_node_from_id(Store, ElseCondId, CondNode),
-			CondNode = cond(_, CondPathStr, _),
+			CondNode = cond(_, Label, _),
+			CondPathStr = get_goal_path_from_label_layout(Label),
 			path_from_string_det(CondPathStr, CondPath),
 			list.append(Path, PathTail, CondPath),
 			PathTail = [ite_cond]
@@ -1176,7 +1183,7 @@
 		Goal = negation_rep(NegGoal),
 		(
 			Contour = [_ - ContourHeadNode | ContourTail],
-			ContourHeadNode = neg_succ(_, _)
+			ContourHeadNode = neg_succ(_, _, _)
 		->
 			% The negated goal cannot contribute any bindings.
 			MaybePrims = make_primitive_list(Store, GoalPaths, 
@@ -1208,9 +1215,9 @@
 	Contour0 = [_ - ContourHeadNode | ContourTail],
 	(
 		(
-			ContourHeadNode = exit(_, _, _, _, _, _)
+			ContourHeadNode = exit(_, _, _, _, _, _, _)
 		;
-			ContourHeadNode = fail(_, _, _, _)
+			ContourHeadNode = fail(_, _, _, _, _)
 		)
 	->
 		remove_leading_exit_fail_events(ContourTail, 
@@ -1245,8 +1252,9 @@
 		MaybeEnd = yes(EndPath)
 	->
 		(
-			ContourHeadNode = 
-				call(_, _, Atom, _, _, _, _, CallPathStr, _),
+			ContourHeadNode = call(_, _, _, _, _, _, _, 
+				CallPathStr, _, _),
+			Atom = get_trace_call_atom(ContourHeadNode),
 			path_from_string_det(CallPathStr, CallPath),
 			CallPath = EndPath
 		->
@@ -1323,7 +1331,7 @@
 			Contour = [ContourHeadId - ContourHeadNode |
 				ContourTail],
 			(
-				ContourHeadNode = exit(_, _, _, Atom, _, _)
+				Atom = get_trace_exit_atom(ContourHeadNode)
 			->
 				(
 					(
@@ -1612,20 +1620,20 @@
 edt_subtree_details(Store, dynamic(Ref), Event, SeqNo, CallPreceding) :-
 	det_edt_return_node_from_id(Store, Ref, Node),
 	(
-		Node = exit(_, Call, _, _, Event, _)
+		Node = exit(_, Call, _, _, Event, _, _)
 	;
-		Node = fail(_, Call, _, Event)
+		Node = fail(_, Call, _, Event, _)
 	;
-		Node = excp(_, Call, _, _, Event)
+		Node = excp(_, Call, _, _, Event, _)
 	),
 	call_node_from_id(Store, Call, CallNode),
 	SeqNo = CallNode ^ call_seq,
 	CallPreceding = CallNode ^ call_preceding.
 
-:- inst edt_return_node
-	--->	exit(ground, ground, ground, ground, ground, ground)
-	;	fail(ground, ground, ground, ground)
-	;	excp(ground, ground, ground, ground, ground).
+:- inst edt_return_node 
+	--->	exit(ground, ground, ground, ground, ground, ground, ground)
+	;	fail(ground, ground, ground, ground, ground)
+	;	excp(ground, ground, ground, ground, ground, ground).
 
 :- pred det_edt_return_node_from_id(S::in, R::in,
 	trace_node(R)::out(edt_return_node)) is det <= annotated_trace(S, R).
@@ -1634,11 +1642,11 @@
 	(
 		trace_node_from_id(Store, Ref, Node0),
 		(
-			Node0 = exit(_, _, _, _, _, _)
+			Node0 = exit(_, _, _, _, _, _, _)
 		;
-			Node0 = fail(_, _, _, _)
+			Node0 = fail(_, _, _, _, _)
 		;
-			Node0 = excp(_, _, _, _, _)
+			Node0 = excp(_, _, _, _, _, _)
 		)
 	->
 		Node = Node0
@@ -1654,11 +1662,11 @@
 	(
 		trace_node_from_id(Store, Ref, Node0),
 		(
-			Node0 = exit(_, CallId0, _, _, _, _)
+			Node0 = exit(_, CallId0, _, _, _, _, _)
 		;
-			Node0 = fail(_, CallId0, _, _)
+			Node0 = fail(_, CallId0, _, _, _)
 		;
-			Node0 = excp(_, CallId0, _, _, _)
+			Node0 = excp(_, CallId0, _, _, _, _)
 		)
 	->
 		CallId = CallId0
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.79
diff -u -r1.79 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c	27 Jan 2005 06:17:40 -0000	1.79
+++ trace/mercury_trace_declarative.c	19 Feb 2005 09:16:16 -0000
@@ -247,7 +247,7 @@
 static	MR_bool		MR_trace_same_construct(const char *p1,
 				const char *p2);
 static	MR_bool		MR_trace_single_component(const char *path);
-static	MR_Word		MR_decl_make_atom(const MR_Label_Layout *layout,
+static	MR_Word		MR_decl_make_atom_args(const MR_Label_Layout *layout,
 				MR_Word *saved_regs, MR_Trace_Port port);
 static	MR_Word		MR_decl_atom_args(const MR_Label_Layout *layout,
 				MR_Word *saved_regs);
@@ -554,7 +554,7 @@
 MR_trace_decl_call(MR_Event_Info *event_info, MR_Trace_Node prev)
 {
 	MR_Trace_Node			node;
-	MR_Word				atom;
+	MR_Word				atom_args;
 	MR_bool				at_depth_limit;
 	const MR_Label_Layout		*event_label_layout;
 	const MR_Proc_Layout		*event_proc_layout;
@@ -575,8 +575,8 @@
 	event_label_layout = event_info->MR_event_sll;
 	event_proc_layout = event_label_layout->MR_sll_entry;
 	proc_rep = (MR_Word) event_proc_layout->MR_sle_proc_rep;
-	atom = MR_decl_make_atom(event_label_layout, event_info->MR_saved_regs,
-			MR_PORT_CALL);
+	atom_args = MR_decl_make_atom_args(event_label_layout, 
+		event_info->MR_saved_regs, MR_PORT_CALL);
 	base_sp = MR_saved_sp(event_info->MR_saved_regs);
 	base_curfr = MR_saved_curfr(event_info->MR_saved_regs);
 	result = MR_stack_walk_step(event_proc_layout, &return_label_layout,
@@ -602,17 +602,20 @@
 		if (proc_rep) {
 			node = (MR_Trace_Node)
 				MR_DD_construct_call_node_with_goal(
-					(MR_Word) prev, atom,
+					(MR_Word) prev, atom_args,
 					(MR_Word) event_info->MR_call_seqno,
 					(MR_Word) event_info->MR_event_number,
 					(MR_Word) at_depth_limit, proc_rep,
-					goal_path, MR_io_tabling_counter);
+					goal_path, event_label_layout, 
+					MR_io_tabling_counter);
 		} else {
 			node = (MR_Trace_Node)
-				MR_DD_construct_call_node((MR_Word) prev, atom,
+				MR_DD_construct_call_node((MR_Word) prev, 
+					atom_args,
 					(MR_Word) event_info->MR_call_seqno,
 					(MR_Word) event_info->MR_event_number,
 					(MR_Word) at_depth_limit, goal_path,
+					event_label_layout,
 					MR_io_tabling_counter);
 		}
 	);
@@ -626,9 +629,9 @@
 	MR_Trace_Node		node;
 	MR_Trace_Node		call;
 	MR_Word			last_interface;
-	MR_Word			atom;
+	MR_Word			atom_args;
 
-	atom = MR_decl_make_atom(event_info->MR_event_sll,
+	atom_args = MR_decl_make_atom_args(event_info->MR_event_sll,
 				event_info->MR_saved_regs,
 				MR_PORT_EXIT);
 
@@ -639,7 +642,9 @@
 				(MR_Word) call);
 		node = (MR_Trace_Node) MR_DD_construct_exit_node(
 				(MR_Word) prev, (MR_Word) call, last_interface,
-				atom, (MR_Word) event_info->MR_event_number,
+				atom_args, 
+				(MR_Word) event_info->MR_event_number,
+				event_info->MR_event_sll,
 				MR_io_tabling_counter);
 		MR_DD_call_node_set_last_interface((MR_Word) call,
 				(MR_Word) node);
@@ -682,7 +687,8 @@
 		node = (MR_Trace_Node) MR_DD_construct_redo_node(
 					(MR_Word) prev,
 					last_interface,
-					(MR_Word) event_info->MR_event_number);
+					(MR_Word) event_info->MR_event_number,
+					event_info->MR_event_sll);
 		MR_DD_call_node_set_last_interface((MR_Word) call,
 					(MR_Word) node);
 	);
@@ -715,7 +721,8 @@
 		node = (MR_Trace_Node) MR_DD_construct_fail_node(
 					(MR_Word) prev, (MR_Word) call,
 					(MR_Word) redo,
-					(MR_Word) event_info->MR_event_number);
+					(MR_Word) event_info->MR_event_number,
+					event_info->MR_event_sll);
 		MR_DD_call_node_set_last_interface((MR_Word) call,
 					(MR_Word) node);
 	);
@@ -738,7 +745,8 @@
 		MR_DD_construct_excp_node(
 				(MR_Word) prev, (MR_Word) call, last_interface,
 				MR_trace_get_exception_value(),
-				(MR_Word) event_info->MR_event_number, &node);
+				(MR_Word) event_info->MR_event_number, 
+				event_info->MR_event_sll, &node);
 		MR_DD_call_node_set_last_interface(
 				(MR_Word) call, (MR_Word) node);
 	);
@@ -754,7 +762,7 @@
 	MR_TRACE_CALL_MERCURY(
 		node = (MR_Trace_Node) MR_DD_construct_cond_node(
 					(MR_Word) prev,
-					(MR_String) event_info->MR_event_path);
+					event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -783,7 +791,8 @@
 					MR_TRACE_STATUS_SUCCEEDED);
 		node = (MR_Trace_Node) MR_DD_construct_then_node(
 					(MR_Word) prev,
-					(MR_Word) cond);
+					(MR_Word) cond,
+					event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -820,7 +829,8 @@
 					MR_TRACE_STATUS_FAILED);
 		node = (MR_Trace_Node) MR_DD_construct_else_node(
 					(MR_Word) prev,
-					(MR_Word) cond);
+					(MR_Word) cond,
+					event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -833,7 +843,7 @@
 	MR_TRACE_CALL_MERCURY(
 		node = (MR_Trace_Node) MR_DD_construct_neg_node(
 					(MR_Word) prev,
-					(MR_String) event_info->MR_event_path);
+					event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -870,7 +880,8 @@
 					MR_TRACE_STATUS_SUCCEEDED);
 		node = (MR_Trace_Node) MR_DD_construct_neg_succ_node(
 						(MR_Word) prev,
-						(MR_Word) nege);
+						(MR_Word) nege,
+						event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -896,7 +907,8 @@
 					MR_TRACE_STATUS_FAILED);
 		node = (MR_Trace_Node) MR_DD_construct_neg_fail_node(
 						(MR_Word) prev,
-						(MR_Word) next);
+						(MR_Word) next,
+						event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -909,7 +921,7 @@
 	MR_TRACE_CALL_MERCURY(
 		node = (MR_Trace_Node) MR_DD_construct_switch_node(
 					(MR_Word) prev,
-					(MR_String) event_info->MR_event_path);
+					event_info->MR_event_sll);
 	);
 	return node;
 }
@@ -925,7 +937,7 @@
 		MR_TRACE_CALL_MERCURY(
 			node = (MR_Trace_Node) MR_DD_construct_first_disj_node(
 					(MR_Word) prev,
-					(MR_String) path);
+					event_info->MR_event_sll);
 		);
 	}
 	else
@@ -956,7 +968,7 @@
 			node = (MR_Trace_Node) MR_DD_construct_later_disj_node(
 						MR_trace_node_store,
 						(MR_Word) prev,
-						(MR_String) path,
+						event_info->MR_event_sll,
 						(MR_Word) first);
 		);
 	}
@@ -1097,12 +1109,12 @@
 }
 
 static	MR_Word
-MR_decl_make_atom(const MR_Label_Layout *layout, MR_Word *saved_regs,
+MR_decl_make_atom_args(const MR_Label_Layout *layout, MR_Word *saved_regs,
 		MR_Trace_Port port)
 {
 	MR_PredFunc			pred_or_func;
 	int				arity;
-	MR_Word				atom;
+	MR_Word				atom_args;
 	int				hv;   /* any head variable */
 	int				num_added_args;
 	MR_TypeInfoParams		type_params;
@@ -1113,11 +1125,10 @@
 		&pred_or_func);
 
 	MR_TRACE_CALL_MERCURY(
-		atom = MR_DD_construct_trace_atom(entry, 
-			(MR_Integer) entry->MR_sle_num_head_vars);
+		atom_args = MR_DD_init_trace_atom_args();
 	);
 
-	for (hv = 0; hv < entry->MR_sle_num_head_vars; hv++) {
+	for (hv = entry->MR_sle_num_head_vars - 1; hv >= 0; hv--) {
 		int		hlds_num;
 		MR_Word		arg;
 		MR_TypeInfo	arg_type;
@@ -1135,9 +1146,9 @@
 		if (problem != NULL) {
 			/* this head variable is not live at this port */
 			MR_TRACE_CALL_MERCURY(
-				atom = MR_DD_add_trace_atom_arg_no_value(atom,
-					(MR_Word) hv + 1, hlds_num,
-					is_prog_visible_headvar);
+				MR_DD_add_trace_atom_arg_no_value(hlds_num,
+					is_prog_visible_headvar, atom_args, 
+					&atom_args);
 			);
 		} else {
 			MR_TRACE_USE_HP(
@@ -1145,15 +1156,14 @@
 			);
 
 			MR_TRACE_CALL_MERCURY(
-				MR_DD_add_trace_atom_arg_value(
-					(MR_Word) hv + 1, hlds_num,
-					is_prog_visible_headvar, arg, atom,
-					&atom);
+				MR_DD_add_trace_atom_arg_value( hlds_num,
+					is_prog_visible_headvar, arg,
+					atom_args, &atom_args);
 			);
 		}
 	}
 
-	return atom;
+	return atom_args;
 }
 
 static	void
@@ -1718,8 +1728,7 @@
 
 	MR_trace_node_store++;
 	MR_TRACE_CALL_MERCURY(
-		path = MR_DD_trace_node_path(MR_trace_node_store,
-				(MR_Word) node);
+		path = MR_DD_trace_node_path((MR_Word) node);
 	);
 	return path;
 }
--------------------------------------------------------------------------
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