[m-rev.] diff: better error messages for minimal model tabling

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Nov 25 16:40:01 AEDT 2005


Provide better error messages when minimal model code cannot be evaluated
due to the limits of our current program transformation technique.

runtime/mercury_stacks.[ch]:
	Add an extra argument, a string, to MR_pneg_enter_else.
	If MR_pneg_enter_else has to abort, print this string first.

compiler/ite_gen.m:
	When generating the wrappers around possibly negated contexts,
	add an argument to MR_pneg_enter_else that gives the current context.

library/std_util.m:
	Add the argument to a hand-written call to MR_pneg_enter_else.

tests/.mgnuc_opts:
	New file that turns off the searching of the standard (i.e. the
	installed) directories for header files. It is needed because
	without it, gcc would find the old, no-argument MR_pneg_enter_else
	declaration in the installed mercury_stacks.h.

	This is ok because the already existing .mgnuc_copts file tells
	gcc to look for header files in the relevant stage directories.

tools/bootcheck:
	Copt tests/.mgnuc_opts to the various test directories.

tests/tabling/consumer_in_solutions.exp:
	Update the expected output of this test case.

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
Index: compiler/ite_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.84
diff -u -b -r1.84 ite_gen.m
--- compiler/ite_gen.m	17 Nov 2005 15:57:18 -0000	1.84
+++ compiler/ite_gen.m	23 Nov 2005 07:46:05 -0000
@@ -51,6 +51,7 @@
 :- import_module parse_tree.prog_data.
 
 :- import_module bool.
+:- import_module int.
 :- import_module list.
 :- import_module map.
 :- import_module require.
@@ -61,8 +62,8 @@
 
 %---------------------------------------------------------------------------%
 
-generate_ite(AddTrailOps, CodeModel, CondGoal0, ThenGoal,
-        ElseGoal, IteGoalInfo, Code, !CI) :-
+generate_ite(AddTrailOps, CodeModel, CondGoal0, ThenGoal, ElseGoal,
+        IteGoalInfo, Code, !CI) :-
     CondGoal0 = CondExpr - CondInfo0,
     goal_info_get_code_model(CondInfo0, CondCodeModel),
     (
@@ -191,7 +192,7 @@
     EndLabelCode = node([
         label(EndLabel) - "end of if-then-else"
     ]),
-    make_pneg_context_wrappers(Globals, PNegCondCode, PNegThenCode,
+    make_pneg_context_wrappers(Globals, CondInfo, PNegCondCode, PNegThenCode,
         PNegElseCode),
     Code = tree_list([
         FlushCode,
@@ -340,8 +341,8 @@
         % The call to reset_ticket(..., commit) here is necessary
         % in order to properly detect floundering.
         code_info__maybe_release_hp(MaybeHpSlot, !CI),
-        code_info__maybe_reset_prune_and_release_ticket(
-            MaybeTicketSlot, commit, PruneTicketCode, !CI),
+        code_info__maybe_reset_prune_and_release_ticket(MaybeTicketSlot,
+            commit, PruneTicketCode, !CI),
         trace__maybe_generate_negated_event_code(Goal, NotGoalInfo,
             neg_failure, FailTraceCode, !CI),
         code_info__generate_failure(FailCode, !CI),
@@ -363,8 +364,8 @@
     trace__maybe_generate_negated_event_code(Goal, NotGoalInfo,
         neg_success, SuccessTraceCode, !CI),
 
-    make_pneg_context_wrappers(Globals, PNegCondCode, PNegThenCode,
-        PNegElseCode),
+    make_pneg_context_wrappers(Globals, NotGoalInfo, PNegCondCode,
+        PNegThenCode, PNegElseCode),
     Code = tree_list([
         FlushCode,
         PrepareHijackCode,
@@ -400,15 +401,26 @@
     % contexts or not, which is why we wrap the condition inside
     % MR_pneg_enter_{cond,then,exit}.
     %
-:- pred make_pneg_context_wrappers(globals::in, code_tree::out, code_tree::out,
-    code_tree::out) is det.
+:- pred make_pneg_context_wrappers(globals::in, hlds_goal_info::in,
+    code_tree::out, code_tree::out, code_tree::out) is det.
 
-make_pneg_context_wrappers(Globals, PNegCondCode, PNegThenCode, PNegElseCode)
-        :-
+make_pneg_context_wrappers(Globals, GoalInfo, PNegCondCode, PNegThenCode,
+        PNegElseCode) :-
     globals__lookup_bool_option(Globals, use_minimal_model_stack_copy_pneg,
         UseMinimalModelStackCopyPNeg),
     (
         UseMinimalModelStackCopyPNeg = yes,
+        goal_info_get_context(GoalInfo, Context),
+        term__context_file(Context, File),
+        term__context_line(Context, Line),
+        (
+            File \= "",
+            Line > 0
+        ->
+            CtxtStr = "\"" ++ File ++ ":" ++ int_to_string(Line) ++ "\""
+        ;
+            CtxtStr = "NULL"
+        ),
 
         PNegCondComponents = [
             pragma_c_raw_code(
@@ -422,7 +434,7 @@
         ],
         PNegElseComponents = [
             pragma_c_raw_code(
-                wrap_transient("\t\tMR_pneg_enter_else();\n"),
+                wrap_transient("\t\tMR_pneg_enter_else(" ++ CtxtStr ++ ");\n"),
                 cannot_branch_away, live_lvals_info(set__init))
         ],
         PNegCondCode = node([
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
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/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
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/gears
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/moose/tests
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/solver_types
cvs diff: Diffing extras/solver_types/library
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/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/std_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.303
diff -u -b -r1.303 std_util.m
--- library/std_util.m	17 Oct 2005 11:35:20 -0000	1.303
+++ library/std_util.m	25 Nov 2005 05:16:47 -0000
@@ -1366,7 +1366,7 @@
     [will_not_call_mercury, thread_safe],
 "
 #ifdef MR_USE_MINIMAL_MODEL_STACK_COPY
-    MR_pneg_enter_else();
+    MR_pneg_enter_else(""end_all_soln_neg_context"");
 #endif
 ").
 
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_stacks.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stacks.c,v
retrieving revision 1.16
diff -u -b -r1.16 mercury_stacks.c
--- runtime/mercury_stacks.c	13 Sep 2005 08:25:39 -0000	1.16
+++ runtime/mercury_stacks.c	24 Nov 2005 04:29:25 -0000
@@ -1,4 +1,7 @@
 /*
+** vim: ts=4 sw=4 expandtab
+*/
+/*
 ** Copyright (C) 1998-2001, 2003-2005 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -76,14 +79,10 @@
 
 	fp = MR_checked_fopen(MR_STACK_FRAME_STATS, "open", "a");
 
-	MR_convert_dword_to_double(MR_det_frame_count,
-		det_frame_count);
-	MR_convert_dword_to_double(MR_det_frame_total_size,
-		det_frame_total_size);
-	MR_convert_dword_to_double(MR_non_frame_count,
-		non_frame_count);
-	MR_convert_dword_to_double(MR_non_frame_total_size,
-		non_frame_total_size);
+    MR_convert_dword_to_double(MR_det_frame_count, det_frame_count);
+    MR_convert_dword_to_double(MR_det_frame_total_size, det_frame_total_size);
+    MR_convert_dword_to_double(MR_non_frame_count, non_frame_count);
+    MR_convert_dword_to_double(MR_non_frame_total_size, non_frame_total_size);
 
 	fprintf(fp, "number of det stack frames created:  %.0f\n",
 		det_frame_count);
@@ -92,8 +91,7 @@
 	fprintf(fp, "average size of a det stack frame:   %.3f\n",
 		det_frame_total_size / det_frame_count);
 	fprintf(fp, "max size of det stack:               %ld\n",
-		(long) (MR_det_frame_max
-		       - MR_CONTEXT(MR_ctxt_detstack_zone)->min));
+        (long) (MR_det_frame_max - MR_CONTEXT(MR_ctxt_detstack_zone)->min));
 	fprintf(fp, "\n");
 
 	fprintf(fp, "number of non stack frames created:  %.0f\n",
@@ -103,8 +101,7 @@
 	fprintf(fp, "average size of a non stack frame:   %.3f\n",
 		non_frame_total_size / non_frame_count);
 	fprintf(fp, "max size of non stack:               %ld\n",
-		(long) (MR_non_frame_max
-			- MR_CONTEXT(MR_ctxt_nondetstack_zone)->min));
+        (long) (MR_non_frame_max - MR_CONTEXT(MR_ctxt_nondetstack_zone)->min));
 	fprintf(fp, "-------------------------------------------\n");
 
 	MR_checked_fclose(fp, MR_STACK_FRAME_STATS);
@@ -372,8 +369,7 @@
 				"MR_cut_stack[MR_cut_next].gen_next %ld\n",
 				(long) MR_gen_next,
 				(long) MR_cut_next,
-				(long) MR_cut_stack[MR_cut_next].
-					MR_cut_gen_next);
+                (long) MR_cut_stack[MR_cut_next].MR_cut_gen_next);
 			MR_fatal_error("GEN_NEXT ASSERTION FAILURE");
 		}
 	}
@@ -411,10 +407,8 @@
 
 #ifdef	MR_TABLE_DEBUG
 	if (MR_tabledebug) {
-		printf("registering generator %p -> %s "
-			"at commit stack level %d\n",
-			subgoal, MR_subgoal_addr_name(subgoal),
-			MR_cut_next - 1);
+        printf("registering generator %p -> %s at commit stack level %d\n",
+            subgoal, MR_subgoal_addr_name(subgoal), MR_cut_next - 1);
 	}
 #endif
 }
@@ -427,8 +421,7 @@
 #ifdef	MR_TABLE_DEBUG
 		if (MR_tabledebug) {
 			printf("no cleanup: generator %p -> %s is complete\n",
-				subgoal->MR_sg_back_ptr,
-				MR_subgoal_addr_name(subgoal));
+                subgoal->MR_sg_back_ptr, MR_subgoal_addr_name(subgoal));
 		}
 #endif
 	} else {
@@ -438,8 +431,7 @@
 #ifdef	MR_TABLE_DEBUG
 		if (MR_tabledebug) {
 			printf("cleanup: generator %p -> %s deleted\n",
-				subgoal->MR_sg_back_ptr,
-				MR_subgoal_addr_name(subgoal));
+                subgoal->MR_sg_back_ptr, MR_subgoal_addr_name(subgoal));
 		}
 #endif
 
@@ -453,8 +445,7 @@
 #ifdef	MR_TABLE_DEBUG
 			if (MR_tabledebug) {
 				printf("cleanup: consumer %s is deleted",
-					MR_consumer_addr_name(
-						consumer_list->MR_cl_item));
+                    MR_consumer_addr_name(consumer_list->MR_cl_item));
 			}
 #endif
 
@@ -507,8 +498,7 @@
 			} else {
 				subgoal_debug = MR_lookup_subgoal_debug_addr(
 					gen_list->MR_cut_generator_ptr);
-				fprintf(fp, " <%s>",
-					MR_subgoal_debug_name(subgoal_debug));
+                fprintf(fp, " <%s>", MR_subgoal_debug_name(subgoal_debug));
 			}
 
 			gen_list = gen_list->MR_cut_next_generator;
@@ -575,8 +565,7 @@
 
 #ifdef	MR_TABLE_DEBUG
 	if (MR_tabledebug) {
-		printf("pneg stack down up to %ld (then)\n",
-			(long) MR_pneg_next);
+        printf("pneg stack down up to %ld (then)\n", (long) MR_pneg_next);
 	}
 #endif
 
@@ -591,7 +580,7 @@
 }
 
 void
-MR_pneg_enter_else(void)
+MR_pneg_enter_else(const char *context)
 {
 	MR_PNegConsumerList	l;
 	MR_PNegConsumerList	next;
@@ -607,8 +596,7 @@
 
 #ifdef	MR_TABLE_DEBUG
 	if (MR_tabledebug) {
-		printf("pneg stack down up to %ld (else)\n",
-			(long) MR_pneg_next);
+        printf("pneg stack down up to %ld (else)\n", (long) MR_pneg_next);
 	}
 #endif
 
@@ -620,14 +608,33 @@
 		next = l->MR_pneg_next_consumer;
 		consumer = l->MR_pneg_consumer_ptr;
 		if (consumer->MR_cns_subgoal == NULL) {
-			/* this consumer has logically been deleted */
+            /* This consumer has logically been deleted. */
 			continue;
 		}
 
 		subgoal = consumer->MR_cns_subgoal;
 		if (subgoal->MR_sg_status != MR_SUBGOAL_COMPLETE) {
-			MR_fatal_error("failing out of negated context "
-				"with incomplete consumer");
+            const char  *msg;
+            int         len;
+            char        *buf;
+
+            msg = "failing out of negated context with incomplete consumer";
+            if (context != NULL) {
+                /*
+                ** The 10 accounts for the ": ", the final '\0',
+                ** and leaves some space to spare.
+                */
+                len = strlen(context) + strlen(msg) + 10;
+                buf = malloc(len);
+                if (buf != NULL) {
+                    snprintf(buf, len, "%s: %s", context, msg);
+                    MR_fatal_error(buf);
+                } else {
+                    MR_fatal_error(msg);
+                }
+            } else {
+                MR_fatal_error(msg);
+            }
 		}
 
 		MR_table_free(l);
@@ -679,8 +686,7 @@
 			l = l->MR_pneg_next_consumer, n++)
 		{
 			consumer = l->MR_pneg_consumer_ptr;
-			fprintf(fp, " <%d: %s>",
-				n, MR_consumer_addr_name(consumer));
+            fprintf(fp, " <%d: %s>", n, MR_consumer_addr_name(consumer));
 		}
 	}
 
Index: runtime/mercury_stacks.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stacks.h,v
retrieving revision 1.52
diff -u -b -r1.52 mercury_stacks.h
--- runtime/mercury_stacks.h	14 Sep 2005 01:29:21 -0000	1.52
+++ runtime/mercury_stacks.h	23 Nov 2005 13:56:16 -0000
@@ -679,7 +679,7 @@
 extern  void                MR_register_suspension(MR_Consumer *consumer);
 extern  void                MR_pneg_enter_cond(void);
 extern  void                MR_pneg_enter_then(void);
-extern  void                MR_pneg_enter_else(void);
+extern  void                MR_pneg_enter_else(const char *context);
 
 extern  void                MR_print_pneg_stack(FILE *fp);
 extern  void                MR_print_any_pneg_stack(FILE *fp,
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 slice
cvs diff: Diffing tests
Index: tests/.mgnuc_opts
===================================================================
RCS file: tests/.mgnuc_opts
diff -N tests/.mgnuc_opts
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/.mgnuc_opts	25 Nov 2005 03:14:35 -0000
@@ -0,0 +1 @@
+--no-mercury-stdlib-dir
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
Index: tests/tabling/consumer_in_solutions.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/tabling/consumer_in_solutions.exp,v
retrieving revision 1.2
diff -u -b -r1.2 consumer_in_solutions.exp
--- tests/tabling/consumer_in_solutions.exp	20 Mar 2004 05:51:35 -0000	1.2
+++ tests/tabling/consumer_in_solutions.exp	25 Nov 2005 05:17:34 -0000
@@ -1 +1 @@
-Mercury runtime: failing out of negated context with incomplete consumer
+Mercury runtime: end_all_soln_neg_context: failing out of negated context with incomplete consumer
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.176
diff -u -b -r1.176 bootcheck
--- tools/bootcheck	13 Sep 2005 08:25:44 -0000	1.176
+++ tools/bootcheck	25 Nov 2005 03:14:17 -0000
@@ -1506,6 +1506,7 @@
         for d in $all_test_dirs
         do
             cp ${tests_prefix}tests/.mgnuc_copts ${tests_prefix}tests/$d
+            cp ${tests_prefix}tests/.mgnuc_opts ${tests_prefix}tests/$d
         done
 
         WORKSPACE_FLAGS=yes
cvs diff: Diffing trace
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