[m-dev.] For review: Incorporate the term brower stuff in the external debugger. [part 1/2]
Erwan Jahier
Erwan.Jahier at irisa.fr
Fri May 21 18:16:55 AEST 1999
| > +help(external) -->
| > + write_string_debugger(external,
| > +"Commands are:\n\
| > +\t'ls [path]'. -- list subterm (expanded)\n\
| > +\t'cd [path]'. -- cd current subterm (default is root)\n\
| > +\thelp. -- show this help message\n\
| > +\t'set var value'. -- set a setting\n\
| > +\tset. -- show settings\n\
| > +\tprint. -- show single line representation of current term\n\
| > +\tquit. -- quit browser\n\
| > +SICStus Prolog style commands are:\n\
| > +\tp. -- print\n\
| > +\t'< [n]'. -- set depth (default is 10)\n\
| > +\t'^ [path]'. -- cd [path]\n\
| > +\t'?'. -- help\n\
| > +\th. -- help\n\
| > +\n\
| > +-- settings:\n\
| > +-- size; depth; path; format (flat pretty verbose); clipx; clipy\n\
| > +-- Paths can be Unix-style or SICStus-style: /2/3/1 or ^2^3^1\n\
| > +\n"
| > + ).
|
| Why did you duplicate the help string here?
| Why not just use `help(Debugger) :- write_string_debugger(Debugger, "...")'
| to handle both cases?
Well, it is because it is not exactly the same help message. Indeed, since
Opium-M is build on top of a prolog interpreter, it was quite easy to read
terms. That's why here I have "'ls [path]'." instead of "ls [path]", "help."
instead of "help", etc.
But in fact, I've realised now it is not a very good idea, so I have change
that.
Here is the relative diff:
-------------------------------------------------------------------------
Index: browser/debugger_interface.m
--- 0.2/browser/debugger_interface.m Fri, 21 May 1999 09:09:07 +0200 jahier (browse/1_debugger_i 1.1 640)
+++ 0.2(w)/browser/debugger_interface.m Fri, 21 May 1999 09:55:48 +0200 jahier (browse/1_debugger_i 1.1 640)
@@ -581,8 +581,8 @@
:- mode get_variable_name(in, out) is det.
:- pragma export(get_variable_name(in, out), "ML_DI_get_variable_name").
- % Predicate that allows to retrieve the name of the variable to browse
- % from a `browse(var_name)' request in mercury_trace_external.c.
+ % This predicate allows mercury_trace_external.c to retrieve the name
+ % of the variable to browse from a `browse(var_name)' request.
get_variable_name(DebuggerRequest, Options) :-
(
DebuggerRequest = browse(Options1)
Index: browser/browse.m
--- 0.2/browser/browse.m Fri, 21 May 1999 09:09:07 +0200 jahier (browse/2_browse.m 1.1 640)
+++ 0.2(w)/browser/browse.m Fri, 21 May 1999 09:55:39 +0200 jahier (browse/2_browse.m 1.1 640)
@@ -72,7 +72,8 @@
% If the term browser is called from the internal debugger, Input/Output are
% done via MR_mdb_in/MR_mdb_out. If it is called from the external debugger,
% Input/Output are done via MR_debugger_socket_in/MR_debugger_socket_out.
-% Hence we need to output terms ; their type is term_browser_response.
+% In the latter case we need to output terms; their type is
+% term_browser_response.
:- type term_browser_response
@@ -320,8 +321,8 @@
% XXX: default depth is hardwired to 10.
:- pred help(debugger::in, io__state::di, io__state::uo) is det.
-help(internal) -->
- io__write_string(
+help(Debugger) -->
+ write_string_debugger(Debugger,
"Commands are:\n\
\tls [path] -- list subterm (expanded)\n\
\tcd [path] -- cd current subterm (default is root)\n\
@@ -336,29 +337,6 @@
\t^ [path] -- cd [path]\n\
\t? -- help\n\
\th -- help\n\
-\n\
--- settings:\n\
--- size; depth; path; format (flat pretty verbose); clipx; clipy\n\
--- Paths can be Unix-style or SICStus-style: /2/3/1 or ^2^3^1\n\
-\n"
- ).
-
-help(external) -->
- write_string_debugger(external,
-"Commands are:\n\
-\t'ls [path]'. -- list subterm (expanded)\n\
-\t'cd [path]'. -- cd current subterm (default is root)\n\
-\thelp. -- show this help message\n\
-\t'set var value'. -- set a setting\n\
-\tset. -- show settings\n\
-\tprint. -- show single line representation of current term\n\
-\tquit. -- quit browser\n\
-SICStus Prolog style commands are:\n\
-\tp. -- print\n\
-\t'< [n]'. -- set depth (default is 10)\n\
-\t'^ [path]'. -- cd [path]\n\
-\t'?'. -- help\n\
-\th. -- help\n\
\n\
-- settings:\n\
-- size; depth; path; format (flat pretty verbose); clipx; clipy\n\
Index: runtime/mercury_layout_util.h
--- 0.2/runtime/mercury_layout_util.h Fri, 21 May 1999 09:09:07 +0200 jahier (browse/3_mercury_la 1.1 640)
+++ 0.2(w)/runtime/mercury_layout_util.h Fri, 21 May 1999 09:57:25 +0200 jahier (browse/3_mercury_la 1.1 640)
@@ -167,9 +167,9 @@
/*
** Find and validate the number of a variable given by a variable
-** specification in the given layout. If successful, return the
-** number of the variable in *which_var_ptr, and a NULL string;
-** otherwise return a string containing an error message.
+** specification in the given layout. If successful, store the
+** number of the variable in *which_var_ptr, and return a NULL
+** string; otherwise return a string containing an error message.
*/
extern const char *MR_trace_find_var(const MR_Stack_Layout_Label *layout,
Index: runtime/mercury_layout_util.c
--- 0.2/runtime/mercury_layout_util.c Fri, 21 May 1999 09:09:07 +0200 jahier (browse/4_mercury_la 1.1 640)
+++ 0.2(w)/runtime/mercury_layout_util.c Fri, 21 May 1999 09:57:24 +0200 jahier (browse/4_mercury_la 1.1 640)
@@ -520,9 +520,9 @@
/*
** Find and validate the number of a variable given by a variable
-** specification in the given layout. If successful, return the
-** number of the variable in *which_var_ptr, and a NULL string;
-** otherwise return a string containing an error message.
+** specification in the given layout. If successful, store the
+** number of the variable in *which_var_ptr, and return a NULL
+** string; otherwise return a string containing an error message.
*/
const char *
Index: trace/mercury_trace_external.c
--- 0.2/trace/mercury_trace_external.c Fri, 21 May 1999 09:09:07 +0200 jahier (browse/6_mercury_tr 1.1 640)
+++ 0.2(w)/trace/mercury_trace_external.c Fri, 21 May 1999 09:56:29 +0200 jahier (browse/6_mercury_tr 1.1 640)
@@ -402,14 +402,14 @@
Word modules_list;
int ancestor_level;
-/*
-** MR_mmc_options contains the options to pass to mmc when compiling queries.
-** We initialise it to the String "".
-*/
+ /*
+ ** MR_mmc_options contains the options to pass to mmc when compiling
+ ** queries. We initialise it to the String "".
+ */
static String MR_mmc_options;
MR_TRACE_CALL_MERCURY(ML_DI_init_mercury_string(&MR_mmc_options));
-/* by default, print variables from the current call */
+ /* by default, print variables from the current call */
ancestor_level = 0;
event_details.MR_call_seqno = MR_trace_call_seqno;
@@ -1191,9 +1191,10 @@
/*
-** It is the same function as MR_trace_browse_one() defined in
-** mercury_trace_internal.c except it sends/receives messages from/to
-** the socket instead of sending it to mdb_in/mdb_out.
+** This function does the same thing as MR_trace_browse_one() defined in
+** mercury_trace_internal.c except it sends/receives program-readable terms
+** from/to the socket instead of sending human-readable strings from/to
+** mdb_in/mdb_out.
*/
static void
@@ -1239,11 +1240,11 @@
free(type_params);
}
/*
-** It is the same function as MR_trace_browse_var() defined in
-** mercury_trace_internal.c except it always calls the term browser and it calls
-** MR_trace_browse_external() instead of MR_trace_browse().
+** This function does the same thing as MR_trace_browse_var() defined in
+** mercury_trace_internal.c except it always calls the term browser and it
+** calls MR_trace_browse_external() instead of MR_trace_browse().
*/
static void
Index: trace/mercury_trace_browse.c
--- 0.2/trace/mercury_trace_browse.c Fri, 21 May 1999 09:09:07 +0200 jahier (browse/8_mercury_tr 1.1 640)
+++ 0.2(w)/trace/mercury_trace_browse.c Fri, 21 May 1999 09:56:38 +0200 jahier (browse/8_mercury_tr 1.1 640)
@@ -66,8 +66,9 @@
/*
** MR_trace_browse_external() is the same as MR_trace_browse() except it
-** uses debugger_socket_in and debugger_socket_out instead of mdb_in and
-** mdb_out.
+** uses debugger_socket_in and debugger_socket_out to read program-readable
+** terms, whereas MR_trace_browse() uses mdb_in and mdb_out to read
+** human-readable strings.
*/
void
Index: browse.op
--- 0.2/browse.op Fri, 21 May 1999 10:00:19 +0200 jahier (browse/9_browse.op 1.1 640)
+++ 0.2(w)/browse.op Fri, 21 May 1999 10:01:30 +0200 jahier (browse/9_browse.op 1.1 640)
@@ -36,10 +36,10 @@
browser_loop :-
print("browser> "), flush(user),
- ( read_and_check(Term) ->
- atom_string(Term, TermStr),
- quote_string(TermStr, TermStrQuoted),
- send_message_to_socket(external_request(TermStrQuoted)),
+ ( read_and_check(Command) ->
+ atom_string(Command, CommandStr),
+ quote_string(CommandStr, CommandStrQuoted),
+ send_message_to_socket(external_request(CommandStrQuoted)),
read_loop(Msg)
;
send_message_to_socket(external_request('"help"')),
@@ -85,6 +85,6 @@
MsgOut = Msg
).
-read_and_check(Term) :-
- read(Term),
- atom(Term).
\ No newline at end of file
+read_and_check(Command) :-
+ read_string("\n", _, String),
+ atom_string(Command, String).
--
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