[m-rev.] diff: fix debugger printing bug

Simon Taylor stayl at cs.mu.OZ.AU
Sun Jun 9 03:44:08 AEST 2002


Estimated hours taken: 0.5
Branches: main

trace/mercury_trace_vars.c:
	Fix a reversed test in my last change which caused a seg-fault
	in `print goal' where the goal had multiple arguments.

tests/debugger/Mmakefile:
tests/debugger/print_goal.{m,inp,exp}:
	Test case.
		
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.44
diff -u -u -r1.44 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	5 Jun 2002 16:41:31 -0000	1.44
+++ trace/mercury_trace_vars.c	8 Jun 2002 15:30:51 -0000
@@ -801,7 +801,7 @@
                 prev = MR_list_empty();
                 cur = arg_list;
                 while (!MR_list_is_empty(cur) &&
-                       headvar_num < vars[MR_list_head(cur)].MR_var_is_headvar)
+                       headvar_num > vars[MR_list_head(cur)].MR_var_is_headvar)
                 {
                     prev = cur;
                     cur = MR_list_tail(cur);
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.76
diff -u -u -r1.76 Mmakefile
--- tests/debugger/Mmakefile	9 May 2002 08:46:55 -0000	1.76
+++ tests/debugger/Mmakefile	8 Jun 2002 15:37:57 -0000
@@ -44,6 +44,7 @@
 	nondet_stack			\
 	output_term_dep			\
 	polymorphic_output		\
+	print_goal			\
 	queens_rep			\
 	resume_typeinfos		\
 	shallow				\
@@ -258,6 +259,9 @@
 output_term_dep.out: output_term_dep output_term_dep.inp
 	$(MDB) ./output_term_dep < output_term_dep.inp 2>&1 | \
 		sed 's/io.m:[0-9]*/io.m:NNNN/g' > output_term_dep.out 2>&1
+
+print_goal.out: print_goal print_goal.inp
+	$(MDB) ./print_goal < print_goal.inp > print_goal.out 2>&1
 
 queens.out: queens queens.inp
 	$(MDB) ./queens < queens.inp > queens.out 2>&1
Index: tests/debugger/print_goal.exp
===================================================================
RCS file: tests/debugger/print_goal.exp
diff -N tests/debugger/print_goal.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/print_goal.exp	8 Jun 2002 17:37:21 -0000
@@ -0,0 +1,16 @@
+       1:      1  1 CALL pred print_goal:main/2-0 (det) print_goal.m:12
+mdb> Registering debuggable procedures... done.
+There is one debuggable module, with 5 procedures.
+ 0: + stop  interface pred print_goal:big_data/1-0 (det)
+mdb>  1: + stop  interface pred print_goal:print_goal/8-0 (det)
+mdb>        2:      2  2 CALL pred print_goal:big_data/1-0 (det) print_goal.m:24 (print_goal.m:13)
+mdb> big_data('_')
+mdb>        3:      2  2 EXIT pred print_goal:big_data/1-0 (det) print_goal.m:24 (print_goal.m:13)
+mdb> big_data(big(big(big/3, 2, small), 3, big(big/3, 6, small)))
+mdb> big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big(small, 5, small)), 6, small)).
+       4:      3  2 CALL pred print_goal:print_goal/8-0 (det) print_goal.m:54 (print_goal.m:16)
+mdb> print_goal(100, 101, '_', '_', 102, '_', state('<<c_pointer>>'), '_')
+mdb>        5:      3  2 EXIT pred print_goal:print_goal/8-0 (det) print_goal.m:54 (print_goal.m:16)
+mdb> print_goal(100, 101, 102, 103, 102, 103, _, state(<<c_pointer>>))
+mdb> 103.
+103.
Index: tests/debugger/print_goal.inp
===================================================================
RCS file: tests/debugger/print_goal.inp
diff -N tests/debugger/print_goal.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/print_goal.inp	8 Jun 2002 15:39:04 -0000
@@ -0,0 +1,11 @@
+b big_data
+b print_goal
+c
+p goal
+finish
+p goal
+c
+p goal
+finish
+p goal
+c
Index: tests/debugger/print_goal.m
===================================================================
RCS file: tests/debugger/print_goal.m
diff -N tests/debugger/print_goal.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/print_goal.m	8 Jun 2002 17:32:12 -0000
@@ -0,0 +1,55 @@
+:- module print_goal.
+:- interface.
+:- import_module io.
+:- pred main(io__state::di, io__state::uo) is det.
+:- implementation.
+:- import_module int.
+
+:- type big
+	--->	big(big, int, big)
+	;	small.
+
+main -->
+	{ big_data(Data) },
+	io__print(Data),
+	io__write_string(".\n"),
+	print_goal(100, 101, _, Y, 102, Z),
+	io__print(Y),
+	io__write_string(".\n"),
+	io__print(Z),
+	io__write_string(".\n").
+
+:- pred big_data(big::out) is det.
+
+big_data(Data) :-
+	Data = big(
+		big(
+			big(
+				small,
+				1,
+				small
+			),
+			2,
+			small
+		),
+		3,
+		big(
+			big(
+				small,
+				4,
+				big(
+					small,
+					5,
+					small
+				)
+			),
+			6,
+			small
+		)
+	).
+
+:- pred print_goal(int::in, int::in, int::out, int::out, int::in, int::out,
+		io__state::di, io__state::uo) is det.
+
+print_goal(W, X, X + 1, X + 2, Y, Y + 1) --> [].
+
--------------------------------------------------------------------------
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