[m-dev.] for review: fix for failing DD test cases
Mark Anthony BROWN
dougl at cs.mu.OZ.AU
Thu Feb 17 18:59:55 AEDT 2000
Hi,
This fixes a bug mentioned by Fergus last weekend. All tests that
I have tried now pass; I am still awaiting the outcome of tests
in debug grade, so there may also be minor modifications to event
numbers in the appropriate *.exp2 files, which are not included
in this diff.
This is for review by Fergus.
Cheers,
Mark.
Estimated hours taken: 1 (plus 0.2 by fjh)
Fix the problem of test cases failing in tests/debugger/declarative
on the alphas.
browser/declarative_execution.m:
Add Mercury procedures to do destructive update on trace nodes.
trace/mercury_trace_declarative.h:
Remove C macros that did the destructive update.
trace/mercury_trace_declarative.c:
Use the Mercury procedures rather than the old macros.
Index: browser/declarative_execution.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_execution.m,v
retrieving revision 1.3
diff -u -r1.3 declarative_execution.m
--- browser/declarative_execution.m 2000/02/17 06:47:19 1.3
+++ browser/declarative_execution.m 2000/02/17 06:49:09
@@ -23,9 +23,9 @@
% The type R is the type of references to other nodes
% in the store.
%
- % If this type is modified, some of the macros in
- % trace/mercury_trace_declarative.h may also need to be
- % updated.
+ % If this type is modified, the procedures below which
+ % do destructive update on values of this type may also
+ % need to be modified.
%
:- type trace_node(R)
---> call(
@@ -213,7 +213,7 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module map, require.
+:- import_module map, require, store.
det_trace_node_from_id(Store, NodeId, Node) :-
(
@@ -333,6 +333,88 @@
% Following are some predicates that are useful for
% manipulating the above instance in C code.
%
+
+:- func call_node_get_last_interface(trace_node(trace_node_id))
+ = trace_node_id.
+:- pragma export(call_node_get_last_interface(in) = out,
+ "MR_DD_call_node_get_last_interface").
+
+call_node_get_last_interface(Call) = Last :-
+ (
+ Call = call(_, Last0, _, _)
+ ->
+ Last = Last0
+ ;
+ error("call_node_get_last_interface: not a CALL node")
+ ).
+
+:- func call_node_set_last_interface(trace_node(trace_node_id), trace_node_id)
+ = trace_node(trace_node_id).
+:- mode call_node_set_last_interface(di, di) = out is det.
+:- pragma export(call_node_set_last_interface(di, di) = out,
+ "MR_DD_call_node_set_last_interface").
+
+call_node_set_last_interface(Call0, Last) = Call :-
+ (
+ Call0 = call(_, _, _, _)
+ ->
+ Call1 = Call0
+ ;
+ error("call_node_set_last_interface: not a CALL node")
+ ),
+ % The last interface is the second field, so we pass 1
+ % (since argument numbers start from 0).
+ %
+ set_trace_node_arg(Call1, 1, Last, Call).
+
+:- func cond_node_set_status(trace_node(trace_node_id), goal_status)
+ = trace_node(trace_node_id).
+:- mode cond_node_set_status(di, di) = out is det.
+:- pragma export(cond_node_set_status(di, di) = out,
+ "MR_DD_cond_node_set_status").
+
+cond_node_set_status(Cond0, Status) = Cond :-
+ (
+ Cond0 = cond(_, _, _)
+ ->
+ Cond1 = Cond0
+ ;
+ error("cond_node_set_status: not a COND node")
+ ),
+ % The goal status is the third field, so we pass 2
+ % (since argument numbers start from 0).
+ %
+ set_trace_node_arg(Cond1, 2, Status, Cond).
+
+:- func neg_node_set_status(trace_node(trace_node_id), goal_status)
+ = trace_node(trace_node_id).
+:- mode neg_node_set_status(di, di) = out is det.
+:- pragma export(neg_node_set_status(di, di) = out,
+ "MR_DD_neg_node_set_status").
+
+neg_node_set_status(Neg0, Status) = Neg :-
+ (
+ Neg0 = neg(_, _, _)
+ ->
+ Neg1 = Neg0
+ ;
+ error("neg_node_set_status: not a NEGE node")
+ ),
+ % The goal status is the third field, so we pass 2
+ % (since argument numbers start from 0).
+ %
+ set_trace_node_arg(Neg1, 2, Status, Neg).
+
+:- pred set_trace_node_arg(trace_node(trace_node_id), int, T,
+ trace_node(trace_node_id)).
+:- mode set_trace_node_arg(di, in, di, out) is det.
+
+set_trace_node_arg(Node0, FieldNum, Val, Node) :-
+ store__init(S0),
+ store__new_ref(Node0, Ref, S0, S1),
+ store__arg_ref(Ref, FieldNum, ArgRef, S1, S2),
+ store__set_ref_value(ArgRef, Val, S2, S),
+ store__extract_ref_value(S, Ref, Node).
:- func trace_node_port(trace_node(trace_node_id)) = trace_port_type.
:- pragma export(trace_node_port(in) = out,
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.16
diff -u -r1.16 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c 2000/02/17 06:48:17 1.16
+++ trace/mercury_trace_declarative.c 2000/02/17 07:00:33
@@ -396,6 +396,7 @@
{
MR_Trace_Node node;
MR_Trace_Node call;
+ Word last_interface;
Word atom;
atom = MR_decl_make_atom(event_info->MR_event_sll,
@@ -410,12 +411,13 @@
#endif
MR_TRACE_CALL_MERCURY(
+ last_interface = MR_DD_call_node_get_last_interface(
+ (Word) call);
node = (MR_Trace_Node) MR_DD_construct_exit_node(
(Word) prev, (Word) call,
- MR_trace_call_node_last_interface(call),
- atom);
+ last_interface, atom);
+ MR_DD_call_node_set_last_interface((Word) call, (Word) node);
);
- MR_trace_call_node_last_interface(call) = (Word) node;
return node;
}
@@ -426,6 +428,7 @@
MR_Trace_Node node;
MR_Trace_Node call;
MR_Trace_Node next;
+ Word last_interface;
#ifdef MR_USE_DECL_STACK_SLOT
call = MR_trace_decl_get_slot(event_info->MR_event_sll->MR_sll_entry,
@@ -453,11 +456,13 @@
#endif /* !MR_USE_DECL_STACK_SLOT */
MR_TRACE_CALL_MERCURY(
+ last_interface = MR_DD_call_node_get_last_interface(
+ (Word) call);
node = (MR_Trace_Node) MR_DD_construct_redo_node(
(Word) prev,
- MR_trace_call_node_last_interface(call));
+ last_interface);
+ MR_DD_call_node_set_last_interface((Word) call, (Word) node);
);
- MR_trace_call_node_last_interface(call) = (Word) node;
return node;
}
@@ -468,7 +473,7 @@
MR_Trace_Node node;
MR_Trace_Node next;
MR_Trace_Node call;
- MR_Trace_Node redo;
+ Word redo;
#ifdef MR_USE_DECL_STACK_SLOT
call = MR_trace_decl_get_slot(event_info->MR_event_sll->MR_sll_entry,
@@ -490,15 +495,14 @@
MR_decl_checkpoint_match(call);
#endif
- redo = MR_trace_call_node_last_interface(call);
MR_TRACE_CALL_MERCURY(
+ redo = MR_DD_call_node_get_last_interface( (Word) call);
node = (MR_Trace_Node) MR_DD_construct_fail_node(
(Word) prev,
(Word) call,
(Word) redo);
+ MR_DD_call_node_set_last_interface((Word) call, (Word) node);
);
-
- MR_trace_call_node_last_interface(call) = (Word) node;
return node;
}
@@ -534,9 +538,9 @@
cond = next;
MR_decl_checkpoint_match(cond);
- MR_trace_cond_node_status(cond) = MR_TRACE_STATUS_SUCCEEDED;
-
MR_TRACE_CALL_MERCURY(
+ MR_DD_cond_node_set_status((Word) cond,
+ MR_TRACE_STATUS_SUCCEEDED);
node = (MR_Trace_Node) MR_DD_construct_then_node(
(Word) prev,
(Word) cond);
@@ -571,8 +575,9 @@
}
MR_decl_checkpoint_match(cond);
- MR_trace_cond_node_status(cond) = MR_TRACE_STATUS_FAILED;
MR_TRACE_CALL_MERCURY(
+ MR_DD_cond_node_set_status((Word) cond,
+ MR_TRACE_STATUS_FAILED);
node = (MR_Trace_Node) MR_DD_construct_else_node(
(Word) prev,
(Word) cond);
@@ -620,8 +625,9 @@
}
MR_decl_checkpoint_match(nege);
- MR_trace_neg_node_status(nege) = MR_TRACE_STATUS_SUCCEEDED;
MR_TRACE_CALL_MERCURY(
+ MR_DD_neg_node_set_status((Word) nege,
+ MR_TRACE_STATUS_SUCCEEDED);
node = (MR_Trace_Node) MR_DD_construct_neg_succ_node(
(Word) prev,
(Word) nege);
@@ -645,8 +651,9 @@
}
MR_decl_checkpoint_match(next);
- MR_trace_neg_node_status(next) = MR_TRACE_STATUS_FAILED;
MR_TRACE_CALL_MERCURY(
+ MR_DD_neg_node_set_status((Word) next,
+ MR_TRACE_STATUS_FAILED);
node = (MR_Trace_Node) MR_DD_construct_neg_fail_node(
(Word) prev,
(Word) next);
Index: trace/mercury_trace_declarative.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.h,v
retrieving revision 1.7
diff -u -r1.7 mercury_trace_declarative.h
--- trace/mercury_trace_declarative.h 2000/02/17 06:48:18 1.7
+++ trace/mercury_trace_declarative.h 2000/02/17 06:53:16
@@ -37,15 +37,6 @@
typedef Word MR_Trace_Node;
-#define MR_trace_call_node_last_interface(node) \
- MR_field(MR_mktag(0), (node), (Integer) 1)
-
-#define MR_trace_cond_node_status(node) \
- MR_field(MR_mktag(3), (node), (Integer) 3)
-
-#define MR_trace_neg_node_status(node) \
- MR_field(MR_mktag(3), (node), (Integer) 3)
-
#define MR_TRACE_STATUS_SUCCEEDED (Word) 0
#define MR_TRACE_STATUS_FAILED (Word) 1
#define MR_TRACE_STATUS_UNDECIDED (Word) 2
--
Mark Brown, PhD student )O+ | "Another of Fortran's breakthroughs
(m.brown at cs.mu.oz.au) | was the GOTO statement, which was...
Dept. of Computer Science and Software | uniquely simple and understandable"
Engineering, University of Melbourne | -- IEEE, 1994
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list