[m-rev.] diff: trace levels of index predicates

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Dec 6 12:34:50 AEDT 2004


Fix the failure of the debugger/uci test case with intermodule optimization
in asm_fast.gc. The problem was that we used to get a garbage value for the
call number of the index predicate, which shouldn't have had debugging enabled
in the first place.

compiler/trace_params.m:
	Always compile index predicates without any form of debugging, since
	they are only an implementation detail.

tests/debugger/uci_index.{m,inp,exp}:
tests/debugger/Mmakefile:
	Add this cut-down version of the uci test case.

tests/debugger/Mercury.options:
	Make sure that uci_index is always run with the options required to
	demonstrated the presence of the bug if in fact it is present.

Zoltan.

cvs server: Diffing .
cvs server: Diffing analysis
cvs server: Diffing bindist
cvs server: Diffing boehm_gc
cvs server: Diffing boehm_gc/Mac_files
cvs server: Diffing boehm_gc/cord
cvs server: Diffing boehm_gc/cord/private
cvs server: Diffing boehm_gc/doc
cvs server: Diffing boehm_gc/include
cvs server: Diffing boehm_gc/include/private
cvs server: Diffing boehm_gc/tests
cvs server: Diffing browser
cvs server: Diffing bytecode
cvs server: Diffing compiler
Index: compiler/trace_params.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace_params.m,v
retrieving revision 1.19
diff -u -r1.19 trace_params.m
--- compiler/trace_params.m	19 Nov 2004 11:54:20 -0000	1.19
+++ compiler/trace_params.m	6 Dec 2004 00:34:59 -0000
@@ -162,25 +162,51 @@
 convert_trace_level("default", _,   yes, yes(decl_rep)).
 
 eff_trace_level(PredInfo, ProcInfo, TraceLevel) = EffTraceLevel :-
-	(
-		TraceLevel = shallow,
-		pred_info_import_status(PredInfo, Status),
-		status_is_exported(Status, no),
-		proc_info_is_address_taken(ProcInfo, address_is_not_taken),
+	( TraceLevel = none ->
+		EffTraceLevel = none
+	;
 		pred_info_get_maybe_special_pred(PredInfo, MaybeSpecialPred),
+		(
+			MaybeSpecialPred = yes(SpecialPred - _),
 			% Unify and compare predicates can be called from
 			% the generic unify and compare predicates in
 			% builtin.m, so they can be called from outside this
 			% module even if they don't have their address taken.
-		(
-			MaybeSpecialPred = no
+			%
+			% Index predicates can never be called from anywhere
+			% except the compare predicate.
+			%
+			% Initialise predicates invoke user-provided code.
+			% Whether that code has debugging enabled or not,
+			% there is no point in generating events in the
+			% initialise predicate itself.
+			(
+				SpecialPred = unify,
+				EffTraceLevel = shallow
+			;
+				SpecialPred = compare,
+				EffTraceLevel = shallow
+			;
+				SpecialPred = index,
+				EffTraceLevel = none
+			;
+				SpecialPred = initialise,
+				EffTraceLevel = TraceLevel
+			)
 		;
-			MaybeSpecialPred = yes(index - _)
+			MaybeSpecialPred = no,
+			pred_info_import_status(PredInfo, Status),
+			(
+				TraceLevel = shallow,
+				status_is_exported(Status, no),
+				proc_info_is_address_taken(ProcInfo,
+					address_is_not_taken)
+			->
+				EffTraceLevel = none
+			;
+				EffTraceLevel = TraceLevel
+			)
 		)
-	->
-		EffTraceLevel = none
-	;
-		EffTraceLevel = TraceLevel
 	).
 
 given_trace_level_is_none(TraceLevel) =
cvs server: Diffing compiler/notes
cvs server: Diffing debian
cvs server: Diffing deep_profiler
cvs server: Diffing deep_profiler/notes
cvs server: Diffing doc
cvs server: Diffing extras
cvs server: Diffing extras/aditi
cvs server: Diffing extras/cgi
cvs server: Diffing extras/complex_numbers
cvs server: Diffing extras/complex_numbers/samples
cvs server: Diffing extras/complex_numbers/tests
cvs server: Diffing extras/concurrency
cvs server: Diffing extras/curs
cvs server: Diffing extras/curs/samples
cvs server: Diffing extras/curses
cvs server: Diffing extras/curses/sample
cvs server: Diffing extras/dynamic_linking
cvs server: Diffing extras/error
cvs server: Diffing extras/graphics
cvs server: Diffing extras/graphics/easyx
cvs server: Diffing extras/graphics/easyx/samples
cvs server: Diffing extras/graphics/mercury_glut
cvs server: Diffing extras/graphics/mercury_opengl
cvs server: Diffing extras/graphics/mercury_tcltk
cvs server: Diffing extras/graphics/samples
cvs server: Diffing extras/graphics/samples/calc
cvs server: Diffing extras/graphics/samples/gears
cvs server: Diffing extras/graphics/samples/maze
cvs server: Diffing extras/graphics/samples/pent
cvs server: Diffing extras/lazy_evaluation
cvs server: Diffing extras/lex
cvs server: Diffing extras/lex/samples
cvs server: Diffing extras/lex/tests
cvs server: Diffing extras/logged_output
cvs server: Diffing extras/moose
cvs server: Diffing extras/moose/samples
cvs server: Diffing extras/moose/tests
cvs server: Diffing extras/morphine
cvs server: Diffing extras/morphine/non-regression-tests
cvs server: Diffing extras/morphine/scripts
cvs server: Diffing extras/morphine/source
cvs server: Diffing extras/odbc
cvs server: Diffing extras/posix
cvs server: Diffing extras/quickcheck
cvs server: Diffing extras/quickcheck/tutes
cvs server: Diffing extras/references
cvs server: Diffing extras/references/samples
cvs server: Diffing extras/references/tests
cvs server: Diffing extras/stream
cvs server: Diffing extras/trailed_update
cvs server: Diffing extras/trailed_update/samples
cvs server: Diffing extras/trailed_update/tests
cvs server: Diffing extras/xml
cvs server: Diffing extras/xml/samples
cvs server: Diffing java
cvs server: Diffing java/runtime
cvs server: Diffing library
cvs server: Diffing profiler
cvs server: Diffing robdd
cvs server: Diffing runtime
cvs server: Diffing runtime/GETOPT
cvs server: Diffing runtime/machdeps
cvs server: Diffing samples
cvs server: Diffing samples/c_interface
cvs server: Diffing samples/c_interface/c_calls_mercury
cvs server: Diffing samples/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/c_interface/mercury_calls_c
cvs server: Diffing samples/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/c_interface/mercury_calls_fortran
cvs server: Diffing samples/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/diff
cvs server: Diffing samples/muz
cvs server: Diffing samples/rot13
cvs server: Diffing samples/solutions
cvs server: Diffing samples/tests
cvs server: Diffing samples/tests/c_interface
cvs server: Diffing samples/tests/c_interface/c_calls_mercury
cvs server: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/tests/c_interface/mercury_calls_c
cvs server: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs server: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/tests/diff
cvs server: Diffing samples/tests/muz
cvs server: Diffing samples/tests/rot13
cvs server: Diffing samples/tests/solutions
cvs server: Diffing samples/tests/toplevel
cvs server: Diffing scripts
cvs server: Diffing tools
cvs server: Diffing trace
cvs server: Diffing util
cvs server: Diffing vim
cvs server: Diffing vim/after
cvs server: Diffing vim/ftplugin
cvs server: Diffing vim/syntax
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mercury.options,v
retrieving revision 1.8
diff -u -r1.8 Mercury.options
--- tests/debugger/Mercury.options	23 Oct 2003 02:02:40 -0000	1.8
+++ tests/debugger/Mercury.options	19 Oct 2004 02:45:21 -0000
@@ -27,6 +27,14 @@
 # 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
+# uci_index is a regression test. We used to get a garbage value for the call
+# sequence number of the index predicate, which shouldn't have had debugging
+# enabled in the first place. The --compare-specialization option was required 
+# to get the compiler to create the index predicate in the first place, and
+# intermodule optimization was required to export the type, and thus its unify,
+# compare and index predicates. The bug occurred only in asm_fast.gc, not
+# asm_fast.gc.debug.tr.
+MCFLAGS-uci_index = --compare-specialization 2 --intermodule-optimization
 
 # 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/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.106
diff -u -r1.106 Mmakefile
--- tests/debugger/Mmakefile	10 Nov 2004 02:21:39 -0000	1.106
+++ tests/debugger/Mmakefile	10 Nov 2004 03:05:24 -0000
@@ -39,7 +39,8 @@
 	print_table			\
 	queens_rep			\
 	resume_typeinfos		\
-	type_desc_test
+	type_desc_test			\
+	uci_index
 
 # We currently don't pass this test.
 #	deeply_nested_typeinfo
@@ -447,6 +448,9 @@
 
 uci.out: uci uci.inp
 	$(MDB) ./uci < uci.inp 2>&1 > uci.out 2>&1
+
+uci_index.out: uci_index uci_index.inp
+	$(MDB) ./uci_index < uci_index.inp 2>&1 > uci_index.out 2>&1
 
 # When WORKSPACE is set, use $(WORKSPACE)/tools/lmc to compile the query.
 ifneq ($(origin WORKSPACE), undefined)
Index: tests/debugger/uci_index.exp
===================================================================
RCS file: tests/debugger/uci_index.exp
diff -N tests/debugger/uci_index.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci_index.exp	19 Oct 2004 08:23:29 -0000
@@ -0,0 +1,18 @@
+       1:      1  1 CALL pred uci_index.main/2-0 (det) uci_index.m:13
+mdb> echo on
+Command echo enabled.
+mdb> context none
+Contexts will not be printed.
+mdb> step
+       2:      2  2 CALL func uci_index.mai/0-0 (det)
+mdb> step
+       3:      2  2 EXIT func uci_index.mai/0-0 (det)
+mdb> step
+       4:      3  2 CALL func uci_index.mbi/0-0 (det)
+mdb> step
+       5:      3  2 EXIT func uci_index.mbi/0-0 (det)
+mdb> step
+       6:      4  2 CALL __Compare__ for uci_index.i/0-0 (det)
+mdb> step
+       7:      4  2 EXIT __Compare__ for uci_index.i/0-0 (det)
+mdb> quit -y
Index: tests/debugger/uci_index.inp
===================================================================
RCS file: tests/debugger/uci_index.inp
diff -N tests/debugger/uci_index.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci_index.inp	19 Oct 2004 08:23:27 -0000
@@ -0,0 +1,9 @@
+echo on
+context none
+step
+step
+step
+step
+step
+step
+quit -y
Index: tests/debugger/uci_index.m
===================================================================
RCS file: tests/debugger/uci_index.m
diff -N tests/debugger/uci_index.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci_index.m	19 Oct 2004 02:35:01 -0000
@@ -0,0 +1,23 @@
+:- module uci_index.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module string, list.
+
+main(!IO) :-
+	compare(R, mai, mbi),
+	write(R, !IO).
+
+:- type i	--->	ai(int) ; bi(int) ; ci(int).
+
+:- func mai = i.
+:- func mbi = i.
+
+mai = ai(1).
+mbi = bi(11).
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
--------------------------------------------------------------------------
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