[m-rev.] for review: integrity checks

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Jun 11 19:16:00 AEST 2003


Add a mechanism that can detect data structure corruption. The mechanism takes
the form of an option to mdb's forward movement commands, but is enabled only
if the trace directory is compiled with an implementor-only compile-time flag.
The option is therefore not documented.

runtime/mercury_conf_param.h:
	Document the compile-time flag.

trace/mercury_trace.[ch]:
	If the compile-time flag is defined, add a field to mdb commands
	that says whether or not integrity checks are supposed to be done,
	and act on its value. The integrity check consists of printing all
	the variables in all the ancestor stack frames at every event:
	this is useful when looking for code generation errors that cause
	cells to be built wrong.

trace/mercury_trace_external.c:
	If the compile-time flag is defined, set this field to false.

trace/mercury_trace_internal.c:
	If the compile-time flag is defined, set this field based on
	whether the last forward movement command included the --integrity or
	-i option.

trace/mercury_trace_vars.[ch]:
	If the compile-time flag is defined, add a function that implements
	the integrity check.

Zoltan.

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/error
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 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_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.70
diff -u -b -r1.70 mercury_conf_param.h
--- runtime/mercury_conf_param.h	10 Apr 2003 05:51:05 -0000	1.70
+++ runtime/mercury_conf_param.h	10 Jun 2003 05:20:52 -0000
@@ -231,6 +231,11 @@
 ** MP_DEBUG_MDPROF_SIGNAL
 **	Enables low-level debugging messages from the signal handling
 **	functions in the deep profiler.
+**
+** MR_TRACE_CHECK_INTEGRITY
+**	Enables the option on mdb's forward movement commands that causes the
+**	debugger to check the integrity of the representations of all the terms
+**	reachable from the stack.
 */
 
 #ifdef	MR_HIGHLEVEL_CODE
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
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.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.62
diff -u -b -r1.62 mercury_trace.c
--- trace/mercury_trace.c	7 Jun 2003 16:24:31 -0000	1.62
+++ trace/mercury_trace.c	10 Jun 2003 05:29:14 -0000
@@ -61,6 +61,9 @@
     0,                      /* stop event */
     MR_PRINT_LEVEL_SOME,
     MR_FALSE,               /* not strict */
+#ifdef  MR_TRACE_CHECK_INTEGRITY
+    MR_FALSE,               /* don't check integrity */
+#endif
     MR_TRUE,                /* must check */
     NULL                    /* pointer to filter/4 for collect queries */
 };
@@ -311,16 +314,29 @@
         /*
         ** The value of MR_trace_ctrl.MR_trace_must_check was
         ** precomputed when the command was set up; it was set to
-        ** MR_TRUE iff either MR_trace_ctrl.MR_trace_strict is
-        ** MR_FALSE (allowing us to stop at breakpoints whose action
-        ** is MR_SPY_STOP) or MR_trace_ctrl.MR_trace_print_level is
-        ** something other than MR_PRINT_LEVEL_NONE (allowing us to
-        ** print at least some events). The precomputation avoids
-        ** several jumps in the very frequent case that
-        ** MR_trace_must_check is false.
+        ** MR_TRUE iff any one of the following conditions is true:
+        **
+        ** - MR_trace_ctrl.MR_trace_strict is MR_FALSE (allowing us to stop
+        **   at breakpoints whose action is MR_SPY_STOP);
+        ** - MR_trace_ctrl.MR_trace_print_level is something other than
+        **   MR_PRINT_LEVEL_NONE (allowing us to print at least some events);
+        ** - MR_trace_ctrl.MR_trace_check_vars_integrity is MR_TRUE, requiring
+        **   us to check the integrity of all the live variables (which at the
+        **   moment means that they can have their sizes computed without
+        **   internal errors).
+        **
+        ** The precomputation avoids several jumps in the very frequent case
+        ** that MR_trace_must_check is false.
         */
 
         port = (MR_Trace_Port) layout->MR_sll_port;
+
+#ifdef  MR_TRACE_CHECK_INTEGRITY
+        if (MR_trace_ctrl.MR_trace_check_integrity) {
+            MR_trace_check_integrity(layout, port);
+        }
+#endif
+
         match = MR_event_matches_spy_point(layout, port, &action);
         if (! match) {
             if (MR_trace_ctrl.MR_trace_print_level == MR_PRINT_LEVEL_ALL) {
Index: trace/mercury_trace.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace.h,v
retrieving revision 1.27
diff -u -b -r1.27 mercury_trace.h
--- trace/mercury_trace.h	6 Nov 2002 02:02:37 -0000	1.27
+++ trace/mercury_trace.h	10 Jun 2003 05:29:14 -0000
@@ -226,21 +226,32 @@
 	MR_Unsigned		MR_trace_stop_event;
 	MR_Trace_Print_Level	MR_trace_print_level;
 	MR_bool			MR_trace_strict;
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+	MR_bool			MR_trace_check_integrity;
+#endif
 
 				/*
 				** The next field is an optimization;
 				** it must be set to !MR_trace_strict ||
 				** MR_trace_print_level != MR_PRINT_LEVEL_NONE
+				** || MR_trace_check_integrity (the last only
+				** if defined, of course).
 				*/
 	MR_bool			MR_trace_must_check;
 
 				/*
-				** The MR_filter_ptr field points to the filter/4
-				** procedure during a collect request
+				** The MR_filter_ptr field points to the
+				** filter/4 procedure during a collect request
 				*/
 	MR_FilterFuncPtr	MR_filter_ptr;
 } MR_Trace_Cmd_Info;
 
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+  #define MR_init_trace_check_integrity(cmd)	\
+	do { (cmd)->MR_trace_check_integrity = MR_FALSE; } while (0)
+#else
+  #define MR_init_trace_check_integrity(cmd)	((void) 0)
+#endif
 
 #define	MR_port_is_final(port)		((port) == MR_PORT_EXIT || \
 					 (port) == MR_PORT_FAIL || \
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.69
diff -u -b -r1.69 mercury_trace_external.c
--- trace/mercury_trace_external.c	16 Apr 2003 12:38:10 -0000	1.69
+++ trace/mercury_trace_external.c	10 Jun 2003 05:29:14 -0000
@@ -51,7 +51,6 @@
   #include <dlfcn.h>
 #endif
 
-
 /*
 ** This type must match the definition of classify_request in
 ** browser/debugger_interface.m.
@@ -841,6 +840,8 @@
 						cmd->MR_trace_must_check =
 							MR_FALSE;
 						cmd->MR_trace_strict = MR_TRUE;
+						MR_init_trace_check_integrity(
+							cmd);
 						cmd->MR_trace_print_level = 
 						 	MR_PRINT_LEVEL_NONE;
 						goto done;
@@ -897,6 +898,11 @@
 	*/
 	cmd->MR_trace_must_check = (! cmd->MR_trace_strict) ||
 			(cmd->MR_trace_print_level != MR_PRINT_LEVEL_NONE);
+
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+	cmd->MR_trace_must_check = cmd->MR_trace_must_check
+		|| cmd->MR_trace_check_integrity;
+#endif
 
 	/*
 	** Restore the event numbers, in case the Mercury
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.157
diff -u -b -r1.157 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	9 Jun 2003 02:50:25 -0000	1.157
+++ trace/mercury_trace_internal.c	10 Jun 2003 05:29:14 -0000
@@ -478,7 +478,7 @@
 static	void	MR_trace_cmd_nondet_stack_2(MR_Event_Info *event_info,
 			int limit, MR_bool detailed);
 
-static	MR_bool	MR_trace_options_strict_print(MR_Trace_Cmd_Info *cmd,
+static	MR_bool	MR_trace_options_movement_cmd(MR_Trace_Cmd_Info *cmd,
 			char ***words, int *word_count,
 			const char *cat, const char *item);
 static	MR_bool	MR_trace_options_retry(MR_Retry_Across_Io *across_io,
@@ -680,6 +680,11 @@
 	cmd->MR_trace_must_check = (! cmd->MR_trace_strict) ||
 			(cmd->MR_trace_print_level != MR_PRINT_LEVEL_NONE);
 
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+	cmd->MR_trace_must_check = cmd->MR_trace_must_check
+			|| cmd->MR_trace_check_integrity;
+#endif
+
 	MR_trace_call_seqno = event_details.MR_call_seqno;
 	MR_trace_call_depth = event_details.MR_call_depth;
 	MR_trace_event_number = event_details.MR_event_number;
@@ -1323,7 +1328,8 @@
 
 	cmd->MR_trace_strict = MR_FALSE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "step"))
 	{
 		; /* the usage message has already been printed */
@@ -1353,7 +1359,8 @@
 
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "goto"))
 	{
 		; /* the usage message has already been printed */
@@ -1387,7 +1394,8 @@
 
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "next"))
 	{
 		; /* the usage message has already been printed */
@@ -1426,7 +1434,8 @@
 
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "finish"))
 	{
 		; /* the usage message has already been printed */
@@ -1467,7 +1476,8 @@
 
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "fail"))
 	{
 		; /* the usage message has already been printed */
@@ -1518,7 +1528,8 @@
 {
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "exception"))
 	{
 		; /* the usage message has already been printed */
@@ -1543,7 +1554,8 @@
 {
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "return"))
 	{
 		; /* the usage message has already been printed */
@@ -1568,7 +1580,8 @@
 {
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "forward"))
 	{
 		; /* the usage message has already been printed */
@@ -1599,7 +1612,8 @@
 
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "mindepth"))
 	{
 		; /* the usage message has already been printed */
@@ -1625,7 +1639,8 @@
 
 	cmd->MR_trace_strict = MR_TRUE;
 	cmd->MR_trace_print_level = MR_default_print_level;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "maxdepth"))
 	{
 		; /* the usage message has already been printed */
@@ -1649,14 +1664,14 @@
 {
 	cmd->MR_trace_strict = MR_FALSE;
 	cmd->MR_trace_print_level = (MR_Trace_Cmd_Type) -1;
-	if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+	MR_init_trace_check_integrity(cmd);
+	if (! MR_trace_options_movement_cmd(cmd, &words, &word_count,
 		"forward", "continue"))
 	{
 		; /* the usage message has already been printed */
 	} else if (word_count == 1) {
 		cmd->MR_trace_cmd = MR_CMD_TO_END;
-		if (cmd->MR_trace_print_level ==
-				(MR_Trace_Cmd_Type) -1) {
+		if (cmd->MR_trace_print_level == (MR_Trace_Cmd_Type) -1) {
 			/*
 			** The user did not specify the print level;
 			** select the intelligent default.
@@ -4838,25 +4853,34 @@
 	}
 }
 
-static struct MR_option MR_trace_strict_print_opts[] =
+static struct MR_option MR_trace_movement_cmd_opts[] =
 {
 	{ "all",	MR_no_argument,	NULL,	'a' },
 	{ "none",	MR_no_argument,	NULL,	'n' },
 	{ "some",	MR_no_argument,	NULL,	's' },
 	{ "nostrict",	MR_no_argument,	NULL,	'N' },
 	{ "strict",	MR_no_argument,	NULL,	'S' },
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+	{ "integrity",	MR_no_argument,	NULL,	'i' },
+#endif
 	{ NULL,		MR_no_argument,	NULL,	0 }
 };
 
 static MR_bool
-MR_trace_options_strict_print(MR_Trace_Cmd_Info *cmd,
+MR_trace_options_movement_cmd(MR_Trace_Cmd_Info *cmd,
 	char ***words, int *word_count, const char *cat, const char *item)
 {
 	int	c;
 
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+  #define	MR_TRACE_MOVEMENT_OPTS	"NSains"
+#else
+  #define	MR_TRACE_MOVEMENT_OPTS	"NSans"
+#endif
+
 	MR_optind = 0;
-	while ((c = MR_getopt_long(*word_count, *words, "NSans",
-		MR_trace_strict_print_opts, NULL)) != EOF)
+	while ((c = MR_getopt_long(*word_count, *words, MR_TRACE_MOVEMENT_OPTS,
+		MR_trace_movement_cmd_opts, NULL)) != EOF)
 	{
 		switch (c) {
 
@@ -4879,6 +4903,12 @@
 			case 's':
 				cmd->MR_trace_print_level = MR_PRINT_LEVEL_SOME;
 				break;
+
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+			case 'i':
+				cmd->MR_trace_check_integrity = MR_TRUE;
+				break;
+#endif
 
 			default:
 				MR_trace_usage(cat, item);
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.52
diff -u -b -r1.52 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	2 Apr 2003 23:01:45 -0000	1.52
+++ trace/mercury_trace_vars.c	11 Jun 2003 09:13:58 -0000
@@ -1255,3 +1255,70 @@
 
     return NULL;
 }
+
+#ifdef  MR_TRACE_CHECK_INTEGRITY
+
+static void
+MR_trace_check_integrity_on_cur_level(void)
+{
+    int         i;
+
+    for (i = 0; i < MR_point.MR_point_var_count; i++) {
+        (void) MR_trace_browse_var(stdout, &MR_point.MR_point_vars[i],
+                (MR_String) (MR_Integer) "", MR_trace_print,
+                MR_BROWSE_CALLER_PRINT, MR_BROWSE_DEFAULT_FORMAT);
+    }
+}
+
+#define MR_INTEGRITY_ERROR_BUF_SIZE    512
+
+static  int         MR_check_max_mr_num;
+static  MR_Word     MR_check_saved_regs[MR_MAX_FAKE_REG];
+
+static  int         MR_check_integrity_seq_num = 0;
+
+void
+MR_trace_check_integrity(const MR_Label_Layout *layout, MR_Trace_Port port)
+{
+    int         level;
+    const char  *problem;
+    char        buf[MR_INTEGRITY_ERROR_BUF_SIZE];
+    MR_bool     saved_trace_enabled;
+
+    saved_trace_enabled = MR_trace_enabled;
+    MR_trace_enabled = MR_FALSE;
+
+    MR_compute_max_mr_num(MR_check_max_mr_num, layout);
+    MR_restore_transient_registers();
+    /* This also saves the regs in MR_fake_regs. */
+    MR_copy_regs_to_saved_regs(MR_check_max_mr_num, MR_check_saved_regs);
+	MR_trace_init_point_vars(layout, MR_check_saved_regs, port, MR_TRUE);
+
+    if (MR_point.MR_point_problem != NULL) {
+        MR_fatal_error(problem);
+    }
+
+    level = 0;
+    do {
+        MR_check_integrity_seq_num++;
+#if 0
+        /* enable this code if necessary for debugging */
+        sprintf(buf, "integrity check at event %d, level %d, seq %d\n",
+            MR_trace_event_number, level, MR_check_integrity_seq_num);
+#endif
+        MR_trace_report_msg = buf;
+        fprintf(stdout, "%s", buf);
+        fflush(stdout);
+        MR_trace_check_integrity_on_cur_level();
+        level++;
+        problem = MR_trace_set_level(level, MR_TRUE);
+    } while (problem == NULL);
+
+    MR_restore_transient_registers();
+    MR_saved_global_hp(MR_check_saved_regs) = MR_global_hp;
+    MR_copy_saved_regs_to_regs(MR_check_max_mr_num, MR_check_saved_regs);
+    MR_trace_report_msg = NULL;
+    MR_trace_enabled = saved_trace_enabled;
+}
+
+#endif  /* MR_TRACE_CHECK_INTEGRITY */
Index: trace/mercury_trace_vars.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_vars.h,v
retrieving revision 1.21
diff -u -b -r1.21 mercury_trace_vars.h
--- trace/mercury_trace_vars.h	15 May 2002 11:24:21 -0000	1.21
+++ trace/mercury_trace_vars.h	10 Jun 2003 05:29:14 -0000
@@ -240,4 +240,16 @@
 extern	MR_Completer_List *MR_trace_var_completer(const char *word,
 				size_t word_len);
 
+#ifdef	MR_TRACE_CHECK_INTEGRITY
+
+/*
+** Checks whether any stack frame at the current program point contains
+** references to terms with corrupted representations.
+*/
+
+extern	void		MR_trace_check_integrity(const MR_Label_Layout *layout,
+				MR_Trace_Port port);
+
+#endif	/* MR_TRACE_CHECK_INTEGRITY */
+
 #endif	/* MERCURY_TRACE_VARS_H */
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