[m-dev.] for review: enable declarative debugging by default

Mark Anthony BROWN dougl at cs.mu.OZ.AU
Mon May 31 18:47:33 AEST 1999


Estimated hours taken: 4

Make declarative debugging enabled by default.

configure.in:
	Turn the decl-debug feature on by default.

tests/debugger/declarative:
	New directory containing tests for the declarative debugger.

tests/debugger/declarative/*.m:
tests/debugger/declarative/*.inp:
tests/debugger/declarative/*.exp:
	Declarative debugger test cases.

tests/debugger/declarative/Mmakefile:
	Mmakefile to do the declarative debugger tests.

tests/debugger/Mmakefile:
	For each target, make the corresponding target in the
	'declarative' subdirectory.

Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.171
diff -u -r1.171 configure.in
--- configure.in	1999/05/27 10:20:13	1.171
+++ configure.in	1999/05/31 04:53:39
@@ -1570,12 +1570,12 @@
 AC_SUBST(LIBGRADES)
 #-----------------------------------------------------------------------------#
 #
-# Add an option that enables declarative debugging support in the internal
-# debugger.  It is disabled by default.
+# Add an option that disables declarative debugging support in the internal
+# debugger.  It is enabled by default.
 #
 AC_ARG_ENABLE(decl-debug,
-[  --enable-decl-debug     enable the declarative debugger],
-mercury_cv_enable_decl_debug="$enableval",mercury_cv_enable_decl_debug=no)
+[  --disable-decl-debug    disable the declarative debugger],
+mercury_cv_enable_decl_debug="$enableval",mercury_cv_enable_decl_debug=yes)
 if test "$mercury_cv_enable_decl_debug" = "yes"; then
 	AC_DEFINE(MR_USE_DECLARATIVE_DEBUGGER)
 fi
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.24
diff -u -r1.24 Mmakefile
--- Mmakefile	1999/05/14 02:25:25	1.24
+++ Mmakefile	1999/05/31 06:33:38
@@ -136,12 +136,27 @@
 
 #-----------------------------------------------------------------------------#
 
+SUBDIR_MMAKE = mmake $(MMAKEFLAGS) \
+			GRADE='$(GRADE)' \
+			EXTRA_CFLAGS='$(EXTRA_CFLAGS)' \
+			EXTRA_MCFLAGS='$(EXTRA_MCFLAGS)'
+
 dep:		$(DEPS)
+		cd declarative && $(SUBDIR_MMAKE) dep || exit 1;
 
 depend:		$(DEPENDS)
+		cd declarative && $(SUBDIR_MMAKE) depend || exit 1;
 
 check:		$(OUTS) $(RESS)
+		cd declarative && $(SUBDIR_MMAKE) check || exit 1;
 
 all:		$(PROGS)
+		cd declarative && $(SUBDIR_MMAKE) all || exit 1;
+
+clean:
+		cd declarative && $(SUBDIR_MMAKE) clean || exit 1;
+
+realclean:
+		cd declarative && $(SUBDIR_MMAKE) realclean || exit 1;
 
 #-----------------------------------------------------------------------------#


New file tests/debugger/declarative/Mmakefile:

#-----------------------------------------------------------------------------#

main_target:	check

include ../../Mmake.common

RM_C=:

#-----------------------------------------------------------------------------#

# We suppress the printing of the banner, because different workspaces
# may get different version numbers printed in it. This would otherwise be
# the source of irrelevant difference between the actual and expected outputs.

MDB = MERCURY_SUPPRESS_MDB_BANNER=yes mdb

#-----------------------------------------------------------------------------#

DECLARATIVE_PROGS= 		\
	app 			\
	gcf			\
	if_then_else		\
	propositional		\
	queens

MCFLAGS = --trace deep --trace-decl
MLFLAGS = --trace
C2INITFLAGS = --trace

# Base grades `jump' and `fast' cannot be used with
# stack layouts (which are required for tracing).

ifneq "$(findstring asm_,$(GRADE))" ""
    PROGS=$(DECLARATIVE_PROGS)
else
    ifneq "$(findstring jump,$(GRADE))" ""
	PROGS=
    else
	ifneq "$(findstring fast,$(GRADE))" ""
	    PROGS=
	else
	    PROGS=$(DECLARATIVE_PROGS)
	endif
    endif
endif

#-----------------------------------------------------------------------------#

propositional.out: propositional propositional.inp
	$(MDB) ./propositional < propositional.inp > propositional.out 2>&1

app.out: app app.inp
	$(MDB) ./app < app.inp > app.out 2>&1

gcf.out: gcf gcf.inp
	$(MDB) ./gcf < gcf.inp > gcf.out 2>&1

if_then_else.out: if_then_else if_then_else.inp
	$(MDB) ./if_then_else < if_then_else.inp > if_then_else.out 2>&1

queens.out: queens queens.inp
	$(MDB) ./queens < queens.inp > queens.out 2>&1

#-----------------------------------------------------------------------------#

DEPS=		$(PROGS:%=$(deps_subdir)%.dep)
DEPENDS=	$(PROGS:%=%.depend)
OUTS=		$(PROGS:%=%.out)
RESS=		$(PROGS:%=%.res)

#-----------------------------------------------------------------------------#

dep:		$(DEPS)

depend:		$(DEPENDS)

check:		$(OUTS) $(RESS)

all:		$(PROGS)

#-----------------------------------------------------------------------------#


New file tests/debugger/declarative/app.exp:

       1:      1  1 CALL pred app:main/2-0 (det) 
mdb> echo on
Command echo enabled.
mdb> goto 19
      19:      2  2 EXIT pred app:app/3-0 (det) 
mdb> dd_wrong
app([1, 2, 3, 4, 5], [6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8], int)
Valid? y
Bug not found.
      19:      2  2 EXIT pred app:app/3-0 (det) 
mdb> dd_wrong
app([1, 2, 3, 4, 5], [6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8], int)
Valid? n
app([2, 3, 4, 5], [6, 7, 8], [2, 3, 4, 5, 6, 7, 8], int)
Valid? n
app([3, 4, 5], [6, 7, 8], [3, 4, 5, 6, 7, 8], int)
Valid? n
app([4, 5], [6, 7, 8], [4, 5, 6, 7, 8], int)
Valid? n
app([5], [6, 7, 8], [5, 6, 7, 8], int)
Valid? n
app([], [6, 7, 8], [6, 7, 8], int)
Valid? n
Incorrect instance found:

app([], [6, 7, 8], [6, 7, 8], int).

      19:      2  2 EXIT pred app:app/3-0 (det) 
mdb> goto 67
append([1, 2, 3, 4, 5], [6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8]).
      67:      8  2 EXIT pred app:app/3-0 (det) 
mdb> dd_wrong
app([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8], int)
Valid? n
app([2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8], int)
Valid? n
app([3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8], int)
Valid? n
app([4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8], int)
Valid? y
Incorrect instance found:

app([3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8], int) :-
	app([4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8], int).

      67:      8  2 EXIT pred app:app/3-0 (det) 
mdb> continue -a
append([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8]).
      68:      1  1 EXIT pred app:main/2-0 (det) 


New file tests/debugger/declarative/app.inp:

echo on
goto 19
dd_wrong
y
dd_wrong
n
n
n
n
n
n
goto 67
dd_wrong
n
n
n
y
continue -a



New file tests/debugger/declarative/app.m:

:- module app.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module list.

:- type foo(T) ---> append(T, T, T).

main -->
	{ A = [1, 2, 3, 4, 5] },
	{ B = [6, 7, 8] },
	{ app(A, B, C) },
	io__write(app__append(A, B, C)),
	io__write_string(".\n"),
	{ D = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5] },
	{ E = [6, 7, 8] },
	{ app(D, E, F) },
	io__write(app__append(D, E, F)),
	io__write_string(".\n").


:- pred app(list(T), list(T), list(T)).
:- mode app(in, in, out) is det.

app([], Bs, Bs).
app(A.As, Bs, A.Cs) :-
	app(As, Bs, Cs).


New file tests/debugger/declarative/gcf.exp:

       1:      1  1 CALL pred gcf:main/2-0 (cc_multi) 
mdb> echo on
Command echo enabled.
mdb> goto 22
      22:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> dd_wrong
a(11)
Valid? y
Bug not found.
      22:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> dd_wrong
a(11)
Valid? n
f(11)
Valid? n
Incorrect instance found:

f(11).

      22:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> goto 29
      29:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> dd_wrong
a(12)
Valid? n
f(12)
Valid? y
c(2, 12)
Valid? y
g(2)
Valid? n
Incorrect instance found:

g(2).

      29:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> goto 41
      41:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> dd_wrong
a(20)
Valid? n
f(20)
Valid? y
c(3, 20)
Valid? y
g(3)
Valid? y
Incorrect instance found:

a(20) :-
	g(3),
	c(3, 20),
	f(20).

      41:      2  2 EXIT pred gcf:a/1-0 (nondet) 
mdb> c
yes(20)


New file tests/debugger/declarative/gcf.inp:

echo on
goto 22
dd_wrong
y
dd_wrong
n
n
goto 29
dd_wrong
n
y
y
n
goto 41
dd_wrong
n
y
y
y
c


New file tests/debugger/declarative/gcf.m:

:- module gcf.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is cc_multi.
:- implementation.
:- import_module std_util, int.

main -->
	{
		a(X),
		X > 15
	->
		R = yes(X)
	;
		R = no
	},
	io__write(R),
	io__nl.


:- pred a(int::out) is nondet.
:- pred g(int::out) is multi.
:- pred c(int::in, int::out) is nondet.
:- pred f(int::in) is semidet.

a(X) :-
	g(Y),
	c(Y, X),
	f(X).

g(1).
g(2).
g(3).
g(4).

c(2, 10).
c(2, 11).
c(2, 12).
c(3, 20).

f(X) :-
	X > 10.


New file tests/debugger/declarative/if_then_else.exp:

       1:      1  1 CALL pred if_then_else:main/2-0 (det) 
mdb> echo on
Command echo enabled.
mdb> goto 8
       8:      2  2 EXIT pred if_then_else:ite/2-0 (det) 
mdb> dd_wrong
ite(0, 1)
Valid? n
b(1)
Valid? y
a(0)
Valid? y
Incorrect instance found:

ite(0, 1) :-
	a(0),
	b(1).

       8:      2  2 EXIT pred if_then_else:ite/2-0 (det) 
mdb> dd_wrong
ite(0, 1)
Valid? n
b(1)
Valid? n
Incorrect instance found:

b(1).

       8:      2  2 EXIT pred if_then_else:ite/2-0 (det) 
mdb> goto 15
ite(0, 1).
      15:      5  2 EXIT pred if_then_else:ite/2-0 (det) 
mdb> dd_wrong
ite(1, 0)
Valid? n
a(0)
Valid? y
Incorrect instance found:

ite(1, 0) :-
	a(0).

      15:      5  2 EXIT pred if_then_else:ite/2-0 (det) 
mdb> c
ite(1, 0).


New file tests/debugger/declarative/if_then_else.inp:

echo on
goto 8
dd_wrong
n
y
y
dd_wrong
n
n
goto 15
dd_wrong
n
y
c


New file tests/debugger/declarative/if_then_else.m:

:- module if_then_else.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.

main -->
	{ ite(0, X) },
	io__write_string("ite(0, "),
	io__write_int(X),
	io__write_string(").\n"),
	{ ite(1, Y) },
	io__write_string("ite(1, "),
	io__write_int(Y),
	io__write_string(").\n").

:- pred ite(int::in, int::out) is det.

ite(A, B) :-
	( a(A) ->
		b(B)
	;
		a(B)
	).

:- pred a(int).
:- mode a(in) is semidet.
:- mode a(out) is det.

a(0).

:- pred b(int).
:- mode b(out) is det.

b(1).


New file tests/debugger/declarative/propositional.exp:

       1:      1  1 CALL pred propositional:main/2-0 (det) 
mdb> echo on
Command echo enabled.
mdb> goto 10
      10:      2  2 EXIT pred propositional:a/0-0 (semidet) 
mdb> dd_wrong
a
Valid? n
c
Valid? y
Incorrect instance found:

a :-
	c.

      10:      2  2 EXIT pred propositional:a/0-0 (semidet) 
mdb> goto 21
      21:      5  2 EXIT pred propositional:b/0-0 (semidet) 
mdb> dd_wrong
b
Valid? n
f
Valid? n
i
Valid? y
Incorrect instance found:

f :-
	i.

      21:      5  2 EXIT pred propositional:b/0-0 (semidet) 
mdb> c
yes


New file tests/debugger/declarative/propositional.inp:

echo on
goto 10
dd_wrong
n
y
goto 21
dd_wrong
n
n
y
c


New file tests/debugger/declarative/propositional.m:

:- module propositional.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module std_util.

main -->
	(
		{ a, b }
	->
		io__write_string("yes\n")
	;
		io__write_string("no\n")
	).

:- pred a is semidet.
:- pred b is semidet.
:- pred c is semidet.
:- pred d is semidet.
:- pred e is semidet.
:- pred f is semidet.
:- pred g is semidet.
:- pred h is semidet.
:- pred i is semidet.

a :- e.
a :- c.
b :- f.
b :- g.
c :- semidet_succeed.
c :- d.
d :- semidet_succeed.
e :- semidet_fail.
f :- h.
f :- i.
g :- semidet_succeed.
h :- semidet_fail.
i :- semidet_succeed.


New file tests/debugger/declarative/queens.exp:

       1:      1  1 CALL pred queens:main/2-0 (cc_multi) 
mdb> echo on
Command echo enabled.
mdb> dd_wrong
mdb: wrong answer analysis is only available from EXIT events.
mdb> goto 6
       6:      4  3 SWTC pred queens:qperm/2-0 (nondet) s1;
mdb> dd_wrong
mdb: wrong answer analysis is only available from EXIT events.
mdb> goto 8
       8:      5  4 DISJ pred queens:qdelete/3-0 (nondet) c2;d1;
mdb> dd_wrong
mdb: wrong answer analysis is only available from EXIT events.
mdb> goto 43
      43:     16  4 FAIL pred queens:nodiag/3-0 (semidet) 
mdb> dd_wrong
mdb: wrong answer analysis is only available from EXIT events.
mdb> goto 673
     673:      3  2 EXIT pred queens:queen/2-0 (nondet) 
mdb> dd_wrong
queen([1, 2, 3, 4, 5], [1, 3, 5, 2, 4])
Valid? n
safe([1, 3, 5, 2, 4])
Valid? n
safe([3, 5, 2, 4])
Valid? n
safe([5, 2, 4])
Valid? n
safe([2, 4])
Valid? n
safe([4])
Valid? n
safe([])
Valid? n
Incorrect instance found:

safe([]).

     673:      3  2 EXIT pred queens:queen/2-0 (nondet) 
mdb> dd_wrong
queen([1, 2, 3, 4, 5], [1, 3, 5, 2, 4])
Valid? n
safe([1, 3, 5, 2, 4])
Valid? n
safe([3, 5, 2, 4])
Valid? n
safe([5, 2, 4])
Valid? n
safe([2, 4])
Valid? n
safe([4])
Valid? y
nodiag(2, 1, [4])
Valid? y
Incorrect instance found:

safe([2, 4]) :-
	nodiag(2, 1, [4]),
	safe([4]).

     673:      3  2 EXIT pred queens:queen/2-0 (nondet) 
mdb> dd_wrong
queen([1, 2, 3, 4, 5], [1, 3, 5, 2, 4])
Valid? n
safe([1, 3, 5, 2, 4])
Valid? n
safe([3, 5, 2, 4])
Valid? y
nodiag(1, 1, [3, 5, 2, 4])
Valid? n
nodiag(1, 2, [5, 2, 4])
Valid? n
nodiag(1, 3, [2, 4])
Valid? y
Incorrect instance found:

nodiag(1, 2, [5, 2, 4]) :-
	nodiag(1, 3, [2, 4]).

     673:      3  2 EXIT pred queens:queen/2-0 (nondet) 
mdb> dd_wrong
queen([1, 2, 3, 4, 5], [1, 3, 5, 2, 4])
Valid? n
safe([1, 3, 5, 2, 4])
Valid? n
safe([3, 5, 2, 4])
Valid? y
nodiag(1, 1, [3, 5, 2, 4])
Valid? y
Incorrect instance found:

safe([1, 3, 5, 2, 4]) :-
	nodiag(1, 1, [3, 5, 2, 4]),
	safe([3, 5, 2, 4]).

     673:      3  2 EXIT pred queens:queen/2-0 (nondet) 
mdb> continue -a
     674:      1  1 THEN pred queens:main/2-0 (cc_multi) t;
     675:    141  2 CALL pred queens:print_list/3-0 (det) 
     676:    141  2 ELSE pred queens:print_list/3-0 (det) e;
[     677:    142  3 CALL pred queens:print_list_2/3-0 (det) 
     678:    142  3 SWTC pred queens:print_list_2/3-0 (det) s1;
1     679:    142  3 ELSE pred queens:print_list_2/3-0 (det) s1;c3;e;
,      680:    143  4 CALL pred queens:print_list_2/3-0 (det) 
     681:    143  4 SWTC pred queens:print_list_2/3-0 (det) s1;
3     682:    143  4 ELSE pred queens:print_list_2/3-0 (det) s1;c3;e;
,      683:    144  5 CALL pred queens:print_list_2/3-0 (det) 
     684:    144  5 SWTC pred queens:print_list_2/3-0 (det) s1;
5     685:    144  5 ELSE pred queens:print_list_2/3-0 (det) s1;c3;e;
,      686:    145  6 CALL pred queens:print_list_2/3-0 (det) 
     687:    145  6 SWTC pred queens:print_list_2/3-0 (det) s1;
2     688:    145  6 ELSE pred queens:print_list_2/3-0 (det) s1;c3;e;
,      689:    146  7 CALL pred queens:print_list_2/3-0 (det) 
     690:    146  7 SWTC pred queens:print_list_2/3-0 (det) s1;
4     691:    146  7 THEN pred queens:print_list_2/3-0 (det) s1;c3;t;
     692:    146  7 EXIT pred queens:print_list_2/3-0 (det) 
     693:    145  6 EXIT pred queens:print_list_2/3-0 (det) 
     694:    144  5 EXIT pred queens:print_list_2/3-0 (det) 
     695:    143  4 EXIT pred queens:print_list_2/3-0 (det) 
     696:    142  3 EXIT pred queens:print_list_2/3-0 (det) 
]
     697:    141  2 EXIT pred queens:print_list/3-0 (det) 
     698:      1  1 EXIT pred queens:main/2-0 (cc_multi) 


New file tests/debugger/declarative/queens.inp:

echo on
dd_wrong
goto 6
dd_wrong
goto 8
dd_wrong
goto 43
dd_wrong
goto 673
dd_wrong
n
n
n
n
n
n
n
dd_wrong
n
n
n
n
n
y
y
dd_wrong
n
n
y
n
n
y
dd_wrong
n
n
y
y
continue -a


New file tests/debugger/declarative/queens.m is exactly the same as
tests/debugger/queens.m.


-- 
Mark Brown  (dougl at cs.mu.oz.au)       )O+   |  For Microsoft to win,
PhD student,                                |  the customer must lose
Dept of Computer Science, Melbourne Uni     |          -- Eric S. Raymond
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list