[m-rev.] for review: fix the debugger's handling of unify/compare/index preds
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Mar 31 21:17:12 AEST 2003
For review by anyone.
Zoltan.
Fix two bugs in the printing of goals where the predicate concerned is an
compiler-generated unify, compare or index predicate. Improve the mechanisms
for debugging bugs like this.
runtime/mercury_layout_util.[ch]:
Fix bug one: do not return the arity of a type constructor as
the arity of the unify, compare or index predicate of that
type constructor; return the actual arity. When the falsely
returned arity was greater than the actual arity, we could get
core dumps; when it was smaller, the mdb command "print goal"
printed wrong output.
Provide a mechanism for fixing bug two: add a utility function
for computing *correctly* a procedure's original arity and the number
of type_info and/or typeclass_info arguments added by the compiler.
(For convenience, it also returns a predicate/function indication.)
runtime/mercury_stack_layout.h:
Rename the MR_comp_arity field of MR_Compiler_Proc_Id to
MR_comp_type_arity, to make clear that it gives the arity of the type
constructor, not the arity of the predicate, and thus avoid bugs such
as those above.
runtime/mercury_stack_trace.c:
Use the new name of the MR_comp_type_arity field.
trace/mercury_trace_declarative.c:
trace/mercury_trace_vars.c:
Call the new, correct utility function in runtime/mercury_layout_util
to compute how many typeinfo and/or typeclassinfo arguments are added
by the compiler to a unify, compare, or index procedure's arguments,
instead of the different, but logically equivalent and equally wrong
pieces of code here.
trace/mercury_trace_external.c:
Use the new name of the MR_comp_type_arity field. Leave an XXX, since
I am not sure whether Morphine interprets the arity as the arity of the
type constructor or as the arity of the predicate.
runtime/mercury_engine.[ch]:
runtime/mercury_layout_util.c:
Make the printing of locations obtained from RTTI data structures
switchable from mdb, to make problems like this easier to debug.
tests/debugger/uci.{m,inp,exp}:
A new test case to test the proper handling of unify, compare and index
predicates.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
Enable the new test case.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing gcc
cvs diff: Diffing gcc/mercury
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.41
diff -u -b -r1.41 mercury_engine.c
--- runtime/mercury_engine.c 18 Mar 2003 16:38:10 -0000 1.41
+++ runtime/mercury_engine.c 28 Mar 2003 07:45:19 -0000
@@ -55,6 +55,7 @@
{ "agc", MR_AGC_FLAG },
{ "ordreg", MR_ORDINARY_REG_FLAG },
{ "anyreg", MR_ANY_REG_FLAG },
+ { "printlocn", MR_PRINT_LOCN_FLAG },
{ "detail", MR_DETAILFLAG }
};
Index: runtime/mercury_engine.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.h,v
retrieving revision 1.29
diff -u -b -r1.29 mercury_engine.h
--- runtime/mercury_engine.h 18 Mar 2003 16:38:10 -0000 1.29
+++ runtime/mercury_engine.h 28 Mar 2003 07:45:02 -0000
@@ -60,8 +60,9 @@
#define MR_AGC_FLAG 14
#define MR_ORDINARY_REG_FLAG 15
#define MR_ANY_REG_FLAG 16
-#define MR_DETAILFLAG 17
-#define MR_MAXFLAG 18
+#define MR_PRINT_LOCN_FLAG 17
+#define MR_DETAILFLAG 18
+#define MR_MAXFLAG 19
/* MR_DETAILFLAG should be the last real flag */
/*
@@ -112,6 +113,9 @@
**
** MR_finaldebug controls whether we want to get diagnostics showing how
** execution reaches the end of the program.
+**
+** MR_printlocndebug controls whether we want to get diagnostics showing how
+** the runtime system looks up locations recorded in RTTI data structures.
*/
#define MR_progdebug MR_debugflag[MR_PROGFLAG]
@@ -131,6 +135,7 @@
#define MR_agc_debug MR_debugflag[MR_AGC_FLAG]
#define MR_ordregdebug MR_debugflag[MR_ORDINARY_REG_FLAG]
#define MR_anyregdebug MR_debugflag[MR_ANY_REG_FLAG]
+#define MR_printlocndebug MR_debugflag[MR_PRINT_LOCN_FLAG]
#define MR_detaildebug MR_debugflag[MR_DETAILFLAG]
typedef struct {
Index: runtime/mercury_layout_util.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_layout_util.c,v
retrieving revision 1.29
diff -u -b -r1.29 mercury_layout_util.c
--- runtime/mercury_layout_util.c 15 May 2002 11:24:15 -0000 1.29
+++ runtime/mercury_layout_util.c 29 Mar 2003 14:25:12 -0000
@@ -210,7 +210,7 @@
}
#ifdef MR_DEBUG_LVAL_REP
- #define MR_print_locn MR_TRUE
+ #define MR_print_locn MR_printlocndebug
#else
#define MR_print_locn MR_FALSE
#endif
@@ -714,8 +714,16 @@
if (MR_PROC_LAYOUT_COMPILER_GENERATED(proc_layout)) {
*proc_name_ptr = proc_layout->MR_sle_proc_id.
MR_proc_comp.MR_comp_pred_name;
- *arity_ptr = proc_layout->MR_sle_proc_id.
- MR_proc_comp.MR_comp_arity;
+ if (MR_streq(*proc_name_ptr, "__Unify__")) {
+ *arity_ptr = 2;
+ } else if (MR_streq(*proc_name_ptr, "__Compare__")) {
+ *arity_ptr = 3;
+ } else if (MR_streq(*proc_name_ptr, "__Index__")) {
+ *arity_ptr = 2;
+ } else {
+ MR_fatal_error("MR_generate_proc_name_from_layout: "
+ "bad MR_comp_pred_name");
+ }
*is_func_ptr = MR_BOOL_NO;
} else {
*proc_name_ptr = proc_layout->MR_sle_proc_id.
@@ -729,5 +737,27 @@
} else {
*is_func_ptr = MR_BOOL_NO;
}
+ }
+}
+
+void
+MR_proc_id_arity_addedargs_predfunc(const MR_Proc_Layout *proc, int *arity_ptr,
+ int *num_added_args_ptr, MR_PredFunc *pred_or_func_ptr)
+{
+ if (MR_PROC_LAYOUT_COMPILER_GENERATED(proc)) {
+ /*
+ ** MR_comp_type_arity is the arity of the type constructor.
+ ** Each argument of the type constructor adds a typeinfo
+ ** argument to the headvars for all predicates, unify, compare
+ ** and index. (The index predicate doesn't need these
+ ** typeinfos, but it has them anyway.)
+ */
+ *num_added_args_ptr = proc->MR_sle_comp.MR_comp_type_arity;
+ *arity_ptr = proc->MR_sle_num_head_vars - *num_added_args_ptr;
+ *pred_or_func_ptr = MR_PREDICATE;
+ } else {
+ *arity_ptr = proc->MR_sle_user.MR_user_arity;
+ *num_added_args_ptr = proc->MR_sle_num_head_vars - *arity_ptr;
+ *pred_or_func_ptr = proc->MR_sle_user.MR_user_pred_or_func;
}
}
Index: runtime/mercury_layout_util.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_layout_util.h,v
retrieving revision 1.20
diff -u -b -r1.20 mercury_layout_util.h
--- runtime/mercury_layout_util.h 15 May 2002 11:24:16 -0000 1.20
+++ runtime/mercury_layout_util.h 29 Mar 2003 03:45:04 -0000
@@ -163,4 +163,15 @@
*proc_layout, MR_ConstString *proc_name_ptr,
int *arity_ptr, MR_Word *is_func_ptr);
+/*
+** Return the user-visible arity of the procedure (including the return value
+** for functions), the number of typeinfo and/or typeclassinfo arguments added
+** by the compiler, and an indication whether the procedure is from a predicate
+** or a function.
+*/
+
+extern void MR_proc_id_arity_addedargs_predfunc(const MR_Proc_Layout *proc,
+ int *arity_ptr, int *num_added_args_ptr,
+ MR_PredFunc *pred_or_func_ptr);
+
#endif /* MERCURY_LAYOUT_UTIL_H */
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.67
diff -u -b -r1.67 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h 26 Feb 2003 08:03:53 -0000 1.67
+++ runtime/mercury_stack_layout.h 29 Mar 2003 03:45:44 -0000
@@ -563,7 +563,7 @@
MR_ConstString MR_comp_type_module;
MR_ConstString MR_comp_def_module;
MR_ConstString MR_comp_pred_name;
- MR_int_least16_t MR_comp_arity;
+ MR_int_least16_t MR_comp_type_arity;
MR_int_least16_t MR_comp_mode;
} MR_Compiler_Proc_Id;
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.53
diff -u -b -r1.53 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c 18 Mar 2003 16:38:11 -0000 1.53
+++ runtime/mercury_stack_trace.c 29 Mar 2003 14:16:22 -0000
@@ -1028,7 +1028,7 @@
entry->MR_sle_comp.MR_comp_pred_name,
entry->MR_sle_comp.MR_comp_type_module,
entry->MR_sle_comp.MR_comp_type_name,
- (long) entry->MR_sle_comp.MR_comp_arity,
+ (long) entry->MR_sle_comp.MR_comp_type_arity,
(long) entry->MR_sle_comp.MR_comp_mode);
if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mercury.options,v
retrieving revision 1.6
diff -u -b -r1.6 Mercury.options
--- tests/debugger/Mercury.options 4 Feb 2003 05:04:21 -0000 1.6
+++ tests/debugger/Mercury.options 31 Mar 2003 09:56:15 -0000
@@ -17,6 +17,12 @@
# differences from the expected output on the nondet_stack test case.
# The optimization level also affects stack frame sizes.
MCFLAGS-nondet_stack = -O2 --no-reclaim-heap-on-failure
+# We test the behavior of comparisons both with and without index predicates.
+# The --compare-specialization flag creates index predicates for type
+# constructors with three or more alternatives. The optimization level
+# is fixed to fix the event numbers in the input script; this is needed
+# because one cannot (yet) put breakpoints on unify, compare and index preds.
+MCFLAGS-uci = -O2 --compare-specialization 2
# We need to use shared libraries for interactive queries to work.
# The following is necessary for shared libraries to work on Linux.
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.94
diff -u -b -r1.94 Mmakefile
--- tests/debugger/Mmakefile 4 Feb 2003 05:04:21 -0000 1.94
+++ tests/debugger/Mmakefile 31 Mar 2003 07:30:31 -0000
@@ -36,7 +36,8 @@
print_table \
queens_rep \
resume_typeinfos \
- type_desc_test
+ type_desc_test \
+ uci
# This test is currently not useful.
# output_term_dep
@@ -374,6 +375,9 @@
type_desc_test.out: type_desc_test type_desc_test.inp
$(MDB_STD) ./type_desc_test < type_desc_test.inp \
> type_desc_test.out 2>&1
+
+uci.out: uci uci.inp
+ $(MDB) ./uci < uci.inp 2>&1 > uci.out 2>&1
# When WORKSPACE is set, use $(WORKSPACE)/tools/lmc to compile the query.
ifneq ($(origin WORKSPACE), undefined)
Index: tests/debugger/uci.exp
===================================================================
RCS file: tests/debugger/uci.exp
diff -N tests/debugger/uci.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci.exp 31 Mar 2003 07:31:55 -0000
@@ -0,0 +1,98 @@
+ 1: 1 1 CALL pred uci.main/2-0 (det) uci.m:17
+mdb> echo on
+Command echo enabled.
+mdb> context none
+Contexts will not be printed.
+mdb> register --quiet
+mdb> goto 16
+ 16: 8 3 CALL __Compare__ for uci.t1/1-0 (det)
+mdb> print goal
+__Compare__(_, b1(11), a1(1))
+mdb> goto 19
+ 19: 8 3 EXIT __Compare__ for uci.t1/1-0 (det)
+mdb> print goal
+__Compare__('>', b1(11), a1(1))
+mdb> goto 28
+ 28: 12 3 CALL __Compare__ for uci.t2/2-0 (det)
+mdb> print goal
+__Compare__(_, a2(1, 2), a2(1, 2))
+mdb> goto 35
+ 35: 12 3 EXIT __Compare__ for uci.t2/2-0 (det)
+mdb> print goal
+__Compare__('=', a2(1, 2), a2(1, 2))
+mdb> goto 44
+ 44: 16 3 CALL __Compare__ for uci.t3/3-0 (det)
+mdb> print goal
+__Compare__(_, b3(11, 12, 13), a3(1, 2, 3))
+mdb> goto 47
+ 47: 16 3 EXIT __Compare__ for uci.t3/3-0 (det)
+mdb> print goal
+__Compare__('>', b3(11, 12, 13), a3(1, 2, 3))
+mdb> goto 56
+ 56: 20 3 CALL __Compare__ for uci.t4/4-0 (det)
+mdb> print goal
+__Compare__(_, a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> goto 59
+ 59: 20 3 EXIT __Compare__ for uci.t4/4-0 (det)
+mdb> print goal
+__Compare__('<', a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> goto 76
+ 76: 27 3 CALL __Unify__ for uci.t1/1-0 (semidet)
+mdb> print goal
+__Unify__(a1(1), a1(1))
+mdb> goto 78
+ 78: 27 3 EXIT __Unify__ for uci.t1/1-0 (semidet)
+mdb> print goal
+__Unify__(a1(1), a1(1))
+mdb> goto 87
+ 87: 31 3 CALL __Unify__ for uci.t2/2-0 (semidet)
+mdb> print goal
+__Unify__(a2(1, 2), b2(11, 12))
+mdb> goto 89
+ 89: 31 3 FAIL __Unify__ for uci.t2/2-0 (semidet)
+mdb> print goal
+__Unify__(a2(1, 2), b2(11, 12))
+mdb> goto 98
+ 98: 35 3 CALL __Unify__ for uci.t3/3-0 (semidet)
+mdb> print goal
+__Unify__(b3(11, 12, 13), b3(11, 12, 13))
+mdb> goto 100
+ 100: 35 3 EXIT __Unify__ for uci.t3/3-0 (semidet)
+mdb> print goal
+__Unify__(b3(11, 12, 13), b3(11, 12, 13))
+mdb> goto 109
+ 109: 39 3 CALL __Unify__ for uci.t4/4-0 (semidet)
+mdb> print goal
+__Unify__(a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> goto 111
+ 111: 39 3 FAIL __Unify__ for uci.t4/4-0 (semidet)
+mdb> print goal
+__Unify__(a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> goto 121
+ 121: 44 4 CALL __Index__ for uci.i/3-0 (det)
+mdb> print goal
+__Index__(ai(1), _)
+mdb> goto 123
+ 123: 44 4 EXIT __Index__ for uci.i/3-0 (det)
+mdb> print goal
+__Index__(ai(1), 0)
+mdb> goto 124
+ 124: 45 4 CALL __Index__ for uci.i/3-0 (det)
+mdb> print goal
+__Index__(bi(11), _)
+mdb> goto 126
+ 126: 45 4 EXIT __Index__ for uci.i/3-0 (det)
+mdb> print goal
+__Index__(bi(11), 1)
+mdb> continue
+0 lt
+1 ge
+2 ge
+3 ge
+4 lt
+0 ne
+1 eq
+2 ne
+3 eq
+4 ne
+i lt
Index: tests/debugger/uci.inp
===================================================================
RCS file: tests/debugger/uci.inp
diff -N tests/debugger/uci.inp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci.inp 31 Mar 2003 07:29:09 -0000
@@ -0,0 +1,44 @@
+echo on
+context none
+register --quiet
+goto 16
+print goal
+goto 19
+print goal
+goto 28
+print goal
+goto 35
+print goal
+goto 44
+print goal
+goto 47
+print goal
+goto 56
+print goal
+goto 59
+print goal
+goto 76
+print goal
+goto 78
+print goal
+goto 87
+print goal
+goto 89
+print goal
+goto 98
+print goal
+goto 100
+print goal
+goto 109
+print goal
+goto 111
+print goal
+goto 121
+print goal
+goto 123
+print goal
+goto 124
+print goal
+goto 126
+print goal
+continue
Index: tests/debugger/uci.m
===================================================================
RCS file: tests/debugger/uci.m
diff -N tests/debugger/uci.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci.m 31 Mar 2003 07:30:42 -0000
@@ -0,0 +1,122 @@
+% This test case checks the debugger's handling of unify, compare and index
+% predicates. Versions of the runtime system before 29 Mar 2003 used to have
+% a bug in computing their arities.
+
+:- module uci.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module string, list.
+
+main(!IO) :-
+ test([], RevResults),
+ list__reverse(RevResults, Results),
+ string__append_list(Results, ResultString),
+ io__write_string(ResultString, !IO).
+
+:- pred test(list(string)::in, list(string)::out) is det.
+
+test(!Res) :-
+ ( compare((<), ma0, mb0) ->
+ add_res("0 lt\n", !Res)
+ ;
+ add_res("0 ge\n", !Res)
+ ),
+ ( compare((<), mb1, ma1) ->
+ add_res("1 lt\n", !Res)
+ ;
+ add_res("1 ge\n", !Res)
+ ),
+ ( compare((<), ma2, ma2) ->
+ add_res("2 lt\n", !Res)
+ ;
+ add_res("2 ge\n", !Res)
+ ),
+ ( compare((<), mb3, ma3) ->
+ add_res("3 lt\n", !Res)
+ ;
+ add_res("3 ge\n", !Res)
+ ),
+ ( compare((<), ma4, mb4) ->
+ add_res("4 lt\n", !Res)
+ ;
+ add_res("4 ge\n", !Res)
+ ),
+ ( unify(ma0, mb0) ->
+ add_res("0 eq\n", !Res)
+ ;
+ add_res("0 ne\n", !Res)
+ ),
+ ( unify(ma1, ma1) ->
+ add_res("1 eq\n", !Res)
+ ;
+ add_res("1 ne\n", !Res)
+ ),
+ ( unify(ma2, mb2) ->
+ add_res("2 eq\n", !Res)
+ ;
+ add_res("2 ne\n", !Res)
+ ),
+ ( unify(mb3, mb3) ->
+ add_res("3 eq\n", !Res)
+ ;
+ add_res("3 ne\n", !Res)
+ ),
+ ( unify(ma4, mb4) ->
+ add_res("4 eq\n", !Res)
+ ;
+ add_res("4 ne\n", !Res)
+ ),
+ ( compare((<), mai, mbi) ->
+ add_res("i lt\n", !Res)
+ ;
+ add_res("i ge\n", !Res)
+ ).
+
+:- pred add_res(string::in, list(string)::in, list(string)::out) is det.
+
+add_res(R, Rs0, [R | Rs0]).
+
+:- type t0 ---> a0 ; b0.
+:- type t1(A) ---> a1(A) ; b1(A).
+:- type t2(A, B) ---> a2(A, B) ; b2(A, B).
+:- type t3(A, B, C) ---> a3(A, B, C) ; b3(A, B, C).
+:- type t4(A, B, C, D) ---> a4(A, B, C, D) ; b4(A, B, C, D).
+
+:- type i(A, B, C) ---> ai(A) ; bi(B) ; ci(C).
+
+:- func ma0 = t0.
+:- func mb0 = t0.
+:- func ma1 = t1(int).
+:- func mb1 = t1(int).
+:- func ma2 = t2(int, int).
+:- func mb2 = t2(int, int).
+:- func ma3 = t3(int, int, int).
+:- func mb3 = t3(int, int, int).
+:- func ma4 = t4(int, int, int, int).
+:- func mb4 = t4(int, int, int, int).
+
+:- func mai = i(int, int, int).
+:- func mbi = i(int, int, int).
+:- func mci = i(int, int, int).
+
+ma0 = a0.
+mb0 = b0.
+ma1 = a1(1).
+mb1 = b1(11).
+ma2 = a2(1, 2).
+mb2 = b2(11, 12).
+ma3 = a3(1, 2, 3).
+mb3 = b3(11, 12, 13).
+ma4 = a4(1, 2, 3, 4).
+mb4 = b4(11, 12, 13, 14).
+
+mai = ai(1).
+mbi = bi(11).
+mci = ci(111).
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.61
diff -u -b -r1.61 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c 6 Nov 2002 02:02:37 -0000 1.61
+++ trace/mercury_trace_declarative.c 29 Mar 2003 03:43:10 -0000
@@ -950,22 +950,15 @@
MR_trace_init_point_vars(layout, saved_regs, port, MR_TRUE);
name = MR_decl_atom_name(entry);
- if (MR_PROC_LAYOUT_COMPILER_GENERATED(entry)) {
- arity = entry->MR_sle_comp.MR_comp_arity;
- pred_or_func = MR_PREDICATE;
- } else {
- arity = entry->MR_sle_user.MR_user_arity;
- pred_or_func = entry->MR_sle_user.MR_user_pred_or_func;
- }
+ MR_proc_id_arity_addedargs_predfunc(entry, &arity, &num_added_args,
+ &pred_or_func);
+
MR_TRACE_CALL_MERCURY(
atom = MR_DD_construct_trace_atom(
(MR_Word) pred_or_func,
(MR_String) name,
(MR_Word) entry->MR_sle_num_head_vars);
);
-
- /* Find out how many type-info/typeclass-info variables were added. */
- num_added_args = entry->MR_sle_num_head_vars - arity;
for (hv = 0; hv < entry->MR_sle_num_head_vars; hv++) {
int hlds_num;
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.67
diff -u -b -r1.67 mercury_trace_external.c
--- trace/mercury_trace_external.c 6 Nov 2002 02:02:38 -0000 1.67
+++ trace/mercury_trace_external.c 31 Mar 2003 09:51:51 -0000
@@ -934,7 +934,8 @@
layout->MR_sll_entry->MR_sle_comp.MR_comp_def_module,
(MR_String)
layout->MR_sll_entry->MR_sle_comp.MR_comp_pred_name,
- layout->MR_sll_entry->MR_sle_comp.MR_comp_arity,
+ /* is the type_ctor's arity what is wanted? XXX */
+ layout->MR_sll_entry->MR_sle_comp.MR_comp_type_arity,
layout->MR_sll_entry->MR_sle_comp.MR_comp_mode,
layout->MR_sll_entry->MR_sle_detism,
(MR_String) (MR_Word) path,
@@ -1037,7 +1038,8 @@
layout->MR_sll_entry->MR_sle_comp.MR_comp_def_module,
(MR_String)
layout->MR_sll_entry->MR_sle_comp.MR_comp_pred_name,
- layout->MR_sll_entry->MR_sle_comp.MR_comp_arity,
+ /* is the type_ctor's arity what is wanted? XXX */
+ layout->MR_sll_entry->MR_sle_comp.MR_comp_type_arity,
layout->MR_sll_entry->MR_sle_comp.MR_comp_mode,
layout->MR_sll_entry->MR_sle_detism,
arguments,
@@ -1368,7 +1370,7 @@
entry->MR_sle_comp.MR_comp_pred_name,
entry->MR_sle_comp.MR_comp_type_module,
entry->MR_sle_comp.MR_comp_type_name,
- (long) entry->MR_sle_comp.MR_comp_arity,
+ (long) entry->MR_sle_comp.MR_comp_type_arity,
(long) entry->MR_sle_comp.MR_comp_mode);
if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.51
diff -u -b -r1.51 mercury_trace_vars.c
--- trace/mercury_trace_vars.c 7 Mar 2003 08:14:00 -0000 1.51
+++ trace/mercury_trace_vars.c 29 Mar 2003 14:25:25 -0000
@@ -314,8 +314,9 @@
const MR_Proc_Layout *entry;
MR_Word *valid_saved_regs;
int var_count;
- int proc_arity;
int num_added_args;
+ int arity;
+ MR_PredFunc pred_or_func;
MR_TypeInfo *type_params;
MR_Word value;
MR_TypeInfo type_info;
@@ -406,13 +407,8 @@
string_table = entry->MR_sle_module_layout->MR_ml_string_table;
string_table_size = entry->MR_sle_module_layout->MR_ml_string_table_size;
- /* Work out how many type-infos were added. */
- if (MR_PROC_LAYOUT_COMPILER_GENERATED(entry)) {
- proc_arity = entry->MR_sle_comp.MR_comp_arity;
- } else {
- proc_arity = entry->MR_sle_user.MR_user_arity;
- }
- num_added_args = entry->MR_sle_num_head_vars - proc_arity;
+ MR_proc_id_arity_addedargs_predfunc(entry, &arity, &num_added_args,
+ &pred_or_func);
slot = 0;
for (i = 0; i < var_count; i++) {
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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