[m-rev.] for review: cleaning up and documenting I/O tabling

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Oct 18 17:17:58 AEST 2002


For review by Mark and/or Fergus.

Zoltan.

Document I/O tabling, after cleaning it up for public use.

We have previously implemented two forms of I/O tabling. One tables
only the output arguments of each primitive; this allows transparent
retries across I/O. The other tables all the arguments and the name
of the predicate; this allows transparent retries across I/O, the
declarative debugging of code that does I/O, and the printing of tabled
I/O actions. Since we now support declarative debugging in the standard
debugging grades, standardize on the second form of I/O tabling, and
make the first form accessible to implementors only, via a deliberately
undocumented option. This option, --trace-table-io-only-retry, is sort of
the inverse of the old option --trace-table-io-decl, which this change
deletes. (Only "sort of" because --trace-table-io-decl used to turn on
I/O tabling, whereas --trace-table-io-only-retry is consulted only if
I/O tabling is turned on by some other mechanism.)

NEWS:
	Mention I/O tabling.

compiler/options.m:
	Delete --trace-table-io-decl, and add --trace-table-io-only-retry.

	Update documentation.

compiler/table_gen.m:
	Base decisions on --trace-table-io-only-retry, not
	--trace-table-io-decl.

compiler/handle_options.m:
	Delete an implication involving --trace-table-io-decl that is now
	unnecessary.

doc/user_guide.texi:
	Document the idea of I/O tabling, and move the table_io command
	out of the list of developer only commands into a category of its own
	(since it doesn't naturally fit anywhere else).

	Change the old mismatched "table_io start" "table_io end" pair to
	the matched "table_io start" "table_io stop" pair.

	Document the variants of the print and browse commands that print and
	browse I/O actions.

	Be consistent about formatting of categories of mdb commands.

doc/generate_mdb_doc:
	Include the new table_io category in the list of mdb command
	categories.

	Squeeze out repeated blank lines in the automatically generated
	documentation, to make maximum use of screen real estate.

doc/squeeze:
	A new script to do the squeezing.

doc/mdb_categories:
	Include the new table_io category in the list of mdb command
	categories.

runtime/mercury_trace_base.[ch]:
	Add a new global variable MR_io_tabling_allowed. It is initialized
	to TRUE in debugging grades and FALSE in other grades.

trace/mercury_trace_internal.c:
	Accept "table_io begin" and "table_io end" as well as "table_io start"
	and "table_io stop". Consistently use "start" and "stop" in output.

	Make "table_io" print a message saying the executable is not set up
	for I/O tabling unless MR_io_tabling_allowed is set.

	Add a new command, "table allow", that sets MR_io_tabling_allowed to
	TRUE. In debugging grades, this has no effect. In other grades, it
	allows I/O tabling, even though some parts of the program may have
	been compiled with --trace-table-io and some without. This
	inconsistency can yield weird results, which is why this command is
	deliberately undocumented. However, we can use it in a disciplined
	fashion to test I/O tabling even in nondebugging grades, thus spotting
	any regression in this area more quickly than if we tested I/O tabling
	only in debugging grades.

tests/debugger/Mercury.options:
tests/debugger/declarative/Mercury.options:
	Delete all occurrences of --trace-table-io-decl, since its effect is
	now the default.

tests/debugger/mdb_command_test.inp:
	Move the location of the table_io command test in this autogenerated
	file to reflect its move to a new category.

tests/debugger/tabled_read*.{inp,exp}:
tests/debugger/declarative/tabled_read*.{inp,exp}:
	Execute "table_io allow" before trying to turn on I/O tabling, since
	this is now required in non-debugging grades.

	Reflect the change in terminology: expect "stopped", not "ended",

cvs diff: Diffing .
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.272
diff -u -b -r1.272 NEWS
--- NEWS	14 Oct 2002 07:07:57 -0000	1.272
+++ NEWS	17 Oct 2002 09:12:34 -0000
@@ -24,6 +24,7 @@
 * Command-line completion.
 * Ability to display values of higher-order terms.
 * Declarative debugging.
+* Support for transparent retries across I/O.
 
 Numerous minor improvements to the Mercury standard library.
 
@@ -384,5 +385,11 @@
 * The debugger now includes support for declarative debugging.  The `dd'
   command starts diagnosis at any exit, fail or exception port in mdb.  See
   the Mercury User's Guide for more details.
+
+* When a program is compiled in a debugging grade, the debugger can be
+  asked, via the command `table_io start', to make I/O primitives (such as
+  io__open_file, io__write_string etc) idempotent. This means that a given
+  call to e.g. io__open_file will open the specified file only once,
+  even if retry commands cause the call to be executed more than once.
 
 For news about earlier versions, see the HISTORY file.
cvs diff: Diffing bench
cvs diff: Diffing bench/progs
cvs diff: Diffing bench/progs/compress
cvs diff: Diffing bench/progs/icfp2000
cvs diff: Diffing bench/progs/icfp2001
cvs diff: Diffing bench/progs/nuc
cvs diff: Diffing bench/progs/ray
cvs diff: Diffing bench/progs/tree234
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
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.154
diff -u -b -r1.154 handle_options.m
--- compiler/handle_options.m	17 Oct 2002 09:17:46 -0000	1.154
+++ compiler/handle_options.m	17 Oct 2002 09:18:52 -0000
@@ -630,8 +630,6 @@
 	% one can do retries across I/O safely.
 	option_implies(require_tracing, trace_table_io_all, bool(yes)),
 
-	% --trace-table-io-decl is an extension of --trace-table-io
-	option_implies(trace_table_io_decl, trace_table_io, bool(yes)),
 	% --trace-table-io-all is compulsory application of --trace-table-io
 	option_implies(trace_table_io_all, trace_table_io, bool(yes)),
 	% --trace-table-io-require is compulsory application of --trace-table-io
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.389
diff -u -b -r1.389 options.m
--- compiler/options.m	16 Oct 2002 08:08:46 -0000	1.389
+++ compiler/options.m	17 Oct 2002 04:34:39 -0000
@@ -141,7 +141,7 @@
 		;	trace
 		;	trace_optimized
 		;	trace_table_io
-		;	trace_table_io_decl
+		;	trace_table_io_only_retry
 		;	trace_table_io_states
 		;	trace_table_io_require
 		;	trace_table_io_all
@@ -717,7 +717,7 @@
 	trace			-	string("default"),
 	trace_optimized		-	bool(no),
 	trace_table_io		-	bool(no),
-	trace_table_io_decl	-	bool(no),
+	trace_table_io_only_retry -	bool(no),
 	trace_table_io_states	-	bool(no),
 	trace_table_io_require	-	bool(no),
 	trace_table_io_all	-	bool(no),
@@ -1278,13 +1278,12 @@
 long_option("assume-gmake",		assume_gmake).
 long_option("generate-mmc-make-module-dependencies",
 					generate_mmc_make_module_dependencies).
-long_option("generate-mmc-deps",
-					generate_mmc_make_module_dependencies).
+long_option("generate-mmc-deps",	generate_mmc_make_module_dependencies).
 long_option("trace",			trace).
 long_option("trace-optimised",		trace_optimized).
 long_option("trace-optimized",		trace_optimized).
 long_option("trace-table-io",		trace_table_io).
-long_option("trace-table-io-decl",	trace_table_io_decl).
+long_option("trace-table-io-only-retry", trace_table_io_only_retry).
 long_option("trace-table-io-states",	trace_table_io_states).
 long_option("trace-table-io-require",	trace_table_io_require).
 long_option("trace-table-io-all",	trace_table_io_all).
@@ -2439,14 +2438,18 @@
 %		"\tSuppress the named aspects of the execution tracing system.",
 		"--trace-optimized",
 		"\tDo not disable optimizations that can change the trace.",
-% tabling io is documented yet, since it is mean to be switched on only
-% automatically (in certain grades)
+% I/O tabling is deliberately not documented. It is mean to be switched on,
+% with consistent parameters, in debugging grades, and to be consistently
+% switched off in non-debugging grades. Inconsistent use of the options
+% governing I/O tabling can yield core dumps from the debugger, so these
+% options are for implementors only.
 %		"--trace-table-io",
 %		"\tEnable the tabling of I/O actions, to allow the debugger",
 %		"\tto execute retry commands across I/O actions.",
-%		"--trace-table-io-decl",
-%		"\tSet up I/O tabling so that the declarative debugger can",
-%		"\tmake use of it.",
+%		"--trace-table-io-only-retry",
+%		"\tSet up I/O tabling to support only retries across I/O",
+%		"\tactions, not the printing of actions or declarative",
+%		"\tdebugging. This reduces the size of the I/O action table.",
 %		"--trace-table-io-states",
 %		"\tWhen tabling I/O actions, table the io__state arguments",
 %		"\ttogether with the others. This should be required iff",
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.39
diff -u -b -r1.39 table_gen.m
--- compiler/table_gen.m	9 Sep 2002 08:55:12 -0000	1.39
+++ compiler/table_gen.m	16 Oct 2002 07:57:44 -0000
@@ -360,12 +360,13 @@
 		;
 			TransformPrimitive = yes(Unitize),
 			globals__lookup_bool_option(Globals,
-				trace_table_io_decl, TraceTableIoDecl),
+				trace_table_io_only_retry,
+				TraceTableIoOnlyRetry),
 			(
-				TraceTableIoDecl = yes,
+				TraceTableIoOnlyRetry = no,
 				Decl = table_io_decl
 			;
-				TraceTableIoDecl = no,
+				TraceTableIoOnlyRetry = yes,
 				Decl = table_io_proc
 			),
 			TableIoMethod = eval_table_io(Decl, Unitize),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/generate_mdb_doc
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/generate_mdb_doc,v
retrieving revision 1.5
diff -u -b -r1.5 generate_mdb_doc
--- doc/generate_mdb_doc	20 Jul 1999 21:29:54 -0000	1.5
+++ doc/generate_mdb_doc	18 Oct 2002 02:13:36 -0000
@@ -16,12 +16,16 @@
 
 debug_cmd_path="debug debugger"
 for section in interactive forward backward browsing breakpoint \
-	parameter help exp developer misc 
+	i/o parameter help exp developer misc 
 do
 	case $section in
 		interactive)	category=queries ;;
+		i/o)		category=table_io ;;
 		*)		category=$section ;;
 	esac
 	info -f ./mercury_user_guide.info -o $tmp $debug_cmd_path $section
 	../util/info_to_mdb $category $tmp >> mdb_doc
 done
+
+mv mdb_doc $tmp
+./squeeze < $tmp > mdb_doc
Index: doc/mdb_categories
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.13
diff -u -b -r1.13 mdb_categories
--- doc/mdb_categories	9 Sep 2002 07:48:20 -0000	1.13
+++ doc/mdb_categories	18 Oct 2002 01:53:54 -0000
@@ -35,33 +35,37 @@
              `delete', `modules', `procedures' and `register'.
 
 end
-document_category 600 parameter
+document_category 600 table_io
+table_io   - Commands that let users control the tabling of I/O actions.
+             The only such command is `table_io'.
+
+end
+document_category 700 parameter
 parameter  - Commands that let users access debugger parameters.
              The parameter commands are `printlevel', `echo', `context',
              `scroll', `mmc_options', `scope', `alias' and `unalias'.
 
 end
-document_category 700 help
+document_category 800 help
 help       - Commands that let users access and control the help system.
              The help commands are `document_category', `document' and `help'.
              For help on the `help' command, type `help help help'.
 
 end
-document_category 800 exp
+document_category 900 exp
 exp        - Commands that let users collect and inspect experimental
              data about the behavior of the program. The exp commands are
              `histogram_all', `histogram_exp', and `clear_histogram'.
 
 end
-document_category 900 developer
+document_category 1000 developer
 developer  - Commands that are intended to be of use only to developers
              of the Mercury implementation. The developer commands are
-             `nondet_stack', `stack_regs', `all_regs', `table_io',
-             `proc_stats', `label_stats', `print_optionals' and
-             `unhide_events'.
+             `nondet_stack', `stack_regs', `all_regs', `proc_stats',
+	     `label_stats', `print_optionals' and `unhide_events'.
 
 end
-document_category 1000 misc
+document_category 1100 misc
 misc       - Commands that do not fit into other categories.
              The misc commands are `source', `save' and `quit'.
 
Index: doc/squeeze
===================================================================
RCS file: doc/squeeze
diff -N doc/squeeze
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ doc/squeeze	18 Oct 2002 06:14:21 -0000
@@ -0,0 +1,23 @@
+#!/bin/sh
+#---------------------------------------------------------------------------#
+# Copyright (C) 2002 The University of Melbourne.
+# This file may only be copied under the terms of the GNU General
+# Public License - see the file COPYING in the Mercury distribution.
+#---------------------------------------------------------------------------#
+
+# Replace any sequence of blank lines in the input with a single blank line.
+# If invoked with arguments, the input is the concatenation of the named files;
+# if invoked without arguments, the input is standard input.
+
+awk '
+$0 ~ /^[ \t]*$/		{
+				if (empties == 0)
+					print;
+
+				empties++;
+			}
+$0 !~ /^[ \t]*$/	{
+				empties = 0;
+				print;
+			}
+' $@
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.331
diff -u -b -r1.331 user_guide.texi
--- doc/user_guide.texi	16 Oct 2002 08:08:50 -0000	1.331
+++ doc/user_guide.texi	18 Oct 2002 01:56:42 -0000
@@ -1161,6 +1161,7 @@
 * Tracing optimized code::
 * Mercury debugger invocation::
 * Mercury debugger concepts::
+* I/O tabling::
 * Debugger commands::
 * Declarative debugging::
 @end menu
@@ -1965,6 +1966,65 @@
 @end itemize
 @end table
 
+ at node I/O tabling
+ at section I/O tabling
+
+In Mercury, predicates that want to do I/O
+must take a di/uo pair of I/O state arguments.
+Some of these predicates call other predicates to do I/O for them,
+but some are @emph{I/O primitives}, i.e. they perform the I/O themselves.
+The Mercury standard library provides a large set of these primitives,
+and programmers can write their own through the foreign language interface.
+An I/O action is the execution of one call to an I/O primitive.
+
+In debugging grades, the Mercury implementation has the ability
+to automatically record, for every I/O action,
+the identity of the I/O primitive involved in the action
+and the values of all its arguments.
+The size of the table storing this information
+is proportional to the number of @emph{tabled} I/O actions,
+which are the I/O actions whose details are entered into the table.
+Therefore the tabling of I/O actions is never turned on automatically;
+instead, users must ask for I/O tabling to start
+with the @samp{table_io start} command in mdb.
+
+The purpose of I/O tabling is to enable transparent retries across I/O actions.
+In the absence of I/O tabling,
+retries across I/O actions can have bad consequences.
+Retry of a goal that reads some input requires that input to be provided twice;
+retry of a goal that writes some output generates duplicate output.
+Retry of a goal that opens a file leads to a file descriptor leak;
+retry of a goal that closes a file can lead to errors
+(duplicate closes, reads from and writes to closed files).
+
+I/O tabling avoids these problems by making I/O primitives @emph{idempotent}.
+This means that they will generate their desired effect
+when they are first executed,
+but reexecuting them after a retry won't have any further effect.
+The Mercury implementation achieves this
+by looking up the action (which is identified by a I/O action number)
+in the table and returning the output arguments stored in the table
+for the given action @emph{without} executing the code of the primitive.
+
+Starting I/O tabling when the program starts execution
+and leaving it enabled for the entire program run
+will work well for program runs that don't do lots of I/O.
+For program runs that @emph{do} lots of I/O,
+the table can fill up all available memory.
+In such cases, the programmer may enable I/O tabling with @samp{table_io start}
+just before the program enters the part they wish to debug
+and in which they wish to be able to perform
+transparent retries across I/O actions,
+and turn it off with @samp{table_io stop} after execution leaves that part.
+
+The commands @samp{table_io start} and @samp{table_io stop}
+can each be given only once during an mdb session.
+They divide the execution of the program into three phases:
+before @samp{table_io start},
+between @samp{table_io start} and @samp{table_io stop},
+and after @samp{table_io stop}.
+Retries across I/O will be transparent only in the middle phase.
+
 @node Debugger commands
 @section Debugger commands
 
@@ -1998,6 +2058,7 @@
 * Backward movement commands::
 * Browsing commands::
 * Breakpoint commands::
+* I/O tabling commands::
 * Parameter commands::
 * Help commands::
 * Experimental commands::
@@ -2073,12 +2134,13 @@
 @samp{MGNUCFLAGS=--pic-reg} and @samp{MLFLAGS=--shared} in your
 Mmakefile.  See the @file{README.Linux} file in the Mercury
 distribution for more details.
-
 @end table
 
+ at sp 1
 @node Forward movement commands
 @subsection Forward movement commands
 
+ at sp 1
 @table @code
 @item step [-NSans] [@var{num}]
 @kindex step (mdb command)
@@ -2258,9 +2320,11 @@
 by the command by default depends on the final strictness level:
 if the command is strict, it is @samp{none}, otherwise it is @samp{some}.
 @end table
+
 @sp 1
 @node Backward movement commands
 @subsection Backward movement commands
+
 @sp 1
 @table @code
 @item retry [-f]
@@ -2334,9 +2398,11 @@
 The option @samp{-f} or @samp{--force} suppresses the question,
 and tells the debugger that retrying over I/O is OK.
 @end table
+
 @sp 1
 @node Browsing commands
 @subsection Browsing commands
+
 @sp 1
 @table @code
 @item vars
@@ -2378,6 +2444,13 @@
 The options @samp{-f} or @samp{--flat}, @samp{-p} or @samp{--pretty},
 and @samp{-v} or @samp{--verbose} specify the format to use for printing.
 @sp 1
+ at item print [-fpv] action @var{num}
+Prints a representation
+of the @var{num}'th I/O action executed by the program.
+ at sp 1
+The options @samp{-f} or @samp{--flat}, @samp{-p} or @samp{--pretty},
+and @samp{-v} or @samp{--verbose} specify the format to use for printing.
+ at sp 1
 @item browse [-fpv] @var{name}
 @itemx browse [-fpv] @var{num}
 @kindex browse (mdb command)
@@ -2415,6 +2488,13 @@
 The options @samp{-f} or @samp{--flat}, @samp{-p} or @samp{--pretty},
 and @samp{-v} or @samp{--verbose} specify the format to use for browsing.
 @sp 1
+ at item browse [-fpv] action @var{num}
+Invokes an interactive term browser to browse a representation
+of the @var{num}'th I/O action executed by the program.
+ at sp 1
+The options @samp{-f} or @samp{--flat}, @samp{-p} or @samp{--pretty},
+and @samp{-v} or @samp{--verbose} specify the format to use for browsing.
+ at sp 1
 @item stack [-d]
 @kindex stack (mdb command)
 Prints the names of the ancestors of the call
@@ -2603,10 +2683,12 @@
 The option @samp{-t} (or @samp{--timeout}) specifies
 the maximum number of seconds to wait for the server to start.
 @end table
+
 @sp 1
 @node Breakpoint commands
 @subsection Breakpoint commands
 @cindex Breakpoints
+
 @sp 1
 @table @code
 @item break [-PS] [-E at var{ignore-count}] [-I at var{ignore-count}] @var{filename}:@var{linenumber}
@@ -2785,9 +2867,31 @@
 The debugger will perform this registration when creating breakpoints
 and when listing debuggable modules and/or procedures.
 @end table
+
+ at sp 1
+ at node I/O tabling commands
+ at subsection I/O tabling commands
+
+ at sp 1
+ at table @code
+ at item table_io
+ at kindex table_io (mdb command)
+Reports which phase of I/O tabling we are in at the moment.
+ at sp 1
+ at item table_io start
+Tells the debugger to start tabling I/O actions.
+ at sp 1
+ at item table_io stop
+Tells the debugger to stop tabling I/O actions.
+ at sp 1
+ at item table_io stats
+Reports statistics about I/O tabling.
+ at end table
+
 @sp 1
 @node Parameter commands
 @subsection Parameter commands
+
 @sp 1
 @table @code
 @item mmc_options @var{option1} @var{option2} @dots{}
@@ -2925,9 +3029,11 @@
 @kindex unalias (mdb command)
 Removes any existing alias for @var{name}.
 @end table
+
 @sp 1
 @node Help commands
 @subsection Help commands
+
 @sp 1
 @table @code
 @item document_category @var{slot} @var{category}
@@ -2957,9 +3063,11 @@
 @item help
 Prints summary information about all the available help categories.
 @end table
+
 @sp 1
 @node Experimental commands
 @subsection Experimental commands
+
 @sp 1
 @table @code
 @item histogram_all @var{filename}
@@ -2983,8 +3091,11 @@
 Clears the histogram printed by @samp{histogram_exp},
 i.e.@: sets the counts for all depths to zero.
 @end table
+
+ at sp 1
 @node Developer commands
 @subsection Developer commands
+
 @sp 1
 The following commands are intended for use by the developers
 of the Mercury implementation.
@@ -3006,19 +3117,6 @@
 @kindex all_regs (mdb command)
 Prints the contents of all the virtual machine registers.
 @sp 1
- at item table_io
- at kindex table_io (mdb command)
-Reports which phase of I/O tabling we are in at the moment.
- at sp 1
- at item table_io stats
-Reports statistics about I/O tabling.
- at sp 1
- at item table_io start
-Tells the debugger to start tabling I/O actions.
- at sp 1
- at item table_io end
-Tells the debugger to stop tabling I/O actions.
- at sp 1
 @item proc_stats
 @kindex proc_stats (mdb command)
 Prints statistics about proc layout structures in the program.
@@ -3058,8 +3156,11 @@
 @item unhide_events off
 Tells the debugger to hide events that are normally hidden.
 @end table
+
+ at sp 1
 @node Miscellaneous commands
 @subsection Miscellaneous commands
+
 @sp 1
 @table @code
 @item source [-i] @var{filename}
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/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 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_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.47
diff -u -b -r1.47 mercury_trace_base.c
--- runtime/mercury_trace_base.c	11 Sep 2002 07:20:28 -0000	1.47
+++ runtime/mercury_trace_base.c	18 Oct 2002 03:33:44 -0000
@@ -65,6 +65,12 @@
 MR_Unsigned		MR_io_tabling_end = 0;
 MR_bool			MR_io_tabling_debug = MR_FALSE;
 
+#ifdef	MR_REQUIRE_TRACING
+MR_bool			MR_io_tabling_allowed = MR_TRUE;
+#else
+MR_bool			MR_io_tabling_allowed = MR_FALSE;
+#endif
+
 #ifdef	MR_TRACE_HISTOGRAM
 
 int		*MR_trace_histogram_all = NULL;
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.28
diff -u -b -r1.28 mercury_trace_base.h
--- runtime/mercury_trace_base.h	29 Sep 2002 10:30:54 -0000	1.28
+++ runtime/mercury_trace_base.h	18 Oct 2002 03:34:21 -0000
@@ -275,6 +275,9 @@
 /* The flag that controls whether we should generate diagnostics. */
 extern	MR_bool		MR_io_tabling_debug;
 
+/* The flag that controls whether I/O tabling is allowed at all. */
+extern	MR_bool		MR_io_tabling_allowed;
+
 /*
 ** These functions will report the number of the last event,
 ** if there have been some events, and will do nothing otherwise.
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.3
diff -u -b -r1.3 Mercury.options
--- tests/debugger/Mercury.options	17 Oct 2002 09:17:49 -0000	1.3
+++ tests/debugger/Mercury.options	18 Oct 2002 03:39:23 -0000
@@ -7,7 +7,7 @@
 MCFLAGS-shallow = --trace shallow
 MCFLAGS-tabled_read = --trace-table-io-all
 MCFLAGS-tabled_read_unitize = --trace-table-io-all
-MCFLAGS-tabled_read_decl = --trace-table-io-decl --trace-table-io-all
+MCFLAGS-tabled_read_decl = --trace-table-io-all
 # By default, we reclaim heap on failure in non-Boehm-gc grades.
 # The extra stack slots required for this reclamation cause spurious
 # differences from the expected output on the nondet_stack test case.
Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.19
diff -u -b -r1.19 mdb_command_test.inp
--- tests/debugger/mdb_command_test.inp	9 Sep 2002 07:48:24 -0000	1.19
+++ tests/debugger/mdb_command_test.inp	18 Oct 2002 04:50:42 -0000
@@ -30,6 +30,7 @@
 modules              xyzzy xyzzy xyzzy xyzzy xyzzy
 procedures           xyzzy xyzzy xyzzy xyzzy xyzzy
 register             xyzzy xyzzy xyzzy xyzzy xyzzy
+table_io             xyzzy xyzzy xyzzy xyzzy xyzzy
 mmc_options          xyzzy xyzzy xyzzy xyzzy xyzzy
 printlevel           xyzzy xyzzy xyzzy xyzzy xyzzy
 echo                 xyzzy xyzzy xyzzy xyzzy xyzzy
@@ -43,7 +44,6 @@
 nondet_stack         xyzzy xyzzy xyzzy xyzzy xyzzy
 stack_regs           xyzzy xyzzy xyzzy xyzzy xyzzy
 all_regs             xyzzy xyzzy xyzzy xyzzy xyzzy
-table_io             xyzzy xyzzy xyzzy xyzzy xyzzy
 proc_stats           xyzzy xyzzy xyzzy xyzzy xyzzy
 label_stats          xyzzy xyzzy xyzzy xyzzy xyzzy
 print_optionals      xyzzy xyzzy xyzzy xyzzy xyzzy
Index: tests/debugger/tabled_read.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read.exp,v
retrieving revision 1.4
diff -u -b -r1.4 tabled_read.exp
--- tests/debugger/tabled_read.exp	11 Sep 2002 07:20:31 -0000	1.4
+++ tests/debugger/tabled_read.exp	18 Oct 2002 03:40:11 -0000
@@ -4,6 +4,7 @@
 mdb> register --quiet
 mdb> context none
 Contexts will not be printed.
+mdb> table_io allow
 mdb> table_io
 io tabling has not yet started
 mdb> break tabled_read__test
@@ -35,7 +36,7 @@
        N (arg 3)              	123
        DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> table_io end
-io tabling ended
+io tabling stopped
 mdb> continue
 123
 456
Index: tests/debugger/tabled_read.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read.inp,v
retrieving revision 1.1
diff -u -b -r1.1 tabled_read.inp
--- tests/debugger/tabled_read.inp	6 Dec 2000 06:05:54 -0000	1.1
+++ tests/debugger/tabled_read.inp	18 Oct 2002 03:39:43 -0000
@@ -1,6 +1,7 @@
 echo on
 register --quiet
 context none
+table_io allow
 table_io
 break tabled_read__test
 table_io start
Index: tests/debugger/tabled_read_decl.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read_decl.exp,v
retrieving revision 1.4
diff -u -b -r1.4 tabled_read_decl.exp
--- tests/debugger/tabled_read_decl.exp	11 Sep 2002 07:20:31 -0000	1.4
+++ tests/debugger/tabled_read_decl.exp	18 Oct 2002 04:53:58 -0000
@@ -4,6 +4,7 @@
 mdb> register --quiet
 mdb> context none
 Contexts will not be printed.
+mdb> table_io allow
 mdb> table_io
 io tabling has not yet started
 mdb> break tabled_read_decl__test
@@ -68,7 +69,7 @@
 456
       E6:     C4  2 CALL pred tabled_read_decl:part_2/3-0 (det)
 mdb> table_io end
-io tabling ended
+io tabling stopped
 mdb> print action 0
 open_input("tabled_read_decl.data", 0, '<<c_pointer>>')
 mdb> print action 1
Index: tests/debugger/tabled_read_decl.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read_decl.inp,v
retrieving revision 1.1
diff -u -b -r1.1 tabled_read_decl.inp
--- tests/debugger/tabled_read_decl.inp	20 Feb 2002 03:14:46 -0000	1.1
+++ tests/debugger/tabled_read_decl.inp	18 Oct 2002 03:39:52 -0000
@@ -1,6 +1,7 @@
 echo on
 register --quiet
 context none
+table_io allow
 table_io
 break tabled_read_decl__test
 table_io start
Index: tests/debugger/tabled_read_unitize.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read_unitize.exp,v
retrieving revision 1.4
diff -u -b -r1.4 tabled_read_unitize.exp
--- tests/debugger/tabled_read_unitize.exp	13 Sep 2002 03:37:42 -0000	1.4
+++ tests/debugger/tabled_read_unitize.exp	18 Oct 2002 03:40:21 -0000
@@ -4,6 +4,7 @@
 mdb> register --quiet
 mdb> context none
 Contexts will not be printed.
+mdb> table_io allow
 mdb> table_io start
 io tabling started
 mdb> break unitize
Index: tests/debugger/tabled_read_unitize.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read_unitize.inp,v
retrieving revision 1.2
diff -u -b -r1.2 tabled_read_unitize.inp
--- tests/debugger/tabled_read_unitize.inp	29 Jul 2002 11:16:00 -0000	1.2
+++ tests/debugger/tabled_read_unitize.inp	18 Oct 2002 03:39:56 -0000
@@ -1,6 +1,7 @@
 echo on
 register --quiet
 context none
+table_io allow
 table_io start
 break unitize
 continue
cvs diff: Diffing tests/debugger/declarative
Index: tests/debugger/declarative/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/Mercury.options,v
retrieving revision 1.4
diff -u -b -r1.4 Mercury.options
--- tests/debugger/declarative/Mercury.options	29 Sep 2002 10:30:56 -0000	1.4
+++ tests/debugger/declarative/Mercury.options	18 Oct 2002 03:41:07 -0000
@@ -6,5 +6,5 @@
 MCFLAGS-output_term_dep=--trace rep
 MCFLAGS-shallow_2=--trace shallow
 MCFLAGS-special_term_dep=--trace rep
-MCFLAGS-tabled_read_decl=--trace rep --trace-table-io-decl --trace-table-io-all
+MCFLAGS-tabled_read_decl=--trace rep --trace-table-io-all
 MCFLAGS-untraced_subgoal_sub=--trace minimum
Index: tests/debugger/declarative/tabled_read_decl.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/tabled_read_decl.exp,v
retrieving revision 1.3
diff -u -b -r1.3 tabled_read_decl.exp
--- tests/debugger/declarative/tabled_read_decl.exp	16 Oct 2002 03:15:32 -0000	1.3
+++ tests/debugger/declarative/tabled_read_decl.exp	18 Oct 2002 03:41:23 -0000
@@ -4,6 +4,7 @@
 mdb> register --quiet
 mdb> context none
 Contexts will not be printed.
+mdb> table_io allow
 mdb> table_io start
 io tabling started
 mdb> break tabled_read_decl__test
Index: tests/debugger/declarative/tabled_read_decl.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/tabled_read_decl.inp,v
retrieving revision 1.1
diff -u -b -r1.1 tabled_read_decl.inp
--- tests/debugger/declarative/tabled_read_decl.inp	15 May 2002 11:24:17 -0000	1.1
+++ tests/debugger/declarative/tabled_read_decl.inp	18 Oct 2002 03:41:15 -0000
@@ -1,6 +1,7 @@
 echo on
 register --quiet
 context none
+table_io allow
 table_io start
 break tabled_read_decl__test
 continue
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
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/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_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.143
diff -u -b -r1.143 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	16 Oct 2002 05:45:30 -0000	1.143
+++ trace/mercury_trace_internal.c	18 Oct 2002 03:38:19 -0000
@@ -3154,6 +3154,13 @@
 	MR_Code **jumpaddr)
 {
 	if (word_count == 1) {
+		if (! MR_io_tabling_allowed) {
+			fprintf(MR_mdb_err,
+				"This executable wasn't prepared "
+				"for I/O tabling.\n");
+			return KEEP_INTERACTING;
+		}
+
 		if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE)
 		{
 			fprintf(MR_mdb_out,
@@ -3165,12 +3172,21 @@
 		} else if (MR_io_tabling_phase == MR_IO_TABLING_AFTER)
 		{
 			fprintf(MR_mdb_out,
-				"io tabling has finished\n");
+				"io tabling has stopped\n");
 		} else {
 			MR_fatal_error(
 				"io tabling in impossible phase\n");
 		}
-	} else if (word_count == 2 && MR_streq(words[1], "start")) {
+	} else if (word_count == 2 && (MR_streq(words[1], "start")
+		|| MR_streq(words[1], "begin")))
+	{
+		if (! MR_io_tabling_allowed) {
+			fprintf(MR_mdb_err,
+				"This executable wasn't prepared "
+				"for I/O tabling.\n");
+			return KEEP_INTERACTING;
+		}
+
 		if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE) {
 			MR_io_tabling_phase = MR_IO_TABLING_DURING;
 			MR_io_tabling_start = MR_io_tabling_counter;
@@ -3186,12 +3202,21 @@
 		} else if (MR_io_tabling_phase == MR_IO_TABLING_AFTER)
 		{
 			fprintf(MR_mdb_out,
-				"io tabling has already ended\n");
+				"io tabling has already stopped\n");
 		} else {
 			MR_fatal_error(
 				"io tabling in impossible phase\n");
 		}
-	} else if (word_count == 2 && MR_streq(words[1], "end")) {
+	} else if (word_count == 2 && (MR_streq(words[1], "stop")
+		|| MR_streq(words[1], "end")))
+	{
+		if (! MR_io_tabling_allowed) {
+			fprintf(MR_mdb_err,
+				"This executable wasn't prepared "
+				"for I/O tabling.\n");
+			return KEEP_INTERACTING;
+		}
+
 		if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE)
 		{
 			fprintf(MR_mdb_out,
@@ -3200,18 +3225,24 @@
 		{
 			MR_io_tabling_phase = MR_IO_TABLING_AFTER;
 			MR_io_tabling_end = MR_io_tabling_counter_hwm;
-			fprintf(MR_mdb_out, "io tabling ended\n");
+			fprintf(MR_mdb_out, "io tabling stopped\n");
 		} else if (MR_io_tabling_phase == MR_IO_TABLING_AFTER)
 		{
 			fprintf(MR_mdb_out,
-				"io tabling has already ended\n");
+				"io tabling has already stopped\n");
 		} else {
 			MR_fatal_error(
 				"io tabling in impossible phase\n");
 		}
 	} else if (word_count == 2 && MR_streq(words[1], "stats")) {
-		fprintf(MR_mdb_out, "phase = %d\n",
-			MR_io_tabling_phase);
+		if (! MR_io_tabling_allowed) {
+			fprintf(MR_mdb_err,
+				"This executable wasn't prepared "
+				"for I/O tabling.\n");
+			return KEEP_INTERACTING;
+		}
+
+		fprintf(MR_mdb_out, "phase = %d\n", MR_io_tabling_phase);
 		MR_print_unsigned_var(MR_mdb_out, "counter",
 			MR_io_tabling_counter);
 		MR_print_unsigned_var(MR_mdb_out, "hwm",
@@ -3220,6 +3251,9 @@
 			MR_io_tabling_start);
 		MR_print_unsigned_var(MR_mdb_out, "end",
 			MR_io_tabling_end);
+	} else if (word_count == 2 && MR_streq(words[1], "allow")) {
+		/* The  "table_io allow" command is for developers only */
+		MR_io_tabling_allowed = MR_TRUE;
 	} else {
 		MR_trace_usage("developer", "table_io");
 	}
@@ -4996,7 +5030,7 @@
 		{"all", "interface", "entry", NULL};
 
 static const char *const	MR_trace_table_io_cmd_args[] =
-		{"stats", "start", "end", NULL};
+		{"stats", "start", "stop", NULL};
 
 		/*
 		** It's better to have a single completion where possible,
@@ -5088,6 +5122,9 @@
 	{ "queries", "io_query", MR_trace_cmd_io_query,
 		NULL, MR_trace_module_completer },
 
+	{ "table_io", "table_io", MR_trace_cmd_table_io,
+		MR_trace_table_io_cmd_args, MR_trace_null_completer },
+
 	{ "parameter", "printlevel", MR_trace_cmd_printlevel,
 		MR_trace_printlevel_cmd_args, MR_trace_null_completer },
 	{ "parameter", "mmc_options", MR_trace_cmd_mmc_options,
@@ -5131,8 +5168,6 @@
 		NULL, MR_trace_null_completer },
 	{ "developer", "all_regs", MR_trace_cmd_all_regs,
 		NULL, MR_trace_null_completer },
-	{ "developer", "table_io", MR_trace_cmd_table_io,
-		MR_trace_table_io_cmd_args, MR_trace_null_completer },
 	{ "developer", "proc_stats", MR_trace_cmd_proc_stats,
 		NULL, MR_trace_filename_completer },
 	{ "developer", "label_stats", MR_trace_cmd_label_stats,
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