[m-rev.] diff: fix an abort in the debugger

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Apr 3 17:07:31 AEST 2002


Fix a bug that caused an abort at certain events in the debugger.

runtime/mercury_stack_layout.h:
	Change the name of the MR_exec_max_var_num field to
	MR_exec_max_named_var_num, as this better reflects its contents.

trace/mercury_trace_vars.c:
	If a var has a number beyond the value of MR_exec_max_named_var_num,
	do not abort; instead, ignore the variable because it is unnamed
	(and therefore of no interest to the user).

tests/debugger/queens_rep.{m,inp,exp}:
	New text case to confirm the lack of abort.

tests/debugger/Mmakefile:
	Enable the new test case.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/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_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.56
diff -u -b -r1.56 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h	2002/02/24 11:53:33	1.56
+++ runtime/mercury_stack_layout.h	2002/03/29 02:11:43
@@ -543,8 +543,10 @@
 ** Therefore using the stored offset to index into the string table
 ** is always safe.
 **
-** The max_var_num field gives the number of elements in the used_var_names
-** table.
+** The max_named_var_num field gives the number of elements in the
+** used_var_names table, which is also the number of the highest numbered
+** named variable. Note that unnamed variables may have numbers higher than
+** this.
 **
 ** The max_r_num field tells the debugger which Mercury abstract machine
 ** registers need saving in MR_trace: besides the special registers, it is
@@ -613,7 +615,7 @@
 	MR_Word			*MR_exec_proc_rep;
 	const MR_Table_Io_Decl	*MR_exec_table_io_decl;
 	const MR_int_least16_t	*MR_exec_used_var_names;
-	MR_int_least16_t	MR_exec_max_var_num;
+	MR_int_least16_t	MR_exec_max_named_var_num;
 	MR_int_least16_t	MR_exec_max_r_num;
 	MR_int_least8_t		MR_exec_maybe_from_full;
 	MR_int_least8_t		MR_exec_maybe_io_seq;
@@ -727,7 +729,7 @@
 #define	MR_sle_module_layout	MR_sle_exec_trace.MR_exec_module_layout
 #define	MR_sle_proc_rep	MR_sle_exec_trace.MR_exec_proc_rep
 #define	MR_sle_used_var_names	MR_sle_exec_trace.MR_exec_used_var_names
-#define	MR_sle_max_var_num	MR_sle_exec_trace.MR_exec_max_var_num
+#define	MR_sle_max_named_var_num MR_sle_exec_trace.MR_exec_max_named_var_num
 #define	MR_sle_max_r_num	MR_sle_exec_trace.MR_exec_max_r_num
 #define	MR_sle_maybe_from_full	MR_sle_exec_trace.MR_exec_maybe_from_full
 #define	MR_sle_maybe_io_seq	MR_sle_exec_trace.MR_exec_maybe_io_seq
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/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.71
diff -u -b -r1.71 Mmakefile
--- tests/debugger/Mmakefile	2002/03/27 05:18:54	1.71
+++ tests/debugger/Mmakefile	2002/04/03 06:59:33
@@ -44,6 +44,7 @@
 	nondet_stack			\
 	output_term_dep			\
 	polymorphic_output		\
+	queens_rep			\
 	resume_typeinfos		\
 	shallow				\
 	type_desc_test
@@ -52,6 +53,7 @@
 # the input is not a terminal.
 MLFLAGS-completion = --runtime-flags --force-readline
 
+MCFLAGS-queens_rep = --trace rep
 MCFLAGS-shallow = --trace shallow
 MCFLAGS-tabled_read = --trace-table-io
 MCFLAGS-tabled_read_decl = --trace-table-io-decl
@@ -256,6 +258,9 @@
 
 queens.out: queens queens.inp
 	$(MDB) ./queens < queens.inp > queens.out 2>&1
+
+queens_rep.out: queens_rep queens_rep.inp
+	$(MDB) ./queens_rep < queens_rep.inp > queens_rep.out 2>&1
 
 # We insert the names of entry labels into the label table only in a few grades
 # (e.g. profiling grades). The debugger's redo label is an entry label. To
Index: tests/debugger/queens_rep.exp
===================================================================
RCS file: queens_rep.exp
diff -N queens_rep.exp
--- /dev/null	Fri Dec  1 02:25:58 2000
+++ queens_rep.exp	Wed Apr  3 17:02:42 2002
@@ -0,0 +1,11 @@
+       1:      1  1 CALL pred queens_rep:main/2-0 (cc_multi) queens_rep.m:17
+mdb> echo on
+Command echo enabled.
+mdb> context none
+Contexts will not be printed.
+mdb> goto 9
+       9:      5  4 DISJ pred queens_rep:qdelete/3-0 (nondet) c2;d1;
+mdb> print
+qdelete('_', [1, 2, 3, 4, 5], '_')
+mdb> continue -n -S
+[1, 3, 5, 2, 4]
Index: tests/debugger/queens_rep.inp
===================================================================
RCS file: queens_rep.inp
diff -N queens_rep.inp
--- /dev/null	Fri Dec  1 02:25:58 2000
+++ queens_rep.inp	Wed Apr  3 16:59:54 2002
@@ -0,0 +1,5 @@
+echo on
+context none
+goto 9
+print
+continue -n -S
Index: tests/debugger/queens_rep.m
===================================================================
RCS file: queens_rep.m
diff -N queens_rep.m
--- /dev/null	Fri Dec  1 02:25:58 2000
+++ queens_rep.m	Wed Apr  3 16:59:45 2002
@@ -0,0 +1,101 @@
+:- module queens_rep.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state, io__state).
+:- mode main(di, uo) is cc_multi.
+
+:- implementation.
+
+:- import_module list, int.
+
+main -->
+	( { data(Data), queen(Data, Out) } ->
+		print_list(Out)
+	;
+		io__write_string("No solution\n")
+	).
+
+:- pred data(list(int)).
+:- mode data(out) is det.
+
+:- pred queen(list(int), list(int)).
+:- mode queen(in, out) is nondet.
+
+:- pred qperm(list(T), list(T)).
+:- mode qperm(in, out) is nondet.
+
+:- pred qdelete(T, list(T), list(T)).
+:- mode qdelete(out, in, out) is nondet.
+
+:- pred safe(list(int)).
+:- mode safe(in) is semidet.
+
+:- pred nodiag(int, int, list(int)).
+:- mode nodiag(in, in, in) is semidet.
+
+data([1,2,3,4,5]).
+
+queen(Data, Out) :-
+	qperm(Data, Out),
+	safe(Out).
+
+qperm([], []).
+qperm(L, K) :-
+	L = [_ | _], qdelete(U, L, Z),
+	K = [U|V],
+	qperm(Z, V).
+
+qdelete(A, [A|L], L).
+qdelete(X, [A|Z], [A|R]) :-
+	qdelete(X, Z, R).
+
+safe([]).
+safe([N|L]) :-
+	nodiag(N, 1, L),
+	safe(L).
+
+nodiag(_, _, []).
+nodiag(B, D, [N|L]) :-
+	NmB is N - B,
+	BmN is B - N,
+	( D = NmB ->
+		fail
+	; D = BmN ->
+		fail
+	;
+		true
+	),
+	D1 is D + 1,
+	nodiag(B, D1, L).
+
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+	(
+		{ Xs = [] }
+	->
+		io__write_string("[]\n")
+	;
+		io__write_string("["),
+		print_list_2(Xs),
+		io__write_string("]\n")
+	).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) --> 
+	io__write_int(X),
+	(
+		{ Xs = [] }
+	->
+		[]
+	;
+		io__write_string(", "),
+		print_list_2(Xs)
+	).
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/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_vars.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.40
diff -u -b -r1.40 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	2002/03/27 07:35:38	1.40
+++ trace/mercury_trace_vars.c	2002/03/29 02:10:33
@@ -415,8 +415,9 @@
 			continue;
 		}
 
-		if (var_num > entry->MR_sle_max_var_num) {
-			MR_fatal_error("array bounds error on var name table");
+		if (var_num > entry->MR_sle_max_named_var_num) {
+			/* this value is a compiler-generated variable */
+			continue;
 		}
 
 			/* variable number 1 is stored at offset 0 */
cvs diff: Diffing util
--------------------------------------------------------------------------
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