[m-rev.] for review: fix a sanity check in the declarative debugger
Ian MacLarty
maclarty at cs.mu.OZ.AU
Tue Jun 14 11:32:21 AEST 2005
For review by anyone.
Estimated hours taken: 1
Branches: main
Tell the declarative debugger that private_builtin predicates don't generate
any events. When a program is compiled in a .decldebug grade the
declarative debugger performs a sanity check when doing subterm dependency
tracking. It checks that each interface event matches up to the correct
atomic goal in the procedure body. This sanity check was failing when
a call to a predicate from private_builtin was encountered, since such calls
don't generate any events.
compiler/prog_util.m:
mdbcomp/prim_data.m:
Move the definition of any_mercury_builtin_module and all related predicates
from compiler/prog_util.m to mdbcomp/prim_data.m, so that this code can be
shared by the compiler and the debugger.
compiler/simplify.m:
Call mercury_public_builtin_module in mdbcomp/priv_data.
mdbcomp/program_representation.m:
Call any_mercury_builtin_module when determining if a predicate call
should be treated as a primitive or not.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/priv_builtin_bug.exp:
tests/debugger/declarative/priv_builtin_bug.inp:
tests/debugger/declarative/priv_builtin_bug.m:
Add a regression test. Previously this test would result in the
following exception being thrown:
"match_atomic_goal_to_contour_event: name mismatch on call".
The test should only be run in .decldebug grades, since this is
the only time the sanity check is done (in other grades some
events are allowed to be missing).
Index: compiler/prog_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_util.m,v
retrieving revision 1.76
diff -u -r1.76 prog_util.m
--- compiler/prog_util.m 14 Apr 2005 06:51:01 -0000 1.76
+++ compiler/prog_util.m 9 Jun 2005 05:09:02 -0000
@@ -23,68 +23,6 @@
%-----------------------------------------------------------------------------%
- % Returns the name of the module containing public builtins;
- % originally this was "mercury_builtin", but it later became
- % just "builtin", and it may eventually be renamed "std:builtin".
- % This module is automatically imported, as if via `import_module'.
-
-:- pred mercury_public_builtin_module(sym_name::out) is det.
-:- func mercury_public_builtin_module = sym_name.
-
- % Returns the name of the module containing private builtins;
- % traditionally this was "mercury_builtin", but it later became
- % "private_builtin", and it may eventually be renamed
- % "std:private_builtin".
- % This module is automatically imported, as if via `use_module'.
-
-:- pred mercury_private_builtin_module(sym_name::out) is det.
-:- func mercury_private_builtin_module = sym_name.
-
- % Returns the name of the module containing builtins for tabling;
- % originally these were in "private_builtin", but they
- % may soon be moved into a separate module.
- % This module is automatically imported iff tabling is enabled.
-
-:- pred mercury_table_builtin_module(sym_name::out) is det.
-:- func mercury_table_builtin_module = sym_name.
-
- % Returns the name of the module containing the builtins for
- % deep profiling.
- % This module is automatically imported iff deep profiling is
- % enabled.
-:- pred mercury_profiling_builtin_module(sym_name::out) is det.
-:- func mercury_profiling_builtin_module = sym_name.
-
- % Returns the name of the module containing the builtins for
- % term size profiling.
- % This module is automatically imported iff term size profiling is
- % enabled.
-:- pred mercury_term_size_prof_builtin_module(sym_name::out) is det.
-:- func mercury_term_size_prof_builtin_module = sym_name.
-
- % Returns the name of the module containing the public builtins
- % used by the Aditi transaction interface, currently "aditi".
- % This module is not automatically imported (XXX should it be?).
-
-:- pred aditi_public_builtin_module(sym_name::out) is det.
-:- func aditi_public_builtin_module = sym_name.
-
- % Returns the name of the module containing the private builtins
- % used by the Aditi transaction interface, currently
- % "aditi_private_builtin".
- % This module is automatically imported iff the Aditi interface
- % is enabled.
-
-:- pred aditi_private_builtin_module(sym_name::out) is det.
-:- func aditi_private_builtin_module = sym_name.
-
- % Succeeds iff the specified module is one of the
- % builtin modules listed above which are automatically imported.
-
-:- pred any_mercury_builtin_module(sym_name::in) is semidet.
-
-%-----------------------------------------------------------------------------%
-
% Given a symbol name, return its unqualified name.
:- pred unqualify_name(sym_name::in, string::out) is det.
@@ -298,34 +236,6 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-
-% We may eventually want to put the standard library into a package "std":
-% mercury_public_builtin_module = qualified(unqualified("std"), "builtin").
-% mercury_private_builtin_module(M) =
-% qualified(unqualified("std"), "private_builtin"))).
-mercury_public_builtin_module = unqualified("builtin").
-mercury_public_builtin_module(mercury_public_builtin_module).
-mercury_private_builtin_module = unqualified("private_builtin").
-mercury_private_builtin_module(mercury_private_builtin_module).
-mercury_table_builtin_module = unqualified("table_builtin").
-mercury_table_builtin_module(mercury_table_builtin_module).
-mercury_profiling_builtin_module = unqualified("profiling_builtin").
-mercury_profiling_builtin_module(mercury_profiling_builtin_module).
-mercury_term_size_prof_builtin_module = unqualified("term_size_prof_builtin").
-mercury_term_size_prof_builtin_module(mercury_term_size_prof_builtin_module).
-aditi_public_builtin_module = unqualified("aditi").
-aditi_public_builtin_module(aditi_public_builtin_module).
-aditi_private_builtin_module = unqualified("aditi_private_builtin").
-aditi_private_builtin_module(aditi_private_builtin_module).
-
-any_mercury_builtin_module(Module) :-
- ( mercury_public_builtin_module(Module)
- ; mercury_private_builtin_module(Module)
- ; mercury_table_builtin_module(Module)
- ; mercury_profiling_builtin_module(Module)
- ; mercury_term_size_prof_builtin_module(Module)
- ; aditi_private_builtin_module(Module)
- ).
unqualify_name(unqualified(PredName), PredName).
unqualify_name(qualified(_ModuleName, PredName), PredName).
Index: mdbcomp/prim_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/mdbcomp/prim_data.m,v
retrieving revision 1.4
diff -u -r1.4 prim_data.m
--- mdbcomp/prim_data.m 18 Feb 2005 04:05:34 -0000 1.4
+++ mdbcomp/prim_data.m 9 Jun 2005 06:12:21 -0000
@@ -144,6 +144,66 @@
:- pred insert_module_qualifier(string::in, sym_name::in, sym_name::out)
is det.
+ % Returns the name of the module containing public builtins;
+ % originally this was "mercury_builtin", but it later became
+ % just "builtin", and it may eventually be renamed "std:builtin".
+ % This module is automatically imported, as if via `import_module'.
+
+:- pred mercury_public_builtin_module(sym_name::out) is det.
+:- func mercury_public_builtin_module = sym_name.
+
+ % Returns the name of the module containing private builtins;
+ % traditionally this was "mercury_builtin", but it later became
+ % "private_builtin", and it may eventually be renamed
+ % "std:private_builtin".
+ % This module is automatically imported, as if via `use_module'.
+
+:- pred mercury_private_builtin_module(sym_name::out) is det.
+:- func mercury_private_builtin_module = sym_name.
+
+ % Returns the name of the module containing builtins for tabling;
+ % originally these were in "private_builtin", but they
+ % may soon be moved into a separate module.
+ % This module is automatically imported iff tabling is enabled.
+
+:- pred mercury_table_builtin_module(sym_name::out) is det.
+:- func mercury_table_builtin_module = sym_name.
+
+ % Returns the name of the module containing the builtins for
+ % deep profiling.
+ % This module is automatically imported iff deep profiling is
+ % enabled.
+:- pred mercury_profiling_builtin_module(sym_name::out) is det.
+:- func mercury_profiling_builtin_module = sym_name.
+
+ % Returns the name of the module containing the builtins for
+ % term size profiling.
+ % This module is automatically imported iff term size profiling is
+ % enabled.
+:- pred mercury_term_size_prof_builtin_module(sym_name::out) is det.
+:- func mercury_term_size_prof_builtin_module = sym_name.
+
+ % Returns the name of the module containing the public builtins
+ % used by the Aditi transaction interface, currently "aditi".
+ % This module is not automatically imported (XXX should it be?).
+
+:- pred aditi_public_builtin_module(sym_name::out) is det.
+:- func aditi_public_builtin_module = sym_name.
+
+ % Returns the name of the module containing the private builtins
+ % used by the Aditi transaction interface, currently
+ % "aditi_private_builtin".
+ % This module is automatically imported iff the Aditi interface
+ % is enabled.
+
+:- pred aditi_private_builtin_module(sym_name::out) is det.
+:- func aditi_private_builtin_module = sym_name.
+
+ % Succeeds iff the specified module is one of the
+ % builtin modules listed above which are automatically imported.
+
+:- pred any_mercury_builtin_module(sym_name::in) is semidet.
+
%-----------------------------------------------------------------------------%
:- implementation.
@@ -201,4 +261,32 @@
special_pred_name_arity(index, "index", 2).
special_pred_name_arity(compare, "compare", 3).
special_pred_name_arity(initialise, "initialise", 1).
+
+% We may eventually want to put the standard library into a package "std":
+% mercury_public_builtin_module = qualified(unqualified("std"), "builtin").
+% mercury_private_builtin_module(M) =
+% qualified(unqualified("std"), "private_builtin"))).
+mercury_public_builtin_module = unqualified("builtin").
+mercury_public_builtin_module(mercury_public_builtin_module).
+mercury_private_builtin_module = unqualified("private_builtin").
+mercury_private_builtin_module(mercury_private_builtin_module).
+mercury_table_builtin_module = unqualified("table_builtin").
+mercury_table_builtin_module(mercury_table_builtin_module).
+mercury_profiling_builtin_module = unqualified("profiling_builtin").
+mercury_profiling_builtin_module(mercury_profiling_builtin_module).
+mercury_term_size_prof_builtin_module = unqualified("term_size_prof_builtin").
+mercury_term_size_prof_builtin_module(mercury_term_size_prof_builtin_module).
+aditi_public_builtin_module = unqualified("aditi").
+aditi_public_builtin_module(aditi_public_builtin_module).
+aditi_private_builtin_module = unqualified("aditi_private_builtin").
+aditi_private_builtin_module(aditi_private_builtin_module).
+
+any_mercury_builtin_module(Module) :-
+ ( mercury_public_builtin_module(Module)
+ ; mercury_private_builtin_module(Module)
+ ; mercury_table_builtin_module(Module)
+ ; mercury_profiling_builtin_module(Module)
+ ; mercury_term_size_prof_builtin_module(Module)
+ ; aditi_private_builtin_module(Module)
+ ).
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.141
diff -u -r1.141 simplify.m
--- compiler/simplify.m 31 May 2005 06:55:31 -0000 1.141
+++ compiler/simplify.m 9 Jun 2005 05:14:51 -0000
@@ -1169,7 +1169,7 @@
% Construct the call to compare/3.
%
- prog_util__mercury_public_builtin_module(BuiltinModule),
+ mercury_public_builtin_module(BuiltinModule),
hlds_goal__goal_info_get_context(GoalInfo, Context),
Args = [TI, R, X, Y],
Index: mdbcomp/program_representation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/mdbcomp/program_representation.m,v
retrieving revision 1.5
diff -u -r1.5 program_representation.m
--- mdbcomp/program_representation.m 12 Apr 2005 01:53:56 -0000 1.5
+++ mdbcomp/program_representation.m 9 Jun 2005 06:16:29 -0000
@@ -285,7 +285,12 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module string, char, require.
+
+:- import_module char.
+:- import_module require.
+:- import_module string.
+
+:- import_module mdbcomp.prim_data.
atomic_goal_generates_event(unify_construct_rep(_, _, _)) = no.
atomic_goal_generates_event(unify_deconstruct_rep(_, _, _)) = no.
@@ -306,14 +311,8 @@
call_is_primitive(ModuleName, PredName) :-
(
- ModuleName = "builtin",
- ( PredName = "unify"
- ; PredName = "compare"
- )
- ;
- ModuleName = "profiling_builtin"
- ;
- ModuleName = "term_size_prof_builtin"
+ string_to_sym_name(ModuleName, ".", SymModuleName),
+ any_mercury_builtin_module(SymModuleName)
;
%
% The following are also treated as primitive since
Index: tests/debugger/declarative/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/Mmakefile,v
retrieving revision 1.76
diff -u -r1.76 Mmakefile
--- tests/debugger/declarative/Mmakefile 20 May 2005 07:14:35 -0000 1.76
+++ tests/debugger/declarative/Mmakefile 14 Jun 2005 01:13:29 -0000
@@ -76,7 +76,8 @@
#
DECLDEBUG_DECLARATIVE_PROGS= \
builtin_call_rep \
- sort
+ sort \
+ priv_builtin_bug
# The following should not be run in decldebug grades.
#
@@ -378,6 +379,11 @@
pd.out: pd pd.inp
$(MDB) ./pd < pd.inp > pd.out 2>&1 \
+ || { grep . $@ /dev/null; exit 1; }
+
+priv_builtin_bug.out: priv_builtin_bug priv_builtin_bug.inp
+ $(MDB_STD) ./priv_builtin_bug < priv_builtin_bug.inp > \
+ priv_builtin_bug.out 2>&1 \
|| { grep . $@ /dev/null; exit 1; }
propositional.out: propositional propositional.inp
Index: tests/debugger/declarative/priv_builtin_bug.exp
===================================================================
RCS file: tests/debugger/declarative/priv_builtin_bug.exp
diff -N tests/debugger/declarative/priv_builtin_bug.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/priv_builtin_bug.exp 14 Jun 2005 01:11:09 -0000
@@ -0,0 +1,23 @@
+ E1: C1 CALL pred priv_builtin_bug.main/2-0 (det) priv_builtin_bug.m:13
+mdb> mdb> I/O tabling started.
+mdb> echo on
+Command echo enabled.
+mdb> break p
+ 0: + stop interface pred priv_builtin_bug.p/2-0 (det)
+mdb> c
+ E2: C2 CALL pred priv_builtin_bug.p/2-0 (det) priv_builtin_bug.m:32 (priv_builtin_bug.m:25)
+mdb> f
+ E3: C2 EXIT pred priv_builtin_bug.p/2-0 (det) priv_builtin_bug.m:32 (priv_builtin_bug.m:25)
+mdb> dd
+p(2, 2)
+Valid? b 1
+browser> mark
+2
+q(1, 2)
+Valid? n
+Found inadmissible call:
+Parent q(1, _)
+Call p(2, _)
+Is this a bug? y
+ E4: C3 EXIT pred priv_builtin_bug.q/2-0 (det) priv_builtin_bug.m:26 (priv_builtin_bug.m:14)
+mdb> quit -y
Index: tests/debugger/declarative/priv_builtin_bug.inp
===================================================================
RCS file: tests/debugger/declarative/priv_builtin_bug.inp
diff -N tests/debugger/declarative/priv_builtin_bug.inp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/priv_builtin_bug.inp 14 Jun 2005 01:09:28 -0000
@@ -0,0 +1,12 @@
+register --quiet
+table_io start
+echo on
+break p
+c
+f
+dd
+b 1
+mark
+n
+y
+quit -y
Index: tests/debugger/declarative/priv_builtin_bug.m
===================================================================
RCS file: tests/debugger/declarative/priv_builtin_bug.m
diff -N tests/debugger/declarative/priv_builtin_bug.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/priv_builtin_bug.m 14 Jun 2005 01:03:01 -0000
@@ -0,0 +1,32 @@
+:- module priv_builtin_bug.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+main(!IO) :-
+ q(1, X),
+ io.write_int(X, !IO),
+ io.nl(!IO).
+
+:- pred q(int::in, int::out) is det.
+
+q(X, Y) :-
+ ( if
+ private_builtin.builtin_unify_int(X, 1),
+ Z1 = 2
+ then
+ p(Z1, Y)
+ else
+ Y = 2
+ ).
+
+:- pred p(int::in, int::out) is det.
+
+p(X, X).
--------------------------------------------------------------------------
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