[m-dev.] For review interactive queries for the external debugger

Erwan Jahier Erwan.Jahier at irisa.fr
Thu Apr 22 05:04:31 AEST 1999


| Apart from those mostly minor issues, that change looks great.
| I would like to see a relative diff after you've addressed the
| above issues.

Thanks for the review.

I have abstracted out a little bit the code in Opium-M/source/
interactive_queries.op and take your suggestions into account.

Here is the new log message and the relative diff:

--------------------------
Estimated hours taken: 10

This change allows interactive queries to be typed from the external debugger.

browser/debugger_interface.m:
	Define new debugger requests: query/1, cc_query/1, io_query/1 and
	mmc_options/1.

	Define 2 new procedures that are used in trace/mercury_trace_external.c:
	get_list_modules_to_import/3 retrieves from a *query/1 request a list 
	of modules to be imported; and get_mmc_options/2 retrieves from a 
	mmc_options/1 request the option to pass to mmc to compile the query. 

browser/interactive_query.m:
	Define a new procedure query_external/7 that does the same job as 
	query/7 but for the external debugger.

	Unset the environment variable `MERCURY_OPTIONS' before compiling a
	query; `MERCURY_OPTIONS' is exported before executing a program under
	the control of Opium-M (and mdb) and is not supposed to be set before
	compiling a program.

trace/mercury_trace_browse.ch:
	Add a new function MR_trace_query_external() to interface the
	ML_query_external() function defined by browser/interfactive_query.m.

trace/mercury_trace_external.c:
	Add code to implement new commands `query', `cc_query', `io_query',
	and `mmc_options', using the MR_trace_query_external() function defined 
	by trace/mercury_trace_browse.h.

trace/mercury_trace_external.h:
	Export MR_debugger_socket_in and MR_debugger_socket_out since there
	are needed in interactive_query.m.

doc/user_guide.texi:
	Add a comment to tell that there exists duplicated documentation betwenn
	Opium-M/source/interactive_queries.op and doc/user_guide.texi and to 
	tell me to update it if someone update the documentation here.

Index: mercury_trace_external.c
--- 0.3/mercury_trace_external.c Wed, 21 Apr 1999 20:12:58 +0200 jahier (iq/1_mercury_tr 1.1 640)
+++ 0.3(w)/mercury_trace_external.c Wed, 21 Apr 1999 20:35:21 +0200 jahier (iq/1_mercury_tr 1.1 640)
@@ -74,8 +74,8 @@
 				 = 14,/* wait for a cc interactive query      */
 	MR_REQUEST_INTERACTIVE_QUERY_IO	 
 				 = 15,/* wait for a io interactive query      */
-	MR_REQUEST_MMC_OPTIONS	 = 16 /* import modules for interactive 
-					 queries			      */
+	MR_REQUEST_MMC_OPTIONS	 = 16 /* pass down new options to compile
+					 queries with			      */
 
 } MR_debugger_request_type;
 
@@ -126,7 +126,7 @@
 			const MR_Stack_Layout_Entry *entry_layout, int count, 
 			int start_level, Word *base_sp, Word *base_curfr);
 static void	MR_get_list_modules_to_import(Word debugger_request, 
-			Integer *modules_list_card_ptr, Word *modules_list_ptr);
+			Integer *modules_list_length_ptr, Word *modules_list_ptr);
 static void	MR_get_mmc_options(Word debugger_request, 
 			String *mmc_options_ptr);
 
@@ -388,7 +388,7 @@
 	MR_Trace_Port	port = event_info->MR_trace_port;
 	const char 	*path = event_info->MR_event_path;
 	Word		*saved_regs = event_info->MR_saved_regs;
-	Integer		modules_list_card;
+	Integer		modules_list_length;
 	Word		modules_list;
 
 /* 
@@ -562,10 +562,10 @@
 						"_NORMAL\n");
 				}
 				MR_get_list_modules_to_import(
-					debugger_request, &modules_list_card,
+					debugger_request, &modules_list_length,
 					&modules_list);
 				MR_trace_query_external(MR_NORMAL_QUERY, 
-					MR_mmc_options, modules_list_card, 
+					MR_mmc_options, modules_list_length, 
 					modules_list);
 				break;
 
@@ -575,10 +575,10 @@
 						"REQUEST_INTERACTIVE_QUERY_IO\n");
 				}
 				MR_get_list_modules_to_import(
-					debugger_request, &modules_list_card,
+					debugger_request, &modules_list_length,
 					&modules_list);
 				MR_trace_query_external(MR_IO_QUERY, 
-					MR_mmc_options, modules_list_card, 
+					MR_mmc_options, modules_list_length, 
 					modules_list);
 				break;
 
@@ -588,10 +588,10 @@
 						"REQUEST_INTERACTIVE_QUERY_CC\n");
 				}
 				MR_get_list_modules_to_import(
-					debugger_request, &modules_list_card,
+					debugger_request, &modules_list_length,
 					&modules_list);
 				MR_trace_query_external(MR_CC_QUERY, 
-					MR_mmc_options, modules_list_card, 
+					MR_mmc_options, modules_list_length, 
 					modules_list);
 				break;
 
@@ -1133,12 +1133,12 @@
 
 static void
 MR_get_list_modules_to_import(Word debugger_request, 
-	Integer *modules_list_card_ptr, Word *modules_list_ptr)
+	Integer *modules_list_length_ptr, Word *modules_list_ptr)
 {
 	MR_TRACE_CALL_MERCURY(
 		ML_DI_get_list_modules_to_import(
 			debugger_request, 
-			modules_list_card_ptr, 
+			modules_list_length_ptr, 
 			modules_list_ptr);
 		);
 }
Index: debugger_interface.m
--- 0.3/debugger_interface.m Wed, 21 Apr 1999 20:12:58 +0200 jahier (iq/5_debugger_i 1.1 640)
+++ 0.3(w)/debugger_interface.m Wed, 21 Apr 1999 20:36:09 +0200 jahier (iq/5_debugger_i 1.1 640)
@@ -530,25 +530,23 @@
 :- pragma export(get_list_modules_to_import(in, out, out),
 		"ML_DI_get_list_modules_to_import").
 
-get_list_modules_to_import(DebuggerRequest, CardList, ModulesList) :-
+get_list_modules_to_import(DebuggerRequest, ListLength, ModulesList) :-
 	(
 		DebuggerRequest = query(List)
 	->
-		ModulesList = List,
-		length(ModulesList, CardList)
+		ModulesList = List
 	;
 		DebuggerRequest = cc_query(List)
 	->
-		ModulesList = List,
-		length(ModulesList, CardList)
+		ModulesList = List
 	;
 		DebuggerRequest = io_query(List)
 	->
-		ModulesList = List,
-		length(ModulesList, CardList)
+		ModulesList = List
 	;
 		error("get_list_modules_to_import: not a query request")
-	).
+	),
+	length(ModulesList, ListLength).
 
 %-----------------------------------------------------------------------------%
 
Index: user_guide.texi
--- 0.3/user_guide.texi Wed, 21 Apr 1999 20:23:50 +0200 jahier (iq/7_user_guide 1.1 640)
+++ 0.3(w)/user_guide.texi Wed, 21 Apr 1999 20:36:17 +0200 jahier (iq/7_user_guide 1.1 640)
@@ -1338,6 +1338,12 @@
 @item query @var{module1} @var{module2} @dots{}
 @itemx cc_query @var{module1} @var{module2} @dots{}
 @itemx io_query @var{module1} @var{module2} @dots{}
+
+ at c This documentation has been duplicated in 
+ at c Opium-M/source/interactive_queries.op so please tell me (jahier at irisa.fr)
+ at c to update my documentation on interactive queries if you update this 
+ at c subsection.
+
 These commands allow you to type in queries (goals) interactively
 in the debugger.  When you use one of these commands, the debugger
 will respond with a query prompt (@samp{?-} or @samp{run <--}),

--- interactive_queries.op	Wed Apr 21 20:42:34 1999
+++ /home/swann/d01/lande/jahier/d02/projet_en_cours/rmdb/source/interactive_queries.op	Wed Apr 21 21:01:50 1999
@@ -35,10 +35,10 @@
 prompt by typing the end-of-file indicator (typically control-D or \
 control-Z), or by typing `quit.'. \n\
 \n\
-The list of module names passed downed in argument of the query specify which \
+The list of module names passed down in the argument of the query specify which \
 modules will be imported. Note that you can also add new modules to the list \
 of imports directly at the query prompt, by using a command of the form \
-`[\"module\"]', e.g. `[\"int\"]'. You need to import all the modules that \
+`[module]', e.g. `[int]'. You need to import all the modules that \
 define symbols used in your query. Queries can only use symbols that are \
 exported from a module; entities which are declared in a module's \
 implementation section only  cannot be used. \n\
@@ -63,7 +63,13 @@
 supported, you will get an error message when you try to run these commands."
 	).
 
+% Most of this documentation is duplicated from the documentation
+% in mercury/doc/user_guide.texi.
+
 query_Op(ModuleList) :-
+	any_query(ModuleList, query).
+
+any_query(ModuleList, QueryType) :-
 	( not getval(state_of_opium, running) ->
 		write("No program is running, you can't make a query.\n")
 	;
@@ -72,7 +78,8 @@
 	% strings need to quoted before being sent.
 	maplist(quote_string, ModuleList, QuotedList),
 	send_message_to_socket(query(QuotedList)),
-	loop_for_queries(query).
+	loop_for_queries(QueryType).
+
 
 loop_for_queries(QueryType) :-
 	display_query_prompt(QueryType),
@@ -86,6 +93,12 @@
 	send_message_to_socket(Term2),
 	nl,
 	read_message_from_socket(Response),
+	get_parameter(debug_opium, OnOff),
+	( OnOff == on ->
+		printf("response to query = %w\n", [Response])
+	;
+		true
+	),
 	( 
 		( Response == iq_eof ; Response == iq_quit ),
 		write("End of the interactive queries session.\n"),
@@ -144,15 +157,7 @@
 	).
 
 cc_query_Op(ModuleList) :-
-	( not getval(state_of_opium, running) ->
-		write("No program is running, you can't make a query.\n")
-	;
-		true
-	),
-	% strings need to quoted before being sent.
-	maplist(quote_string, ModuleList, QuotedList),
-	send_message_to_socket(cc_query(QuotedList)),
-	loop_for_queries(cc_query).
+	any_query(ModuleList, cc_query).
 
 %------------------------------------------------------------------------------%
 opium_command(
@@ -170,16 +175,7 @@
 	).
 
 io_query_Op(ModuleList) :-
-	( not getval(state_of_opium, running) ->
-		write("No program is running, you can't make a query.\n")
-	;
-		true
-	),
-	% strings need to quoted before being sent.
-	maplist(quote_string, ModuleList, QuotedList),
-	send_message_to_socket(io_query(QuotedList)),
-	loop_for_queries(io_query).
-
+	any_query(ModuleList, io_query).
 
 %------------------------------------------------------------------------------%
 opium_command(
@@ -195,7 +191,7 @@
 "This command sets the options that will be passed to `mmc' to compile your \
 query when you use one of the query commands: `query/1', `cc_query/2', or \
 `io_query/3'. For example, if a query results in a compile error, it may \
-sometimes be helpful to use mmc_options(\"mmc_options --verbose-errors\").\
+sometimes be helpful to use mmc_options(\"--verbose-errors\").\
 "
 	).
 
@@ -219,14 +215,3 @@
 		write("mmc_options_ok expected.\n"),
 		fail
 	).

-- 
R1.


--------------------------------------------------------------------------
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