[m-rev.] For review: Trust standard library

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Nov 10 12:55:12 AEDT 2004


For review by anyone.

Estimated hours taken: 4
Branches: main

Trust modules in the Mercury standard library by default in the declarative 
debugger.

Make trusted object id's returned by `trusted' command persistent. Previously
each trusted object was identified by its position in the ordered list of
trusted objects.  This meant that if an object was removed all objects after
the removed object would have their ids decremented, so the user would have to
issue a new `trusted' command everytime they wished to remove an object to
confirm the id.  The behaviour is now consistent with the behaviour of
breakpoint ids which keep their id for the life of the breakpoint.

Fix generation of online documentation for declarative debugger mdb commands.

browser/declarative_debugger.m
	Add and export predicate to add the standard library to the set of
	trusted objects.

browser/declarative_oracle.m
	Add predicate to add the standard library to the set of trusted 
	objects.
	
	Use bimap to represent set of trusted objects along with each object's
	id (we need to look up objects both ways).
	
	Adjust comment formatting to conform to standard.

	Rename trusted_module_or_predicate type to trusted_object.  Add
	constructor for standard_library to trusted_object type.  Include
	standard library when initialising the set of trusted objects.

	Change predicates adding or removing trusted objects to use new 
	persistent object id.

	If a module belongs to the standard library and the standard library 
	is trusted then trust the module.
	
compiler/mlds.m
	Import library module since since mercury_std_library_module/1 now
	resides there.

compiler/modules.m
library/library.m
	Move definition of mercury_std_library_module/1 from modules.m to
	library.m so it can be used by the debugger.  Adjust comment 
	accordingly.

doc/generate_mdb_doc
	Generate declarative debugger commands documentation.

doc/user_guide.texi
	Document `trust std lib' command.  Move mdb declarative debugging
	commands to their own section.

tests/debugger/declarative/catch.exp2
tests/debugger/declarative/catch.exp3
tests/debugger/declarative/catch.inp2
tests/debugger/declarative/solutions.exp2
tests/debugger/declarative/solutions.inp2
	Untrust the standard library for these tests.

tests/debugger/declarative/trust.inp
tests/debugger/declarative/trust.exp
	Update test to reflect persistent trusted object ids and trusting of
	standard library.

trace/mercury_trace_declarative.c
trace/mercury_trace_declarative.h
	Add function to trust the standard library.

trace/mercury_trace_internal.c
	Allow user to trust the standard library by issuing a `trust std lib'
	command.

Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.40
diff -u -r1.40 declarative_debugger.m
--- browser/declarative_debugger.m	25 Oct 2004 05:30:17 -0000	1.40
+++ browser/declarative_debugger.m	8 Nov 2004 03:54:04 -0000
@@ -555,6 +555,17 @@
 		Oracle),
 	!:Diagnoser = !.Diagnoser ^ oracle_state := Oracle.
 
+:- pred trust_standard_library(diagnoser_state(trace_node_id)::in,
+	diagnoser_state(trace_node_id)::out) is det.
+
+:- pragma export(mdb.declarative_debugger.trust_standard_library(in, out), 
+	"MR_DD_decl_trust_standard_library").
+
+trust_standard_library(!Diagnoser) :-
+	declarative_oracle.trust_standard_library(!.Diagnoser ^ oracle_state,
+		Oracle),
+	!:Diagnoser = !.Diagnoser ^ oracle_state := Oracle.
+
 :- pred remove_trusted(int::in, diagnoser_state(trace_node_id)::in,
 	diagnoser_state(trace_node_id)::out) is semidet.
 	
Index: browser/declarative_oracle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_oracle.m,v
retrieving revision 1.27
diff -u -r1.27 declarative_oracle.m
--- browser/declarative_oracle.m	25 Oct 2004 05:30:18 -0000	1.27
+++ browser/declarative_oracle.m	9 Nov 2004 07:44:26 -0000
@@ -62,6 +62,10 @@
 :- pred add_trusted_pred_or_func(proc_layout::in, oracle_state::in, 
 	oracle_state::out) is det. 
 
+	% Trust all the modules in the Mercury standard library.
+	%
+:- pred trust_standard_library(oracle_state::in, oracle_state::out) is det.
+
 	% remove_trusted(N, !Oracle).
 	% Removes the (N-1)th trusted object from the set of trusted objects.
 	% Fails if there are fewer than N-1 trusted modules (or N < 0).
@@ -116,7 +120,8 @@
 :- import_module mdb__set_cc.
 :- import_module mdb__util.
 
-:- import_module bool, std_util, set, int.
+:- import_module map, bool, std_util, set, int, bimap, counter, assoc_list.
+:- import_module library.
 
 query_oracle(Questions, Response, Oracle0, Oracle) -->
 	{ query_oracle_list(Oracle0, Questions, Answers) },
@@ -208,51 +213,71 @@
 	).
 
 %-----------------------------------------------------------------------------%
-		
+
 :- type oracle_state
 	--->	oracle(
-			kb_current	:: oracle_kb,
 				% Current information about the intended
 				% interpretation.  These answers have been
 				% given, but have not since been revised.
+			kb_current	:: oracle_kb,
 
-			kb_revised	:: oracle_kb,
 				% Old information about the intended
 				% interpretation.  These answers were given
 				% and subsequently revised, but new answers
 				% to the questions have not yet been given.
+			kb_revised	:: oracle_kb,
 
-			user_state	:: user_state,
 				% User interface.
+			user_state	:: user_state,
 				
-			trusted :: set(trusted_module_or_predicate)
 				% Modules and predicates/functions trusted
-				% by the oracle.
+				% by the oracle. The second argument is an
+				% id used to identify an object to remove.
+			trusted		:: bimap(trusted_object, int),
+
+				% Counter to allocate ids to trusted objects
+			trusted_id_counter	:: counter
 		).
 
 oracle_state_init(InStr, OutStr, Browser, Oracle) :-
 	oracle_kb_init(Current),
 	oracle_kb_init(Old),
 	user_state_init(InStr, OutStr, Browser, User),
-	set.init(TrustedModules),
-	Oracle = oracle(Current, Old, User, TrustedModules).
+	% Trust the standard library by default.
+	bimap.set(bimap.init, standard_library, 0, Trusted),
+	counter.init(1, Counter),
+	Oracle = oracle(Current, Old, User, Trusted, Counter).
 	
 %-----------------------------------------------------------------------------%
 
-:- type trusted_module_or_predicate
-	--->	all(string) % all predicates/functions in a module
-	;	specific(
-			pred_or_func,	
+:- type trusted_object
+	--->	module(string) % all predicates/functions in a module
+	;	predicate(
 			string,		% module name
-			string,		% pred or func name
+			string,		% pred name
 			int		% arity
-		).
+		)
+	;	function(
+			string,		% module name
+			string,		% function name
+			int		% arity including return value
+		)
+	;	standard_library.
 
 add_trusted_module(ModuleName, !Oracle) :-
-	insert(!.Oracle ^ trusted, all(ModuleName), Trusted),
-	!:Oracle = !.Oracle ^ trusted := Trusted.
+	counter.allocate(Id, !.Oracle ^ trusted_id_counter, Counter),
+	(
+		bimap.insert(!.Oracle ^ trusted, module(ModuleName), Id, 
+			Trusted)
+	->
+		!:Oracle = !.Oracle ^ trusted := Trusted,
+		!:Oracle = !.Oracle ^ trusted_id_counter := Counter
+	;
+		true
+	).
 
 add_trusted_pred_or_func(ProcLayout, !Oracle) :-
+	counter.allocate(Id, !.Oracle ^ trusted_id_counter, Counter),
 	ProcId = get_proc_id_from_layout(ProcLayout),
 	(
 		ProcId = proc(ModuleName, PredOrFunc, _, Name, Arity, _)
@@ -260,71 +285,80 @@
 		ProcId = uci_proc(ModuleName, _, _, Name, Arity, _),
 		PredOrFunc = predicate
 	),
-	insert(!.Oracle ^ trusted, specific(PredOrFunc, ModuleName, Name, 
-		Arity), Trusted),
-	!:Oracle = !.Oracle ^ trusted := Trusted.
-
-remove_trusted(N, !Oracle) :-
-	TrustedList = to_sorted_list(!.Oracle ^ trusted),
-	index0(TrustedList, N, ObjectToDelete),
-	delete_all(TrustedList, ObjectToDelete, NewTrustedList),
-	!:Oracle = !.Oracle ^ trusted := sorted_list_to_set(NewTrustedList). 
-
-get_trusted_list(Oracle, CommandFormat, List) :-
-	Trusted = to_sorted_list(Oracle ^ trusted),
 	(
-		CommandFormat = yes,
-		foldl(format_trust_command, Trusted, "", List)
-	;
-		CommandFormat = no,
-		foldl(format_trust_display, Trusted, {0, "Trusted Objects:\n"}, 
-			{I, List0}),
 		(
-			I = 0
-		->
-			List = "There are no trusted modules, predicates "++
-				"or functions.\n"
+			PredOrFunc = predicate,
+			bimap.insert(!.Oracle ^ trusted, predicate(ModuleName,
+				Name, Arity), Id, Trusted)
 		;
-			List = List0
+			PredOrFunc = function,
+			bimap.insert(!.Oracle ^ trusted, function(ModuleName,
+				Name, Arity), Id, Trusted)
 		)
+	->
+		!:Oracle = !.Oracle ^ trusted := Trusted,
+		!:Oracle = !.Oracle ^ trusted_id_counter := Counter
+	;
+		true
 	).
 
-:- pred format_trust_command(trusted_module_or_predicate::in, string::in,
-	string::out) is det.
-
-format_trust_command(all(ModuleName), S, S++"trust "++ModuleName++"\n").
-format_trust_command(specific(PredOrFunc, ModuleName, Name, Arity), S, 
-		S++Command) :-
+trust_standard_library(!Oracle) :-
+	counter.allocate(Id, !.Oracle ^ trusted_id_counter, Counter),
 	(
-		PredOrFunc = predicate,
-		PredOrFuncStr = "pred*",
-		ArityStr = int_to_string(Arity)
-	;
-		PredOrFunc = function,
-		PredOrFuncStr = "func*",
-		ArityStr = int_to_string(Arity - 1)
-	),
-	Command = "trust "++PredOrFuncStr++ModuleName++"."++Name++"/"++
-		ArityStr++ "\n".
-		
-:- pred format_trust_display(trusted_module_or_predicate::in, {int,string}::in,
-	{int,string}::out) is det.
+		bimap.insert(!.Oracle ^ trusted, standard_library, Id,
+			Trusted)
+	->
+		!:Oracle = !.Oracle ^ trusted_id_counter := Counter,
+		!:Oracle = !.Oracle ^ trusted := Trusted
+	;
+		true
+	).
 
-format_trust_display(all(ModuleName), {I, S}, 
-	{I + 1, S++int_to_string(I)++": module "++ModuleName++"\n"}).
-format_trust_display(specific(PredOrFunc, ModuleName, Name, Arity), {I, S}, 
-		{I + 1, S++Display}) :-
+remove_trusted(Id, !Oracle) :-
+	bimap.search(!.Oracle ^ trusted, _, Id),
+	bimap.delete_value(Id, !.Oracle ^ trusted, Trusted),
+	!:Oracle = !.Oracle ^ trusted := Trusted. 
+
+get_trusted_list(Oracle, yes, CommandsStr) :-
+	TrustedObjects = bimap.ordinates(Oracle ^ trusted),
+	list.foldl(format_trust_command, TrustedObjects, "", CommandsStr).
+get_trusted_list(Oracle, no, DisplayStr) :-
+	IdToObjectMap = bimap.reverse_map(Oracle ^ trusted),
+	map.foldl(format_trust_display, IdToObjectMap, "", DisplayStr0),
 	(
-		PredOrFunc = predicate,
-		PredOrFuncStr = "pred",
-		ArityStr = int_to_string(Arity)
-	;
-		PredOrFunc = function,
-		PredOrFuncStr = "func",
-		ArityStr = int_to_string(Arity - 1)
-	),
-	Display = int_to_string(I)++": "++PredOrFuncStr++" "++ModuleName++"."++
-		Name++"/"++ArityStr++"\n".
+		DisplayStr0 = ""
+	->
+		DisplayStr = "There are no trusted modules, predicates "++
+			"or functions.\n"
+	;
+		DisplayStr = "Trusted Objects:\n" ++ DisplayStr0
+	).
+
+:- pred format_trust_command(trusted_object::in, string::in,
+	string::out) is det.
+
+format_trust_command(module(ModuleName), S, S++"trust "++ModuleName++"\n").
+format_trust_command(predicate(ModuleName, Name, Arity), S, S++Command) :-
+	ArityStr = int_to_string(Arity),
+	Command = "trust pred*"++ModuleName++"."++Name++"/"++ ArityStr++"\n".
+format_trust_command(function(ModuleName, Name, Arity), S, S++Command) :-
+	ArityStr = int_to_string(Arity - 1),
+	Command = "trust func*"++ModuleName++"."++Name++"/"++ ArityStr++"\n".
+format_trust_command(standard_library, S, S++"trust std lib\n").
+
+:- pred format_trust_display(int::in, trusted_object::in, string::in, 
+	string::out) is det.
+
+format_trust_display(Id, module(ModuleName), S, S++Display) :-
+	Display = int_to_string(Id)++ ": module "++ ModuleName++"\n".
+format_trust_display(Id, predicate(ModuleName, Name, Arity), S, S++Display) :-
+	Display = int_to_string(Id)++": predicate "++ModuleName++"."++
+		Name++"/"++int_to_string(Arity)++"\n".
+format_trust_display(Id, function(ModuleName, Name, Arity), S, S++Display) :-
+	Display = int_to_string(Id)++": function "++ModuleName++"."++
+		Name++"/"++int_to_string(Arity - 1)++"\n".
+format_trust_display(Id, standard_library, S, S++Display) :-
+	Display = int_to_string(Id)++": the Mercury standard library\n".
 		
 %-----------------------------------------------------------------------------%
 
@@ -441,14 +475,22 @@
 :- pred trusted(proc_layout::in, oracle_state::in) is semidet.
 
 trusted(ProcLayout, Oracle) :-
+	Trusted = Oracle ^ trusted,
 	ProcId = get_proc_id_from_layout(ProcLayout),
 	(
 		ProcId = proc(Module, PredOrFunc, _, Name, Arity, _),
 		(
-			set.member(all(Module), Oracle ^ trusted)
+			bimap.search(Trusted, standard_library, _),
+			mercury_std_library_module(Module)
+		;
+			bimap.search(Trusted, module(Module), _)
+		;
+			PredOrFunc = predicate,
+			bimap.search(Trusted, predicate(Module, Name, Arity), 
+				_)
 		;
-			set.member(specific(PredOrFunc, Module, Name, Arity),
-				Oracle ^ trusted)
+			PredOrFunc = function,
+			bimap.search(Trusted, function(Module, Name, Arity), _)
 		)
 	;
 		ProcId = uci_proc(_, _, _, _, _, _)
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.115
diff -u -r1.115 mlds.m
--- compiler/mlds.m	5 Sep 2004 23:52:25 -0000	1.115
+++ compiler/mlds.m	8 Nov 2004 01:42:06 -0000
@@ -1740,7 +1740,7 @@
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__modules.
 
-:- import_module char, int, term, string, require.
+:- import_module char, int, term, string, require, library.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.309
diff -u -r1.309 modules.m
--- compiler/modules.m	27 Oct 2004 07:41:49 -0000	1.309
+++ compiler/modules.m	7 Nov 2004 00:56:51 -0000
@@ -54,11 +54,6 @@
 	% of the modules in the standard library.
 :- pred mercury_std_library_module_name(module_name::in) is semidet.
 
-	% Succeeds iff the string is the (unqualified) name of one of the
-	% modules in the Mercury standard library.
-	%
-:- pred mercury_std_library_module(string::in) is semidet.
-
 	% module_name_to_file_name(Module, Extension, Mkdir, FileName):
 	%	Convert a module name and file extension to the
 	%	corresponding file name.  If `MkDir' is yes, then
@@ -797,80 +792,6 @@
 	mercury_std_library_module(Name).
 mercury_std_library_module_name(qualified(unqualified("mercury"), Name)) :-
 	mercury_std_library_module(Name).
-
-mercury_std_library_module("array").
-mercury_std_library_module("array2d").
-mercury_std_library_module("assoc_list").
-mercury_std_library_module("bag").
-mercury_std_library_module("benchmarking").
-mercury_std_library_module("bimap").
-mercury_std_library_module("bintree").
-mercury_std_library_module("bintree_set").
-mercury_std_library_module("bitmap").
-mercury_std_library_module("bool").
-mercury_std_library_module("bt_array").
-mercury_std_library_module("builtin").
-mercury_std_library_module("char").
-mercury_std_library_module("construct").
-mercury_std_library_module("cord").
-mercury_std_library_module("counter").
-mercury_std_library_module("deconstruct").
-mercury_std_library_module("dir").
-mercury_std_library_module("enum").
-mercury_std_library_module("eqvclass").
-mercury_std_library_module("exception").
-mercury_std_library_module("float").
-mercury_std_library_module("gc").
-mercury_std_library_module("getopt").
-mercury_std_library_module("graph").
-mercury_std_library_module("group").
-mercury_std_library_module("hash_table").
-mercury_std_library_module("int").
-mercury_std_library_module("integer").
-mercury_std_library_module("io").
-mercury_std_library_module("lexer").
-mercury_std_library_module("library").
-mercury_std_library_module("list").
-mercury_std_library_module("map").
-mercury_std_library_module("math").
-mercury_std_library_module("multi_map").
-mercury_std_library_module("ops").
-mercury_std_library_module("parser").
-mercury_std_library_module("pprint").
-mercury_std_library_module("pqueue").
-mercury_std_library_module("private_builtin").
-mercury_std_library_module("profiling_builtin").
-mercury_std_library_module("prolog").
-mercury_std_library_module("queue").
-mercury_std_library_module("random").
-mercury_std_library_module("rational").
-mercury_std_library_module("rbtree").
-mercury_std_library_module("relation").
-mercury_std_library_module("require").
-mercury_std_library_module("rtti_implementation").
-mercury_std_library_module("set").
-mercury_std_library_module("set_bbbtree").
-mercury_std_library_module("set_ordlist").
-mercury_std_library_module("set_unordlist").
-mercury_std_library_module("sparse_bitset").
-mercury_std_library_module("stack").
-mercury_std_library_module("std_util").
-mercury_std_library_module("store").
-mercury_std_library_module("string").
-mercury_std_library_module("table_builtin").
-mercury_std_library_module("term").
-mercury_std_library_module("term_io").
-mercury_std_library_module("term_size_prof_builtin").
-mercury_std_library_module("time").
-mercury_std_library_module("tree234").
-mercury_std_library_module("type_desc").
-mercury_std_library_module("varset").
-mercury_std_library_module("version_array").
-mercury_std_library_module("version_array2d").
-mercury_std_library_module("version_bitmap").
-mercury_std_library_module("version_hash_table").
-mercury_std_library_module("version_store").
-mercury_std_library_module("version_types").
 
 module_name_to_search_file_name(ModuleName, Ext, FileName, !IO) :-
 	module_name_to_file_name(ModuleName, Ext, yes, no, FileName, !IO).
Index: doc/generate_mdb_doc
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/generate_mdb_doc,v
retrieving revision 1.7
diff -u -r1.7 generate_mdb_doc
--- doc/generate_mdb_doc	6 Nov 2002 02:02:25 -0000	1.7
+++ doc/generate_mdb_doc	9 Nov 2004 04:22:03 -0000
@@ -16,11 +16,12 @@
 
 debug_cmd_path="debug debugger"
 for section in interactive forward backward browsing breakpoint \
-	i/o parameter help misc exp developer
+	i/o parameter help declarative misc exp developer
 do
 	case $section in
 		interactive)	category=queries ;;
 		i/o)		category=table_io ;;
+		declarative)	category=dd ;;
 		*)		category=$section ;;
 	esac
 	info -f ./mercury_user_guide.info -o $tmp $debug_cmd_path $section
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.396
diff -u -r1.396 user_guide.texi
--- doc/user_guide.texi	5 Nov 2004 05:39:07 -0000	1.396
+++ doc/user_guide.texi	10 Nov 2004 01:48:39 -0000
@@ -2129,6 +2129,7 @@
 * I/O tabling commands::
 * Parameter commands::
 * Help commands::
+* Declarative debugging mdb commands::
 * Miscellaneous commands::
 * Experimental commands::
 * Developer commands::
@@ -3200,6 +3201,48 @@
 @end table
 
 @sp 1
+ at node Declarative debugging mdb commands
+ at subsection Declarative debugging mdb commands
+
+ at sp 1
+ at table @code
+ at item dd
+ at c @item dd [--assume-all-io-is-tabled]
+ at c The --assume-all-io-is-tabled option is for developers only. Specifying it
+ at c makes an assertion, and if the assertion is incorrect, the resulting
+ at c behaviour would be hard for non-developers to understand. The option is
+ at c therefore deliberately not documented.
+Starts declarative debugging
+using the current event as the initial symptom.
+For details, see @ref{Declarative debugging}.
+ at sp 1
+ at item trust @var{module-name}|@var{proc-spec}
+ at kindex trust (mdb command)
+Tells the declarative debugger to trust the given module, predicate or
+function.  
+ at sp 1
+Individual predicates or functions can be trusted by just giving the
+predicate or function name.  If there is more than one predicate or function
+with the given name then a list of alternatives will be shown.  
+ at sp 1
+The entire Mercury standard library can be trusted by issuing a `trust std lib'
+command.
+ at sp 1
+See also `trusted' and `untrust'.
+ at sp 1
+ at item trusted
+ at kindex trusted (mdb command)
+Lists all the trusted modules, predicates and functions.  See also `trust'
+and `untrust'.
+ at sp 1
+ at item untrust @var{num}
+ at kindex untrust (mdb command)
+Removes the object from the list of trusted objects.  @var{num} should 
+correspond with the number shown in the list produced by issuing a `trusted'
+command.  See also `trust' and `trusted'.
+ at end table
+
+ at sp 1
 @node Experimental commands
 @subsection Experimental commands
 
@@ -3245,35 +3288,6 @@
 Saves current set of breakpoints and the current set of aliases
 in the named file as a set of @samp{break} and @samp{alias} commands.
 Sourcing the file will recreate the current breakpoints and aliases.
- at sp 1
- at item dd
- at c @item dd [--assume-all-io-is-tabled]
- at c The --assume-all-io-is-tabled option is for developers only. Specifying it
- at c makes an assertion, and if the assertion is incorrect, the resulting
- at c behaviour would be hard for non-developers to understand. The option is
- at c therefore deliberately not documented.
-Starts declarative debugging
-using the current event as the initial symptom.
-For details, see @ref{Declarative debugging}.
- at sp 1
- at item trust [@var{module-name}|@var{proc-spec}]
- at kindex trust (mdb command)
-Tells the declarative debugger to trust the given module, predicate or 
-function.  Individual predicates or functions can be trusted by just giving
-the predicate or function name.  If there is more than one predicate or 
-function with the given name then a list of alternatives will be shown.
-See also `trusted' and `untrust'.
- at sp 1
- at item trusted
- at kindex trusted (mdb command)
-Lists all the trusted modules, predicates and functions.  See also `trust'
-and `untrust'.
- at sp 1
- at item untrust @var{num}
- at kindex untrust (mdb command)
-Removes the object from the list of trusted objects.  @var{num} should 
-correspond with the number shown the the list produced by issuing a `trusted'
-command.  See also `trust' and `trusted'.
 @sp 1
 @item quit [-y]
 @kindex quit (mdb command)
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.74
diff -u -r1.74 library.m
--- library/library.m	27 Sep 2004 00:44:43 -0000	1.74
+++ library/library.m	8 Nov 2004 02:48:33 -0000
@@ -18,14 +18,18 @@
 
 :- pred library__version(string::out) is det.
 
+	% Succeeds iff the string is the (unqualified) name of one of the
+	% modules in the Mercury standard library.
+	%
+:- pred mercury_std_library_module(string::in) is semidet.
+
 %---------------------------------------------------------------------------%
 
 :- implementation.
 
-% Note: if you add a new module to this list, you must also a new clause
-% to mercury_std_library_module/1 in compiler/modules.m. Conversely, this
-% should list all the modules named by mercury_std_library_module, except
-% library itself.
+% Note: if you add a new module to this list, you must also a new clause to
+% mercury_std_library_module/1. Conversely, this should list all the modules
+% named by mercury_std_library_module, except library itself.
 %
 % Please keep both parts of this list in alphabetical order.
 
@@ -139,6 +143,82 @@
 	Version = mercury.runtime.Constants.MR_VERSION + "" configured for ""
 			+ mercury.runtime.Constants.MR_FULLARCH;
 ").
+
+%---------------------------------------------------------------------------%
+
+mercury_std_library_module("array").
+mercury_std_library_module("array2d").
+mercury_std_library_module("assoc_list").
+mercury_std_library_module("bag").
+mercury_std_library_module("benchmarking").
+mercury_std_library_module("bimap").
+mercury_std_library_module("bintree").
+mercury_std_library_module("bintree_set").
+mercury_std_library_module("bitmap").
+mercury_std_library_module("bool").
+mercury_std_library_module("bt_array").
+mercury_std_library_module("builtin").
+mercury_std_library_module("char").
+mercury_std_library_module("construct").
+mercury_std_library_module("cord").
+mercury_std_library_module("counter").
+mercury_std_library_module("deconstruct").
+mercury_std_library_module("dir").
+mercury_std_library_module("enum").
+mercury_std_library_module("eqvclass").
+mercury_std_library_module("exception").
+mercury_std_library_module("float").
+mercury_std_library_module("gc").
+mercury_std_library_module("getopt").
+mercury_std_library_module("graph").
+mercury_std_library_module("group").
+mercury_std_library_module("hash_table").
+mercury_std_library_module("int").
+mercury_std_library_module("integer").
+mercury_std_library_module("io").
+mercury_std_library_module("lexer").
+mercury_std_library_module("library").
+mercury_std_library_module("list").
+mercury_std_library_module("map").
+mercury_std_library_module("math").
+mercury_std_library_module("multi_map").
+mercury_std_library_module("ops").
+mercury_std_library_module("parser").
+mercury_std_library_module("pprint").
+mercury_std_library_module("pqueue").
+mercury_std_library_module("private_builtin").
+mercury_std_library_module("profiling_builtin").
+mercury_std_library_module("prolog").
+mercury_std_library_module("queue").
+mercury_std_library_module("random").
+mercury_std_library_module("rational").
+mercury_std_library_module("rbtree").
+mercury_std_library_module("relation").
+mercury_std_library_module("require").
+mercury_std_library_module("rtti_implementation").
+mercury_std_library_module("set").
+mercury_std_library_module("set_bbbtree").
+mercury_std_library_module("set_ordlist").
+mercury_std_library_module("set_unordlist").
+mercury_std_library_module("sparse_bitset").
+mercury_std_library_module("stack").
+mercury_std_library_module("std_util").
+mercury_std_library_module("store").
+mercury_std_library_module("string").
+mercury_std_library_module("table_builtin").
+mercury_std_library_module("term").
+mercury_std_library_module("term_io").
+mercury_std_library_module("term_size_prof_builtin").
+mercury_std_library_module("time").
+mercury_std_library_module("tree234").
+mercury_std_library_module("type_desc").
+mercury_std_library_module("varset").
+mercury_std_library_module("version_array").
+mercury_std_library_module("version_array2d").
+mercury_std_library_module("version_bitmap").
+mercury_std_library_module("version_hash_table").
+mercury_std_library_module("version_store").
+mercury_std_library_module("version_types").
 
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%
Index: tests/debugger/declarative/catch.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/catch.exp2,v
retrieving revision 1.5
diff -u -r1.5 catch.exp2
--- tests/debugger/declarative/catch.exp2	24 Jul 2003 08:08:21 -0000	1.5
+++ tests/debugger/declarative/catch.exp2	9 Nov 2004 06:51:48 -0000
@@ -2,6 +2,7 @@
 mdb> echo on
 Command echo enabled.
 mdb> register --quiet
+mdb> untrust 0
 mdb> break p
  0: + stop  interface pred catch.p/2-0 (cc_multi)
 mdb> continue
Index: tests/debugger/declarative/catch.exp3
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/catch.exp3,v
retrieving revision 1.1
diff -u -r1.1 catch.exp3
--- tests/debugger/declarative/catch.exp3	18 Mar 2003 16:38:47 -0000	1.1
+++ tests/debugger/declarative/catch.exp3	9 Nov 2004 06:52:17 -0000
@@ -2,6 +2,7 @@
 mdb> echo on
 Command echo enabled.
 mdb> register --quiet
+mdb> untrust 0
 mdb> break p
  0: + stop  interface pred catch.p/2-0 (cc_multi)
 mdb> continue
Index: tests/debugger/declarative/catch.inp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/catch.inp2,v
retrieving revision 1.1
diff -u -r1.1 catch.inp2
--- tests/debugger/declarative/catch.inp2	10 Oct 2002 05:59:03 -0000	1.1
+++ tests/debugger/declarative/catch.inp2	9 Nov 2004 06:43:06 -0000
@@ -1,5 +1,6 @@
 echo on
 register --quiet
+untrust 0
 break p
 continue
 finish
Index: tests/debugger/declarative/solutions.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/solutions.exp2,v
retrieving revision 1.5
diff -u -r1.5 solutions.exp2
--- tests/debugger/declarative/solutions.exp2	10 Feb 2003 11:59:23 -0000	1.5
+++ tests/debugger/declarative/solutions.exp2	9 Nov 2004 06:56:14 -0000
@@ -2,6 +2,7 @@
 mdb> echo on
 Command echo enabled.
 mdb> register --quiet
+mdb> untrust 0
 mdb> break p
  0: + stop  interface pred solutions.p/2-0 (det)
 mdb> continue
Index: tests/debugger/declarative/solutions.inp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/solutions.inp2,v
retrieving revision 1.3
diff -u -r1.3 solutions.inp2
--- tests/debugger/declarative/solutions.inp2	10 Feb 2003 11:59:23 -0000	1.3
+++ tests/debugger/declarative/solutions.inp2	9 Nov 2004 06:45:01 -0000
@@ -1,5 +1,6 @@
 echo on
 register --quiet
+untrust 0
 break p
 continue
 finish
Index: tests/debugger/declarative/trust.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/trust.exp,v
retrieving revision 1.3
diff -u -r1.3 trust.exp
--- tests/debugger/declarative/trust.exp	20 Sep 2004 04:50:25 -0000	1.3
+++ tests/debugger/declarative/trust.exp	9 Nov 2004 08:01:21 -0000
@@ -1,5 +1,5 @@
       E1:     C1  1 CALL pred trust.main/2-0 (cc_multi) trust.m:13
-mdb> mdb> Contexts will not be printed.
+mdb> mdb> mdb> Contexts will not be printed.
 mdb> echo on
 Command echo enabled.
 mdb> trust trust_1.
@@ -12,13 +12,13 @@
 Trusting pred trust_1.w_cmp/3
 mdb> trusted
 Trusted Objects:
-0: pred trust_1.IntroducedFrom__pred__w_cmp__15__1/3
-1: pred trust_1.w_cmp/3
-mdb> untrust 1
+1: predicate trust_1.IntroducedFrom__pred__w_cmp__15__1/3
+2: predicate trust_1.w_cmp/3
+mdb> untrust 2
 mdb> trusted
 Trusted Objects:
-0: pred trust_1.IntroducedFrom__pred__w_cmp__15__1/3
-mdb> untrust 0
+1: predicate trust_1.IntroducedFrom__pred__w_cmp__15__1/3
+mdb> untrust 1
 mdb> trusted
 There are no trusted modules, predicates or functions.
 mdb> trust trust_2
@@ -32,15 +32,15 @@
 Trusting pred trust.main/2
 mdb> trusted
 Trusted Objects:
-0: module trust_2
-1: pred trust.main/2
+3: module trust_2
+4: predicate trust.main/2
 mdb> trust trust_2
 Trusting module trust_2
 mdb> trusted
 Trusted Objects:
-0: module trust_2
-1: pred trust.main/2
-mdb> untrust 0
+3: module trust_2
+4: predicate trust.main/2
+mdb> untrust 3
 mdb> trust trust_1
 Trusting module trust_1
 mdb> trust no_such_module
@@ -49,14 +49,16 @@
 Trusting pred trust_2.concat/3
 mdb> trusted
 Trusted Objects:
-0: module trust_1
-1: pred trust.main/2
-2: pred trust_2.concat/3
-mdb> untrust 1
+4: predicate trust.main/2
+5: module trust_1
+6: predicate trust_2.concat/3
+mdb> untrust 4
 mdb> trusted
 Trusted Objects:
-0: module trust_1
-1: pred trust_2.concat/3
+5: module trust_1
+6: predicate trust_2.concat/3
+mdb> untrust 4
+mdb: no such trusted object
 mdb> untrust 99
 mdb: no such trusted object
 mdb> step
Index: tests/debugger/declarative/trust.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/trust.inp,v
retrieving revision 1.2
diff -u -r1.2 trust.inp
--- tests/debugger/declarative/trust.inp	20 Sep 2004 04:50:25 -0000	1.2
+++ tests/debugger/declarative/trust.inp	9 Nov 2004 07:56:48 -0000
@@ -1,12 +1,13 @@
 register --quiet
+untrust 0
 context none
 echo on
 trust trust_1.
 *
 trusted
-untrust 1
+untrust 2
 trusted
-untrust 0
+untrust 1
 trusted
 trust trust_2
 trust trust.
@@ -14,13 +15,14 @@
 trusted
 trust trust_2
 trusted
-untrust 0
+untrust 3
 trust trust_1
 trust no_such_module
 trust trust_2.
 trusted
-untrust 1
+untrust 4
 trusted
+untrust 4
 untrust 99
 step
 finish
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.72
diff -u -r1.72 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c	25 Oct 2004 05:30:19 -0000	1.72
+++ trace/mercury_trace_declarative.c	8 Nov 2004 04:05:23 -0000
@@ -1045,6 +1045,17 @@
 	);
 }
 
+void
+MR_decl_trust_standard_library(void)
+{
+	MR_trace_decl_ensure_init();
+	MR_TRACE_CALL_MERCURY(
+		MR_DD_decl_trust_standard_library(
+			MR_trace_front_end_state,
+			&MR_trace_front_end_state);
+	);
+}
+
 MR_bool
 MR_decl_remove_trusted(int n)
 {
Index: trace/mercury_trace_declarative.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.h,v
retrieving revision 1.18
diff -u -r1.18 mercury_trace_declarative.h
--- trace/mercury_trace_declarative.h	20 Sep 2004 04:50:25 -0000	1.18
+++ trace/mercury_trace_declarative.h	8 Nov 2004 04:05:43 -0000
@@ -58,6 +58,7 @@
 
 extern	void	MR_decl_add_trusted_module(const char *module_name);
 extern	void	MR_decl_add_trusted_pred_or_func(const MR_Proc_Layout *entry);
+extern	void	MR_decl_trust_standard_library(void);
 extern	MR_bool	MR_decl_remove_trusted(int n);
 
 /*
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.178
diff -u -r1.178 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	20 Sep 2004 04:50:25 -0000	1.178
+++ trace/mercury_trace_internal.c	9 Nov 2004 07:40:30 -0000
@@ -5487,6 +5487,10 @@
 				}
 			}
 		}
+	} else if (word_count == 3 && MR_streq(words[1], "std") &&
+			MR_streq(words[2], "lib")) {
+		MR_decl_trust_standard_library();
+		fprintf(MR_mdb_out, "Trusting the Mercury standard library\n");
 	} else {
 		MR_trace_usage("dd", "trust");
 	}
--------------------------------------------------------------------------
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