[m-rev.] for review: fix mdb "save" command

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Mar 30 17:16:23 AEDT 2006


XXX: the change to the mdb "set" command is not yet documented, because it
is not clear shat should be set from "set" and what should be set from
elsewhere; we should discuss this in person tomorrow.

Fix the debugger's save command so that it saves everything it should save
(with one unavoidable exception). Rename the "save_to_file" command to "dump",
as we agreed.

NEWS:
doc/user_guide.texi:
doc/mdb_categories:
	Document these facts.

browser/browser_info.m:
	Provide a predicate to save the entire persistent state of the browser.

	Provide a predicate to set the number of I/O actions printed by the
	declarative debugger.

	Check that the XML browser command and temp file name being set aren't
	empty, since those are not meaningful.

	Rename predicates to avoid ambiguities and excessively long names.
	Simplify some code.

browser/browse.m:
	Generate better error messages if the user tries to use XML browsing
	without setting it up.

browser/browse.m:
browser/declarative_user.m:
	Conform to the changes in browser_info.m

browser/listing.m:
	Use the correct prefix on global C symbols.

trace/mercury_trace_internal.c:
	Change the save command to save everything of the persistent debugger
	state that can be saved.

	Allow the set command to set the number of I/O actions printed by the
	declarative debugger. Without this, there would be no way to restore
	this part of the debugger persistent state, since a source command
	cannot start the declarative debugger.

	Rename save_to_file as dump.

	Use the correct prefix on global C symbols.

	Avoid misleading capitalization.

trace/mercury_trace_spy.c:
	Extend the code that saves the state of breakpoints to save conditions
	on breakpoints as well.

trace/mercury_trace_browser.[ch]:
	Add a utility function for saving the persistent browser state.

	Conform to the changes in browser/browser_info.m.

trace/mercury_trace_alias.[ch]
	Convert to four-space indentation.

tests/debugger/browser_test.{inp,exp}:
tests/debugger/mdb_command_test.inp:
	Use dump instead of save_to_file.

tests/debugger/save.{m,inp,exp}:
	New test case to test the new behavior of the save command.

tests/debugger/Mmakefile:
	Enable the new test case.

Zoltan.

cvs diff: Diffing .
Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.408
diff -u -r1.408 NEWS
--- NEWS	24 Mar 2006 04:40:40 -0000	1.408
+++ NEWS	29 Mar 2006 14:55:10 -0000
@@ -61,6 +61,10 @@
   left the goal at which the term was available as the value of a program
   variable.
 * Users can now see the set of places where two terms differ from each other.
+* The `save_to_file' command has been renamed the `dump' command.
+* The `save' command now saves the entire persistent state of the debugger
+  (with one small exception that cannot be reestablished by an mdb command from
+  an arbitrary point of execution).
 * The declarative debugger now supports an `undo' command, and allows users to
   select the search algorithm.
 * The declarative debugger can now exploit information from the "code
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
Index: browser/browse.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/browse.m,v
retrieving revision 1.58
diff -u -r1.58 browse.m
--- browser/browse.m	29 Mar 2006 08:06:30 -0000	1.58
+++ browser/browse.m	30 Mar 2006 00:31:02 -0000
@@ -210,8 +210,8 @@
 :- pragma export(save_term_to_file_xml(in, in, in, di, uo),
     "ML_BROWSE_save_term_to_file_xml").
 
-:- pragma export(save_and_browse_browser_term_xml(in, in, in, in,
-    di, uo), "ML_BROWSE_browse_term_xml").
+:- pragma export(save_and_browse_browser_term_xml(in, in, in, in, di, uo),
+    "ML_BROWSE_browse_term_xml").
 
 %---------------------------------------------------------------------------%
 %
@@ -329,34 +329,40 @@
 
 save_and_browse_browser_term_xml(Term, OutStream, ErrStream, State, !IO) :-
     MaybeXMLBrowserCmd = State ^ xml_browser_cmd,
+    MaybeTmpFileName = State ^ xml_tmp_filename,
     (
         MaybeXMLBrowserCmd = yes(CommandStr),
-        MaybeTmpFileName = State ^ xml_tmp_filename,
-        (
-            MaybeTmpFileName = yes(TmpFileName),
-            io.write_string(OutStream, "Saving term to XML file...\n", !IO),
-            maybe_save_term_to_file_xml(TmpFileName, Term,
-                SaveResult, !IO),
-            (
-                SaveResult = ok,
-                launch_xml_browser(OutStream, ErrStream, CommandStr, !IO)
-            ;
-                SaveResult = error(Error),
-                io.error_message(Error, Msg),
-                io.write_string(ErrStream,
-                    "Error opening file `" ++ TmpFileName ++ "': ", !IO),
-                io.write_string(ErrStream, Msg, !IO),
-                io.nl(!IO)
-            )
-        ;
-            MaybeTmpFileName = no,
-            io.write_string(ErrStream, "mdb: You need to issue a " ++
-                "\"set xml_tmp_filename '<filename>'\" command first.\n", !IO)
+        MaybeTmpFileName = yes(TmpFileName),
+        io.write_string(OutStream, "Saving term to XML file...\n", !IO),
+        maybe_save_term_to_file_xml(TmpFileName, Term, SaveResult, !IO),
+        (
+            SaveResult = ok,
+            launch_xml_browser(OutStream, ErrStream, CommandStr, !IO)
+        ;
+            SaveResult = error(Error),
+            io.error_message(Error, Msg),
+            io.write_string(ErrStream,
+                "Error opening file `" ++ TmpFileName ++ "': ", !IO),
+            io.write_string(ErrStream, Msg, !IO),
+            io.nl(!IO)
         )
     ;
+        MaybeXMLBrowserCmd = yes(_),
+        MaybeTmpFileName = no,
+        io.write_string(ErrStream, "mdb: You need to issue a " ++
+            "\"set xml_tmp_filename '<filename>'\" command first.\n", !IO)
+    ;
         MaybeXMLBrowserCmd = no,
+        MaybeTmpFileName = yes(_),
         io.write_string(ErrStream, "mdb: You need to issue a " ++
             "\"set xml_browser_cmd '<command>'\" command first.\n", !IO)
+    ;
+        MaybeXMLBrowserCmd = no,
+        MaybeTmpFileName = no,
+        io.write_string(ErrStream, "mdb: You need to issue a " ++
+            "\"set xml_browser_cmd '<command>'\" command\n" ++
+            "and a \"set xml_tmp_filename '<filename>'\" command first.\n",
+            !IO)
     ).
 
 :- pred launch_xml_browser(io.output_stream::in, io.output_stream::in,
@@ -768,8 +774,8 @@
     browser_info::in, browser_info::out) is det.
 
 set_browse_param(OptionTable, Setting, !Info) :-
-    browser_info.set_param(yes, OptionTable, Setting, !.Info ^ state,
-        NewState),
+    set_browser_param_from_option_table(yes, OptionTable, Setting,
+        !.Info ^ state, NewState),
     !:Info = !.Info ^ state := NewState.
 
 :- pred help(debugger::in, io::di, io::uo) is det.
Index: browser/browser_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/browser_info.m,v
retrieving revision 1.25
diff -u -r1.25 browser_info.m
--- browser/browser_info.m	29 Mar 2006 08:06:30 -0000	1.25
+++ browser/browser_info.m	30 Mar 2006 00:07:13 -0000
@@ -205,7 +205,7 @@
     % seven arguments indicate the presence of the `set' options
     % -P, -B, -A, -f, -r, -v and -p, in that order.
     %
-:- pred set_param(bool::in, bool::in, bool::in, bool::in,
+:- pred set_browser_param(bool::in, bool::in, bool::in, bool::in,
     bool::in, bool::in, bool::in, bool::in, setting::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
 
@@ -215,17 +215,23 @@
     % -P, -B, -A, while the next four indicate the presence of -f, -r, -v
     % and -p, in that order.
     %
-:- pred set_param(bool::in, maybe(browse_caller_type)::in,
+:- pred set_browser_param_maybe_caller_type(bool::in,
+    maybe(browse_caller_type)::in,
     bool::in, bool::in, bool::in, bool::in, setting::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
 
-    % browser_info.set_param(FromBrowser, OptionTable, Setting, !State)
+    % set_param_from_option_table(FromBrowser, OptionTable, Setting, !State):
+    %
     % Same as set_param/11, but looks up the options in the
     % supplied option table.
     %
-:- pred set_param(bool::in, option_table(setting_option)::in, setting::in,
+:- pred set_browser_param_from_option_table(bool::in,
+    option_table(setting_option)::in, setting::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
 
+:- pred browser_params_to_string(browser_persistent_state::in, bool::in,
+    string::out) is det.
+
 %---------------------------------------------------------------------------%
 
 % These three predicates are like the deconstruct, limited_deconstruct
@@ -277,73 +283,82 @@
 % call set_param from C code.
 %
 
-:- pred set_param_depth_from_mdb(bool::in, bool::in, bool::in, bool::in,
-    bool::in, bool::in, bool::in, int::in, browser_persistent_state::in,
-    browser_persistent_state::out) is det.
-:- pragma export(set_param_depth_from_mdb(in, in, in, in, in, in, in, in,
-    in, out), "ML_BROWSE_set_param_depth_from_mdb").
-
-set_param_depth_from_mdb(P, B, A, F, Pr, V, NPr, Depth) -->
-    set_param(no, P, B, A, F, Pr, V, NPr,  depth(Depth)).
-
-:- pred set_param_size_from_mdb(bool::in, bool::in, bool::in, bool::in,
-    bool::in, bool::in, bool::in, int::in, browser_persistent_state::in,
-    browser_persistent_state::out) is det.
-:- pragma export(set_param_size_from_mdb(in, in, in, in, in, in, in, in,
-    in, out), "ML_BROWSE_set_param_size_from_mdb").
-
-set_param_size_from_mdb(P, B, A, F, Pr, NPr, V, Size) -->
-    set_param(no, P, B, A, F, Pr, V, NPr, size(Size)).
-
-:- pred set_param_width_from_mdb(bool::in, bool::in, bool::in, bool::in,
-    bool::in, bool::in, bool::in, int::in, browser_persistent_state::in,
-    browser_persistent_state::out) is det.
-:- pragma export(set_param_width_from_mdb(in, in, in, in, in, in, in, in,
-    in, out), "ML_BROWSE_set_param_width_from_mdb").
+:- pred set_depth_from_mdb(bool::in, bool::in, bool::in,
+    bool::in, bool::in, bool::in, bool::in, int::in,
+    browser_persistent_state::in, browser_persistent_state::out) is det.
+:- pragma export(set_depth_from_mdb(in, in, in, in, in, in, in,
+    in, in, out), "ML_BROWSE_set_depth_from_mdb").
 
-set_param_width_from_mdb(P, B, A, F, Pr, V, NPr, Width) -->
-    set_param(no, P, B, A, F, Pr, V, NPr, width(Width)).
+set_depth_from_mdb(P, B, A, F, Pr, V, NPr, Depth, !Browser) :-
+    set_browser_param(no, P, B, A, F, Pr, V, NPr,  depth(Depth), !Browser).
 
-:- pred set_param_lines_from_mdb(bool::in, bool::in, bool::in, bool::in,
+:- pred set_size_from_mdb(bool::in, bool::in, bool::in, bool::in,
     bool::in, bool::in, bool::in, int::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
-:- pragma export(set_param_lines_from_mdb(in, in, in, in, in, in, in, in,
-    in, out), "ML_BROWSE_set_param_lines_from_mdb").
+:- pragma export(set_size_from_mdb(in, in, in, in, in, in, in,
+    in, in, out), "ML_BROWSE_set_size_from_mdb").
+
+set_size_from_mdb(P, B, A, F, Pr, NPr, V, Size, !Browser) :-
+    set_browser_param(no, P, B, A, F, Pr, V, NPr, size(Size), !Browser).
+
+:- pred set_width_from_mdb(bool::in, bool::in, bool::in,
+    bool::in, bool::in, bool::in, bool::in, int::in,
+    browser_persistent_state::in, browser_persistent_state::out) is det.
+:- pragma export(set_width_from_mdb(in, in, in, in, in, in, in,
+    in, in, out), "ML_BROWSE_set_width_from_mdb").
 
-set_param_lines_from_mdb(P, B, A, F, Pr, V, NPr, Lines) -->
-    set_param(no, P, B, A, F, Pr, V, NPr, lines(Lines)).
+set_width_from_mdb(P, B, A, F, Pr, V, NPr, Width, !Browser) :-
+    set_browser_param(no, P, B, A, F, Pr, V, NPr, width(Width), !Browser).
 
-:- pred set_param_format_from_mdb(bool::in, bool::in, bool::in,
-    portray_format::in,
+:- pred set_lines_from_mdb(bool::in, bool::in, bool::in,
+    bool::in, bool::in, bool::in, bool::in, int::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
-:- pragma export(set_param_format_from_mdb(in, in, in, in, in, out),
-    "ML_BROWSE_set_param_format_from_mdb").
+:- pragma export(set_lines_from_mdb(in, in, in, in, in, in, in,
+    in, in, out), "ML_BROWSE_set_lines_from_mdb").
 
-set_param_format_from_mdb(P, B, A, Format, !Browser) :-
+set_lines_from_mdb(P, B, A, F, Pr, V, NPr, Lines, !Browser) :-
+    set_browser_param(no, P, B, A, F, Pr, V, NPr, lines(Lines), !Browser).
+
+:- pred set_format_from_mdb(bool::in, bool::in, bool::in, portray_format::in,
+    browser_persistent_state::in, browser_persistent_state::out) is det.
+:- pragma export(set_format_from_mdb(in, in, in, in, in, out),
+    "ML_BROWSE_set_format_from_mdb").
+
+set_format_from_mdb(P, B, A, Format, !Browser) :-
     % Any format flags are ignored for this parameter.
-    set_param(no, P, B, A, no, no, no, no, format(Format), !Browser).
+    set_browser_param(no, P, B, A, no, no, no, no, format(Format), !Browser).
 
-:- pred set_param_xml_browser_cmd_from_mdb(string::in,
+:- pred set_num_io_actions_from_mdb(int::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
-:- pragma export(mdb.browser_info.set_param_xml_browser_cmd_from_mdb(in, in,
-    out), "ML_BROWSE_set_param_xml_browser_cmd_from_mdb").
+:- pragma export(set_num_io_actions_from_mdb(in, in, out),
+    "ML_BROWSE_set_num_io_actions_from_mdb").
 
-set_param_xml_browser_cmd_from_mdb(Command, !Browser) :-
-    browser_info.set_param(no`with_type`bool,
-        no`with_type`bool, no`with_type`bool, no`with_type`bool,
-        no`with_type`bool, no`with_type`bool, no`with_type`bool,
-        no`with_type`bool, xml_browser_cmd(Command), !Browser).
+set_num_io_actions_from_mdb(NumIOActions, !Browser) :-
+    !:Browser = !.Browser ^ num_printed_io_actions := NumIOActions.
 
-:- pred set_param_xml_tmp_filename_from_mdb(string::in,
+:- pred set_xml_browser_cmd_from_mdb(string::in,
     browser_persistent_state::in, browser_persistent_state::out) is det.
-:- pragma export(mdb.browser_info.set_param_xml_tmp_filename_from_mdb(in, in,
-    out), "ML_BROWSE_set_param_xml_tmp_filename_from_mdb").
+:- pragma export(set_xml_browser_cmd_from_mdb(in, in, out),
+    "ML_BROWSE_set_xml_browser_cmd_from_mdb").
 
-set_param_xml_tmp_filename_from_mdb(FileName, !Browser) :-
-    browser_info.set_param(no `with_type` bool,
-        no `with_type` bool, no `with_type` bool, no `with_type` bool,
-        no `with_type` bool, no `with_type` bool, no `with_type` bool,
-        no `with_type` bool, xml_tmp_filename(FileName), !Browser).
+set_xml_browser_cmd_from_mdb(Command, !Browser) :-
+    ( Command = "" ->
+        !:Browser = !.Browser ^ xml_browser_cmd := no
+    ;
+        !:Browser = !.Browser ^ xml_browser_cmd := yes(Command)
+    ).
+
+:- pred set_xml_tmp_filename_from_mdb(string::in,
+    browser_persistent_state::in, browser_persistent_state::out) is det.
+:- pragma export(set_xml_tmp_filename_from_mdb(in, in, out),
+    "ML_BROWSE_set_xml_tmp_filename_from_mdb").
+
+set_xml_tmp_filename_from_mdb(FileName, !Browser) :-
+    ( FileName = "" ->
+        !:Browser = !.Browser ^ xml_tmp_filename := no
+    ;
+        !:Browser = !.Browser ^ xml_tmp_filename := yes(FileName)
+    ).
 
 %
 % The following exported functions allow C code to create
@@ -474,11 +489,8 @@
 % context.
 num_printed_io_actions_default = 20.
 
-set_param(FromBrowser, MaybeCallerType, F0, Pr0, V0, NPr0, Setting, !State) :-
-    affected_caller_types(FromBrowser, MaybeCallerType, P, B, A),
-    set_param(FromBrowser, P, B, A, F0, Pr0, V0, NPr0, Setting, !State).
-
-set_param(FromBrowser, P0, B0, A0, F0, Pr0, V0, NPr0, Setting, !State) :-
+set_browser_param(FromBrowser, P0, B0, A0, F0, Pr0, V0, NPr0, Setting,
+        !State) :-
     ( Setting = num_io_actions(NumIoActions) ->
         !:State = !.State ^ num_printed_io_actions := NumIoActions
     ; Setting = xml_browser_cmd(CommandStr) ->
@@ -515,15 +527,22 @@
             !.State ^ xml_browser_cmd, !.State ^ xml_tmp_filename)
     ).
 
-browser_info.set_param(FromBrowser, OptionTable, Setting, !State) :-
-    browser_info.set_param(FromBrowser,
-        lookup_bool_option(OptionTable, print) `with_type` bool,
-        lookup_bool_option(OptionTable, browse) `with_type` bool,
-        lookup_bool_option(OptionTable, print_all) `with_type` bool,
-        lookup_bool_option(OptionTable, flat) `with_type` bool,
-        lookup_bool_option(OptionTable, raw_pretty) `with_type` bool,
-        lookup_bool_option(OptionTable, verbose) `with_type` bool,
-        lookup_bool_option(OptionTable, pretty) `with_type` bool,
+set_browser_param_maybe_caller_type(FromBrowser, MaybeCallerType,
+        F0, Pr0, V0, NPr0, Setting, !State) :-
+    affected_caller_types(FromBrowser, MaybeCallerType, P, B, A),
+    set_browser_param(FromBrowser, P, B, A, F0, Pr0, V0, NPr0, Setting,
+        !State).
+
+set_browser_param_from_option_table(FromBrowser, OptionTable, Setting,
+        !State) :-
+    set_browser_param(FromBrowser,
+        lookup_bool_option(OptionTable, print):bool,
+        lookup_bool_option(OptionTable, browse):bool,
+        lookup_bool_option(OptionTable, print_all):bool,
+        lookup_bool_option(OptionTable, flat):bool,
+        lookup_bool_option(OptionTable, raw_pretty):bool,
+        lookup_bool_option(OptionTable, verbose):bool,
+        lookup_bool_option(OptionTable, pretty):bool,
         Setting, !State).
 
 :- pred affected_caller_types(bool::in, maybe(browse_caller_type)::in,
@@ -640,6 +659,127 @@
 
 get_num_printed_io_actions(State) =
     State ^ num_printed_io_actions.
+
+%---------------------------------------------------------------------------%
+
+:- pragma export(browser_params_to_string(in, in, out),
+    "ML_BROWSE_browser_params_to_string").
+
+browser_params_to_string(Browser, MDBCommandFormat, Desc) :-
+    Browser = browser_persistent_state(PrintParams, BrowseParams,
+        PrintAllParams, NumIOActions, MaybeXMLBrowserCmd, MaybeXMLTmpFileName),
+    (
+        MDBCommandFormat = yes,
+        ParamCmds = 
+            caller_params_to_mdb_command("-P", PrintParams) ++
+            caller_params_to_mdb_command("-B", BrowseParams) ++
+            caller_params_to_mdb_command("-A", PrintAllParams),
+        NumIOActionCmd =
+            "set max_io_actions " ++ int_to_string(NumIOActions) ++ "\n",
+        (
+            MaybeXMLBrowserCmd = yes(XMLBrowserCmd),
+            % XMLBrowserCmd shouldn't be "" if MaybeXMLBrowserCmd is yes,
+            % but better safe than sorry.
+            XMLBrowserCmd \= ""
+        ->
+            XMLBrowserCmdCmd =
+                "set xml_browser_cmd " ++ XMLBrowserCmd ++ "\n"
+        ;
+            XMLBrowserCmdCmd = ""
+        ),
+        (
+            MaybeXMLTmpFileName = yes(XMLTmpFileName),
+            % XMLTmpFileName shouldn't be "" if MaybeXMLTmpFileName is yes,
+            % but better safe than sorry.
+            XMLTmpFileName \= ""
+        ->
+            XMLTmpFileNameCmd =
+                "set xml_tmp_filename " ++ XMLTmpFileName ++ "\n"
+        ;
+            XMLTmpFileNameCmd = ""
+        ),
+        Desc = ParamCmds ++ NumIOActionCmd ++
+            XMLBrowserCmdCmd ++ XMLTmpFileNameCmd
+    ;
+        MDBCommandFormat = no,
+        ParamDesc =
+            "Print paramaters:\n" ++
+            caller_params_to_desc(PrintParams) ++
+            "Browse paramaters:\n" ++
+            caller_params_to_desc(BrowseParams) ++
+            "Print all paramaters:\n" ++
+            caller_params_to_desc(PrintAllParams),
+        NumIOActionDesc =
+            "Maximum number of I/O actions printed: " ++
+                int_to_string(NumIOActions) ++ "\n",
+        (
+            MaybeXMLBrowserCmd = yes(XMLBrowserCmd),
+            XMLBrowserCmdDesc =
+                "XML browser command:    " ++ XMLBrowserCmd ++ "\n"
+        ;
+            MaybeXMLBrowserCmd = no,
+            XMLBrowserCmdDesc = ""
+        ),
+        (
+            MaybeXMLTmpFileName = yes(XMLTmpFileName),
+            XMLTmpFileNameDesc =
+                "XML temporary filename: " ++ XMLTmpFileName ++ "\n"
+        ;
+            MaybeXMLTmpFileName = no,
+            XMLTmpFileNameDesc = ""
+        ),
+        Desc = ParamDesc ++ NumIOActionDesc ++
+            XMLBrowserCmdDesc ++ XMLTmpFileNameDesc
+    ).
+
+:- func caller_params_to_mdb_command(string, caller_params) = string.
+
+caller_params_to_mdb_command(CallerOpt, CallerParams) = Cmds :-
+    CmdCallerOpt = "set " ++ CallerOpt ++ " ",
+    CallerParams = caller_params(Format, FlatParams, RawPrettyParams,
+        VerboseParams, PrettyParams),
+    FormatCmd = CmdCallerOpt ++ "format " ++ format_to_string(Format) ++ "\n",
+    FormatParamCmds =
+        format_params_to_mdb_command(CmdCallerOpt ++ "-f ", FlatParams) ++
+        format_params_to_mdb_command(CmdCallerOpt ++ "-r ", RawPrettyParams) ++
+        format_params_to_mdb_command(CmdCallerOpt ++ "-v ", VerboseParams) ++
+        format_params_to_mdb_command(CmdCallerOpt ++ "-p ", PrettyParams),
+    Cmds = FormatCmd ++ FormatParamCmds.
+
+:- func caller_params_to_desc(caller_params) = string.
+
+caller_params_to_desc(caller_params(Format, FlatParams, RawPrettyParams,
+        VerboseParams, PrettyParams)) =
+    "default format " ++ format_to_string(Format) ++ "\n" ++
+    "flat parameters:       " ++ format_params_to_desc(FlatParams) ++
+    "raw_pretty parameters: " ++ format_params_to_desc(RawPrettyParams) ++
+    "verbose parameters:    " ++ format_params_to_desc(VerboseParams) ++
+    "pretty parameters:     " ++ format_params_to_desc(PrettyParams).
+
+:- func format_params_to_mdb_command(string, format_params) = string.
+
+format_params_to_mdb_command(CmdCallerOpt, FormatParams) = Cmds :-
+    FormatParams = format_params(Depth, Size, Width, Lines),
+    DepthCmd = CmdCallerOpt ++ "depth " ++ int_to_string(Depth) ++ "\n",
+    SizeCmd  = CmdCallerOpt ++ "size "  ++ int_to_string(Size) ++ "\n",
+    WidthCmd = CmdCallerOpt ++ "width " ++ int_to_string(Width) ++ "\n",
+    LinesCmd = CmdCallerOpt ++ "lines " ++ int_to_string(Lines) ++ "\n",
+    Cmds = DepthCmd ++ SizeCmd ++ WidthCmd ++ LinesCmd.
+
+:- func format_params_to_desc(format_params) = string.
+
+format_params_to_desc(format_params(Depth, Size, Width, Lines)) =
+    "depth " ++ int_to_string(Depth) ++ ", " ++
+    "size "  ++ int_to_string(Size) ++ ", " ++
+    "width " ++ int_to_string(Width) ++ ", " ++
+    "lines " ++ int_to_string(Lines) ++ "\n".
+
+:- func format_to_string(portray_format) = string.
+
+format_to_string(flat) = "flat".
+format_to_string(raw_pretty) = "raw_pretty".
+format_to_string(verbose) = "verbose".
+format_to_string(pretty) = "pretty".
 
 %---------------------------------------------------------------------------%
 
Index: browser/declarative_user.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_user.m,v
retrieving revision 1.58
diff -u -r1.58 declarative_user.m
--- browser/declarative_user.m	29 Mar 2006 08:06:31 -0000	1.58
+++ browser/declarative_user.m	29 Mar 2006 23:08:15 -0000
@@ -268,8 +268,8 @@
         !IO) :-
     (
         MaybeOptionTable = ok(OptionTable),
-        browser_info.set_param(no, OptionTable, Setting, !.User ^ browser,
-            Browser),
+        set_browser_param_from_option_table(no, OptionTable, Setting,
+            !.User ^ browser, Browser),
         !:User = !.User ^ browser := Browser
     ;
         MaybeOptionTable = error(Msg),
Index: browser/listing.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/listing.m,v
retrieving revision 1.3
diff -u -r1.3 listing.m
--- browser/listing.m	29 Mar 2006 08:06:32 -0000	1.3
+++ browser/listing.m	29 Mar 2006 23:08:15 -0000
@@ -99,19 +99,19 @@
     % These predicates are called from trace/mercury_trace_internal.c.
     %
 :- pragma export(new_list_path = out,
-    "MR_LISTING_new_list_path").
+    "ML_LISTING_new_list_path").
 :- pragma export(get_list_path(in) = out,
-    "MR_LISTING_get_list_path").
+    "ML_LISTING_get_list_path").
 :- pragma export(set_list_path(in, in, out),
-    "MR_LISTING_set_list_path").
+    "ML_LISTING_set_list_path").
 :- pragma export(clear_list_path(in, out),
-    "MR_LISTING_clear_list_path").
+    "ML_LISTING_clear_list_path").
 :- pragma export(push_list_path(in, in, out),
-    "MR_LISTING_push_list_path").
+    "ML_LISTING_push_list_path").
 :- pragma export(pop_list_path(in, out),
-    "MR_LISTING_pop_list_path").
+    "ML_LISTING_pop_list_path").
 :- pragma export(list_file(in, in, in, in, in, in, in, di, uo),
-    "MR_LISTING_list_file").
+    "ML_LISTING_list_file").
 
 %-----------------------------------------------------------------------------%
 
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/mdb_categories
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.30
diff -u -r1.30 mdb_categories
--- doc/mdb_categories	4 Feb 2006 14:30:02 -0000	1.30
+++ doc/mdb_categories	29 Mar 2006 14:45:43 -0000
@@ -27,8 +27,7 @@
 browsing   - Commands that let users explore the state of the computation.
              The browsing commands are `vars', `held_vars', `print', `browse',
              `stack', `up', `down', `level', `current', `view', `hold',
-             `diff', `save_to_file', `list', `push_list_dir' and
-             `pop_list_dir'.
+             `diff', `dump', `list', `push_list_dir' and `pop_list_dir'.
 
 end
 document_category 500 breakpoint
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.471
diff -u -r1.471 user_guide.texi
--- doc/user_guide.texi	27 Mar 2006 06:56:20 -0000	1.471
+++ doc/user_guide.texi	29 Mar 2006 14:53:11 -0000
@@ -2847,27 +2847,27 @@
 The option @samp{-m} (or @samp{--max}), if present,
 specifies how many differences to print.
 @sp 1
- at item save_to_file [-x] goal @var{filename}
- at kindex save_to_file (mdb command)
+ at item dump [-x] goal @var{filename}
+ at kindex dump (mdb command)
 Writes the goal of the current call in its present state of instantiation
 to the specified file.
 The option @samp{-x} (or @samp{--xml}) causes the output to be in XML.
 @sp 1
- at item save_to_file [-x] exception @var{filename}
+ at item dump [-x] exception @var{filename}
 Writes the value of the exception at an EXCP port
 to the specified file.
 Reports an error if the current event does not refer to such a port.
 The option @samp{-x} (or @samp{--xml}) causes the
 output to be in XML.
 @sp 1
- at item save_to_file [-x] @var{name} @var{filename}
- at itemx save_to_file [-x] @var{num} @var{filename}
+ at item dump [-x] @var{name} @var{filename}
+ at itemx dump [-x] @var{num} @var{filename}
 Writes the value of the variable in the current environment
 with the given ordinal number or with the given name
 to the specified file. The option @samp{-x} (or @samp{--xml}) causes the
 output to be in XML.
 @c @sp 1
- at c @item save_to_file [-x] proc_body @var{filename}
+ at c @item dump [-x] proc_body @var{filename}
 @c Writes the representation of the body of the current procedure,
 @c if it is available,
 @c to the specified file. The option @samp{-x} (or @samp{--xml}) causes the
@@ -3746,12 +3746,18 @@
 @sp 1
 @item save @var{filename}
 @kindex save (mdb command)
-Saves the current set of breakpoints, the current set of aliases and the
-current set of objects trusted by the declarative debugger
-in the named file as a set of @samp{break}, @samp{alias} and @samp{trust} 
-commands.
-Sourcing the file will recreate the current breakpoints and aliases and will
-trust the currently trusted objects.
+Saves the persistent state of the debugger
+(aliases, print level, scroll controls,
+set of breakpoints, browser parameters,
+set of objects trusted by the declarative debugger, etc)
+to the specified file.
+The state is saved in the form of mdb commands,
+so that sourcing the file will recreate the saved state.
+Note that this command does not save transient state,
+such as the current event.
+There is also a small part of the persistent state
+(breakpoints established with a @samp{break here} command)
+that cannot be saved.
 @sp 1
 @item quit [-y]
 @kindex quit (mdb command)
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.121
diff -u -r1.121 Mmakefile
--- tests/debugger/Mmakefile	29 Mar 2006 04:10:41 -0000	1.121
+++ tests/debugger/Mmakefile	30 Mar 2006 00:31:35 -0000
@@ -47,6 +47,7 @@
 	print_table			\
 	queens_rep			\
 	resume_typeinfos		\
+	save				\
 	solver_test			\
 	type_desc_test			\
 	uci_index
@@ -462,6 +463,9 @@
 
 retry.out: retry retry.inp
 	$(MDB_STD) ./retry < retry.inp > retry.out 2>&1
+
+save.out: save save.inp
+	$(MDB) ./save < save.inp > save.out 2>&1
 
 shallow.out: shallow shallow.inp
 	$(MDB) ./shallow < shallow.inp > shallow.out 2>&1
Index: tests/debugger/browser_test.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/browser_test.exp,v
retrieving revision 1.24
diff -u -r1.24 browser_test.exp
--- tests/debugger/browser_test.exp	11 Apr 2005 06:49:51 -0000	1.24
+++ tests/debugger/browser_test.exp	29 Mar 2006 13:30:26 -0000
@@ -10,7 +10,7 @@
       E3:     C2 EXIT pred browser_test.big_data/1-0 (det) browser_test.m:37 (browser_test.m:20)
 mdb> delete *
  0: E stop  interface pred browser_test.big_data/1-0 (det)
-mdb> save_to_file 1 browser_test.save.1
+mdb> dump 1 browser_test.save.1
 mdb> set format raw_pretty
 mdb> print *
        Data (arg 1)           	
@@ -187,7 +187,7 @@
       E4:     C3 CALL pred browser_test.list_data/1-0 (det) browser_test.m:66 (browser_test.m:23)
 mdb> finish
       E5:     C3 EXIT pred browser_test.list_data/1-0 (det) browser_test.m:66 (browser_test.m:23)
-mdb> save_to_file Data browser_test.save.2
+mdb> dump Data browser_test.save.2
 mdb> break a_func
  1: + stop  interface func browser_test.a_func/1-0 (det)
 mdb> continue
Index: tests/debugger/browser_test.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/browser_test.inp,v
retrieving revision 1.14
diff -u -r1.14 browser_test.inp
--- tests/debugger/browser_test.inp	11 Apr 2005 06:49:51 -0000	1.14
+++ tests/debugger/browser_test.inp	29 Mar 2006 13:30:15 -0000
@@ -4,7 +4,7 @@
 continue
 finish
 delete *
-save_to_file 1 browser_test.save.1
+dump 1 browser_test.save.1
 set format raw_pretty
 print *
 set -A format verbose
@@ -51,7 +51,7 @@
 break list_data
 continue
 finish
-save_to_file Data browser_test.save.2
+dump Data browser_test.save.2
 break a_func
 continue
 finish
Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.48
diff -u -r1.48 mdb_command_test.inp
--- tests/debugger/mdb_command_test.inp	2 Nov 2005 14:02:11 -0000	1.48
+++ tests/debugger/mdb_command_test.inp	29 Mar 2006 19:44:16 -0000
@@ -39,7 +39,7 @@
 view                 xyzzy xyzzy xyzzy xyzzy xyzzy
 hold                 xyzzy xyzzy xyzzy xyzzy xyzzy
 diff                 xyzzy xyzzy xyzzy xyzzy xyzzy
-save_to_file         xyzzy xyzzy xyzzy xyzzy xyzzy
+dump                 xyzzy xyzzy xyzzy xyzzy xyzzy
 list                 xyzzy xyzzy xyzzy xyzzy xyzzy
 push_list_dir        xyzzy xyzzy xyzzy xyzzy xyzzy
 pop_list_dir         xyzzy xyzzy xyzzy xyzzy xyzzy
Index: tests/debugger/save.exp
===================================================================
RCS file: tests/debugger/save.exp
diff -N tests/debugger/save.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/save.exp	29 Mar 2006 14:40:04 -0000
@@ -0,0 +1,106 @@
+       1:      1  1 CALL pred save.main/2-0 (cc_multi) save.m:17
+mdb> echo on
+Command echo enabled.
+mdb> register --quiet
+mdb> b data
+ 0: + stop  interface pred save.data/1-0 (det)
+mdb> b nodiag
+ 1: + stop  interface pred save.nodiag/3-0 (semidet)
+mdb> condition B = 5
+ 1: + stop  interface pred save.nodiag/3-0 (semidet)
+            B = 5
+mdb> context nextline
+Contexts will be printed on the next line.
+mdb> scroll 42
+Scroll window size set to 42.
+mdb> alias x save
+x      =>    save
+mdb> trust save
+Trusting module save
+mdb> save save_file
+Debugger state saved to save_file.
+mdb> continue -n -S
+[1, 3, 5, 2, 4]
+alias ? help
+alias EMPTY step
+alias NUMBER step
+alias P print *
+alias b break
+alias c continue
+alias d stack
+alias e exception
+alias excp exception
+alias f finish
+alias g goto
+alias h help
+alias p print
+alias r retry
+alias s step
+alias v vars
+alias x save
+printlevel some
+echo on
+scroll on
+scroll 42
+stack_default_limit 0
+context nextline
+goal_paths on
+break pred*save.data/1-0
+break pred*save.nodiag/3-0
+condition B = 5
+scope interface
+set -P format flat
+set -P -f depth 3
+set -P -f size 10
+set -P -f width 80
+set -P -f lines 25
+set -P -r depth 3
+set -P -r size 10
+set -P -r width 80
+set -P -r lines 25
+set -P -v depth 3
+set -P -v size 10
+set -P -v width 80
+set -P -v lines 25
+set -P -p depth 3
+set -P -p size 10
+set -P -p width 80
+set -P -p lines 25
+set -B format flat
+set -B -f depth 10
+set -B -f size 30
+set -B -f width 80
+set -B -f lines 25
+set -B -r depth 10
+set -B -r size 30
+set -B -r width 80
+set -B -r lines 25
+set -B -v depth 10
+set -B -v size 30
+set -B -v width 80
+set -B -v lines 25
+set -B -p depth 10
+set -B -p size 30
+set -B -p width 80
+set -B -p lines 25
+set -A format flat
+set -A -f depth 3
+set -A -f size 10
+set -A -f width 80
+set -A -f lines 2
+set -A -r depth 3
+set -A -r size 10
+set -A -r width 80
+set -A -r lines 2
+set -A -v depth 3
+set -A -v size 10
+set -A -v width 80
+set -A -v lines 5
+set -A -p depth 3
+set -A -p size 10
+set -A -p width 80
+set -A -p lines 2
+set max_io_actions 20
+trust save
+trust std lib
+set list_context_lines 2
Index: tests/debugger/save.inp
===================================================================
RCS file: tests/debugger/save.inp
diff -N tests/debugger/save.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/save.inp	29 Mar 2006 14:26:28 -0000
@@ -0,0 +1,11 @@
+echo on
+register --quiet
+b data
+b nodiag
+condition B = 5
+context nextline
+scroll 42
+alias x save
+trust save
+save save_file
+continue -n -S
Index: tests/debugger/save.m
===================================================================
RCS file: tests/debugger/save.m
diff -N tests/debugger/save.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/save.m	29 Mar 2006 14:33:21 -0000
@@ -0,0 +1,123 @@
+% vim: ts=4 sw=4 et
+
+:- module save.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is cc_multi.
+
+:- implementation.
+
+:- import_module list.
+:- import_module int.
+:- import_module string.
+
+main(!IO) :-
+    (
+        data(Data),
+        queen(Data, Out)
+    ->
+        print_list(Out, !IO)
+    ;
+        io.write_string("No solution\n", !IO)
+    ),
+    io.see("save_file", SeeRes, !IO),
+    (
+        SeeRes = ok,
+        io.read_file_as_string(ReadRes, !IO),
+        (
+            ReadRes = ok(FileContents),
+            io.write_string(FileContents, !IO)
+        ;
+            ReadRes = error(_PartialFileContents, ReadError),
+            io.error_message(ReadError, ReadMsg),
+            io.write_string("Read error: " ++ ReadMsg ++ "\n", !IO)
+        )
+    ;
+        SeeRes = error(SeeError),
+        io.error_message(SeeError, SeeMsg),
+        io.write_string("See error: " ++ SeeMsg ++ "\n", !IO)
+    ).
+
+:- pred data(list(int)::out) is det.
+
+data([1,2,3,4,5]).
+
+:- pred queen(list(int)::in, list(int)::out) is nondet.
+
+queen(Data, Out) :-
+    qperm(Data, Out),
+    safe(Out).
+
+:- pred qperm(list(T)::in, list(T)::out) is nondet.
+
+qperm(L, K) :-
+    (
+        L = [],
+        K = []
+    ;
+        L = [_ | _], qdelete(U, L, Z),
+        K = [U | V],
+        qperm(Z, V)
+    ).
+
+:- pred qdelete(T::out, list(T)::in, list(T)::out) is nondet.
+
+qdelete(A, [A | L], L).
+qdelete(X, [A | Z], [A | R]) :-
+    qdelete(X, Z, R).
+
+:- pred safe(list(int)::in) is semidet.
+
+safe([]).
+safe([N | L]) :-
+    nodiag(N, 1, L),
+    safe(L).
+
+:- pred nodiag(int::in, int::in, list(int)::in) is semidet.
+
+nodiag(B, D, L) :-
+    (
+        L = []
+    ;
+        L = [N | T],
+        NmB = N - B,
+        BmN = B - N,
+        ( D = NmB ->
+            fail
+        ; D = BmN ->
+            fail
+        ;
+            true
+        ),
+        D1 = D + 1,
+        nodiag(B, D1, T)
+    ).
+
+:- pred print_list(list(int)::in, io::di, io::uo) is det.
+
+print_list(Xs, !IO) :-
+    (
+        Xs = [],
+        io.write_string("[]\n", !IO)
+    ;
+        Xs = [_ | _],
+        io.write_string("[", !IO),
+        print_list_2(Xs, !IO),
+        io.write_string("]\n", !IO)
+    ).
+
+:- pred print_list_2(list(int)::in, io::di, io::uo) is det.
+
+print_list_2([], !IO).
+print_list_2([X | Xs], !IO) :-
+    io.write_int(X, !IO),
+    (
+        Xs = []
+    ;
+        Xs = [_ | _],
+        io.write_string(", ", !IO),
+        print_list_2(Xs, !IO)
+    ).
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_alias.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_alias.c,v
retrieving revision 1.8
diff -u -r1.8 mercury_trace_alias.c
--- trace/mercury_trace_alias.c	11 Jul 2005 07:30:30 -0000	1.8
+++ trace/mercury_trace_alias.c	29 Mar 2006 12:49:52 -0000
@@ -1,4 +1,7 @@
 /*
+** vim: ts=4 sw=4 expandtab
+*/
+/*
 ** Copyright (C) 1998-2000,2002-2003, 2005 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -16,168 +19,164 @@
 
 #include "mercury_trace_alias.h"
 
-static	MR_Alias	*MR_alias_records = NULL;
-static	int		MR_alias_record_max = 0;
-static	int		MR_alias_record_next = 0;
+static  MR_Alias    *MR_alias_records = NULL;
+static  int         MR_alias_record_max = 0;
+static  int         MR_alias_record_next = 0;
 
 /* The initial size of the alias table. */
-#define	INIT_ALIAS_COUNT	32
+#define INIT_ALIAS_COUNT    32
 
-static	void		MR_trace_print_alias_num(FILE *fp, int slot,
-				MR_bool mdb_command_format);
-static	char *		MR_trace_get_alias_slot_name(int slot);
-static	MR_bool		MR_trace_filter_alias_completions(const char *word,
-				MR_Completer_Data *data);
+static  void        MR_trace_print_alias_num(FILE *fp, int slot,
+                        MR_bool mdb_command_format);
+static  char        *MR_trace_get_alias_slot_name(int slot);
+static  MR_bool     MR_trace_filter_alias_completions(const char *word,
+                        MR_Completer_Data *data);
 
 void
 MR_trace_add_alias(char *name, char **words, int word_count)
 {
-	MR_bool	found;
-	int	slot;
-	int	i;
-	int	count;
-
-	MR_bsearch(MR_alias_record_next, slot, found,
-		strcmp(MR_alias_records[slot].MR_alias_name, name));
-	if (found) {
-		count = MR_alias_records[slot].MR_alias_word_count;
-		for (i = 0; i < count; i++) {
-			MR_free(MR_alias_records[slot].MR_alias_words[i]);
-		}
-
-		MR_free(MR_alias_records[slot].MR_alias_name);
-		MR_free(MR_alias_records[slot].MR_alias_words);
-	} else {
-		MR_ensure_room_for_next(MR_alias_record, MR_Alias,
-			INIT_ALIAS_COUNT);
-		MR_prepare_insert_into_sorted(MR_alias_records,
-			MR_alias_record_next, slot,
-			strcmp(MR_alias_records[slot].MR_alias_name, name));
-	}
-
-	MR_alias_records[slot].MR_alias_name = MR_copy_string(name);
-	MR_alias_records[slot].MR_alias_word_count = word_count;
-	MR_alias_records[slot].MR_alias_words = MR_NEW_ARRAY(char *,
-							word_count);
-	for (i = 0; i < word_count; i++) {
-		MR_alias_records[slot].MR_alias_words[i]
-			= MR_copy_string(words[i]);
-	}
+    MR_bool found;
+    int slot;
+    int i;
+    int count;
+
+    MR_bsearch(MR_alias_record_next, slot, found,
+        strcmp(MR_alias_records[slot].MR_alias_name, name));
+    if (found) {
+        count = MR_alias_records[slot].MR_alias_word_count;
+        for (i = 0; i < count; i++) {
+            MR_free(MR_alias_records[slot].MR_alias_words[i]);
+        }
+
+        MR_free(MR_alias_records[slot].MR_alias_name);
+        MR_free(MR_alias_records[slot].MR_alias_words);
+    } else {
+        MR_ensure_room_for_next(MR_alias_record, MR_Alias, INIT_ALIAS_COUNT);
+        MR_prepare_insert_into_sorted(MR_alias_records, MR_alias_record_next,
+            slot, strcmp(MR_alias_records[slot].MR_alias_name, name));
+    }
+
+    MR_alias_records[slot].MR_alias_name = MR_copy_string(name);
+    MR_alias_records[slot].MR_alias_word_count = word_count;
+    MR_alias_records[slot].MR_alias_words = MR_NEW_ARRAY(char *, word_count);
+    for (i = 0; i < word_count; i++) {
+        MR_alias_records[slot].MR_alias_words[i] = MR_copy_string(words[i]);
+    }
 }
 
 MR_bool
 MR_trace_remove_alias(const char *name)
 {
-	MR_bool	found;
-	int	slot;
-	int	i;
-	int	count;
-
-	MR_bsearch(MR_alias_record_next, slot, found,
-		strcmp(MR_alias_records[slot].MR_alias_name, name));
-	if (! found) {
-		return MR_FALSE;
-	} else {
-		count = MR_alias_records[slot].MR_alias_word_count;
-		for (i = 0; i < count; i++) {
-			MR_free(MR_alias_records[slot].MR_alias_words[i]);
-		}
-
-		MR_free(MR_alias_records[slot].MR_alias_name);
-		MR_free(MR_alias_records[slot].MR_alias_words);
-
-		for (i = slot; i < MR_alias_record_next - 1; i++) {
-			MR_assign_structure(MR_alias_records[slot],
-				MR_alias_records[slot + 1]);
-		}
+    MR_bool found;
+    int     slot;
+    int     i;
+    int     count;
+
+    MR_bsearch(MR_alias_record_next, slot, found,
+        strcmp(MR_alias_records[slot].MR_alias_name, name));
+    if (! found) {
+        return MR_FALSE;
+    } else {
+        count = MR_alias_records[slot].MR_alias_word_count;
+        for (i = 0; i < count; i++) {
+            MR_free(MR_alias_records[slot].MR_alias_words[i]);
+        }
+
+        MR_free(MR_alias_records[slot].MR_alias_name);
+        MR_free(MR_alias_records[slot].MR_alias_words);
+
+        for (i = slot; i < MR_alias_record_next - 1; i++) {
+            MR_assign_structure(MR_alias_records[slot],
+                MR_alias_records[slot + 1]);
+        }
 
-		MR_alias_record_next--;
+        MR_alias_record_next--;
 
-		return MR_TRUE;
-	}
+        return MR_TRUE;
+    }
 }
 
 MR_bool
 MR_trace_lookup_alias(const char *name,
-	char ***words_ptr, int *word_count_ptr)
+    char ***words_ptr, int *word_count_ptr)
 {
-	MR_bool	found;
-	int	slot;
+    MR_bool found;
+    int slot;
 
-	MR_bsearch(MR_alias_record_next, slot, found,
-		strcmp(MR_alias_records[slot].MR_alias_name, name));
-	if (found) {
-		*word_count_ptr = MR_alias_records[slot].MR_alias_word_count;
-		*words_ptr = MR_alias_records[slot].MR_alias_words;
-		return MR_TRUE;
-	} else {
-		return MR_FALSE;
-	}
+    MR_bsearch(MR_alias_record_next, slot, found,
+        strcmp(MR_alias_records[slot].MR_alias_name, name));
+    if (found) {
+        *word_count_ptr = MR_alias_records[slot].MR_alias_word_count;
+        *words_ptr = MR_alias_records[slot].MR_alias_words;
+        return MR_TRUE;
+    } else {
+        return MR_FALSE;
+    }
 }
 
 void
 MR_trace_print_alias(FILE *fp, const char *name)
 {
-	MR_bool	found;
-	int	slot;
+    MR_bool found;
+    int     slot;
 
-	MR_bsearch(MR_alias_record_next, slot, found,
-		strcmp(MR_alias_records[slot].MR_alias_name, name));
-	if (found) {
-		MR_trace_print_alias_num(fp, slot, MR_FALSE);
-	} else {
-		fprintf(fp, "There is no such alias.\n");
-	}
+    MR_bsearch(MR_alias_record_next, slot, found,
+        strcmp(MR_alias_records[slot].MR_alias_name, name));
+    if (found) {
+        MR_trace_print_alias_num(fp, slot, MR_FALSE);
+    } else {
+        fprintf(fp, "There is no such alias.\n");
+    }
 }
 
 void
 MR_trace_print_all_aliases(FILE *fp, MR_bool mdb_command_format)
 {
-	int	slot;
+    int slot;
 
-	for (slot = 0; slot < MR_alias_record_next; slot++) {
-		MR_trace_print_alias_num(fp, slot, mdb_command_format);
-	}
+    for (slot = 0; slot < MR_alias_record_next; slot++) {
+        MR_trace_print_alias_num(fp, slot, mdb_command_format);
+    }
 }
 
 static void
 MR_trace_print_alias_num(FILE *fp, int slot, MR_bool mdb_command_format)
 {
-	int	i;
+    int i;
 
-	if (mdb_command_format) {
-		fprintf(fp, "alias %s", MR_alias_records[slot].MR_alias_name);
-	} else {
-		fprintf(fp, "%-6s =>   ", MR_alias_records[slot].MR_alias_name);
-	}
-
-	for (i = 0; i < MR_alias_records[slot].MR_alias_word_count; i++) {
-		fprintf(fp, " %s", MR_alias_records[slot].MR_alias_words[i]);
-	}
+    if (mdb_command_format) {
+        fprintf(fp, "alias %s", MR_alias_records[slot].MR_alias_name);
+    } else {
+        fprintf(fp, "%-6s =>   ", MR_alias_records[slot].MR_alias_name);
+    }
+
+    for (i = 0; i < MR_alias_records[slot].MR_alias_word_count; i++) {
+        fprintf(fp, " %s", MR_alias_records[slot].MR_alias_words[i]);
+    }
 
-	fprintf(fp, "\n");
+    fprintf(fp, "\n");
 }
 
 MR_Completer_List *
 MR_trace_alias_completer(const char *word, size_t word_length)
 {
-	/*
-	** Remove "EMPTY" and "NUMBER" from the possible matches.
-	*/
-	return MR_trace_filter_completer(MR_trace_filter_alias_completions,
-		NULL, MR_trace_no_free,
-		MR_trace_sorted_array_completer(word, word_length,
-			MR_alias_record_next, MR_trace_get_alias_slot_name));
+    /*
+    ** Remove "EMPTY" and "NUMBER" from the possible matches.
+    */
+    return MR_trace_filter_completer(MR_trace_filter_alias_completions,
+        NULL, MR_trace_no_free,
+        MR_trace_sorted_array_completer(word, word_length,
+            MR_alias_record_next, MR_trace_get_alias_slot_name));
 }
 
 static char *
 MR_trace_get_alias_slot_name(int slot)
 {
-	return MR_alias_records[slot].MR_alias_name;
+    return MR_alias_records[slot].MR_alias_name;
 }
 
 static MR_bool
 MR_trace_filter_alias_completions(const char *word, MR_Completer_Data *data)
 {
-	return (MR_strdiff(word, "EMPTY") && MR_strdiff(word, "NUMBER"));
+    return (MR_strdiff(word, "EMPTY") && MR_strdiff(word, "NUMBER"));
 }
Index: trace/mercury_trace_alias.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_alias.h,v
retrieving revision 1.5
diff -u -r1.5 mercury_trace_alias.h
--- trace/mercury_trace_alias.h	6 Mar 2002 14:35:03 -0000	1.5
+++ trace/mercury_trace_alias.h	29 Mar 2006 12:50:28 -0000
@@ -1,4 +1,7 @@
 /*
+** vim: ts=4 sw=4 expandtab
+*/
+/*
 ** Copyright (C) 1998,2000-2002 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -10,18 +13,18 @@
 ** Defines the interface of the alias system for the internal debugger.
 */
 
-#ifndef	MERCURY_TRACE_ALIAS_H
+#ifndef MERCURY_TRACE_ALIAS_H
 #define MERCURY_TRACE_ALIAS_H
 
-#include "mercury_std.h"	/* for MR_bool */
+#include "mercury_std.h"    /* for MR_bool */
 #include <stdio.h>
 
 #include "mercury_trace_completion.h"
 
 typedef struct {
-	char		*MR_alias_name;
-	char		**MR_alias_words;
-	int		MR_alias_word_count;
+    char        *MR_alias_name;
+    char        **MR_alias_words;
+    int         MR_alias_word_count;
 } MR_Alias;
 
 /*
@@ -33,8 +36,8 @@
 ** Overwrites any previous alias with the same name.
 */
 
-extern	void		MR_trace_add_alias(char *name, char **words,
-				int word_count);
+extern  void        MR_trace_add_alias(char *name, char **words,
+                        int word_count);
 
 /*
 ** Remove the given alias from the list. Returns MR_FALSE if there is no
@@ -42,7 +45,7 @@
 ** successful.
 */
 
-extern	MR_bool		MR_trace_remove_alias(const char *name);
+extern  MR_bool     MR_trace_remove_alias(const char *name);
 
 /*
 ** Looks up whether the given alias exists. If yes, returns MR_TRUE, and
@@ -51,15 +54,15 @@
 ** returns MR_FALSE.
 */
 
-extern	MR_bool		MR_trace_lookup_alias(const char *name,
-				char ***words_ptr, int *word_count_ptr);
+extern  MR_bool     MR_trace_lookup_alias(const char *name,
+                        char ***words_ptr, int *word_count_ptr);
 
 /*
 ** Print the alias of the given name, if it exists, and an error message
 ** if it does not.
 */
 
-extern	void		MR_trace_print_alias(FILE *fp, const char *name);
+extern  void        MR_trace_print_alias(FILE *fp, const char *name);
 
 /*
 ** Print all the aliases to the given file. If mdb_command_format is MR_TRUE,
@@ -67,11 +70,12 @@
 ** Otherwise, print the aliases in a format that is nice for humans to read.
 */
 
-extern	void		MR_trace_print_all_aliases(FILE *fp,
-				MR_bool mdb_command_format);
+extern  void        MR_trace_print_all_aliases(FILE *fp,
+                        MR_bool mdb_command_format);
 
 /* A Readline completer for aliases. */ 
-extern	MR_Completer_List *MR_trace_alias_completer(const char *word,
-				size_t word_length);
+extern  MR_Completer_List
+                    *MR_trace_alias_completer(const char *word,
+                        size_t word_length);
 
-#endif	/* MERCURY_TRACE_ALIAS_H */
+#endif  /* MERCURY_TRACE_ALIAS_H */
Index: trace/mercury_trace_browse.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_browse.c,v
retrieving revision 1.37
diff -u -r1.37 mercury_trace_browse.c
--- trace/mercury_trace_browse.c	3 Aug 2005 13:42:45 -0000	1.37
+++ trace/mercury_trace_browse.c	29 Mar 2006 12:02:55 -0000
@@ -304,78 +304,70 @@
         MR_trace_is_portray_format(value, &new_format))
     {
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_format_from_mdb(print, browse,
+            ML_BROWSE_set_format_from_mdb(print, browse,
                 print_all, new_format,
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else if (MR_streq(param, "depth") &&
+    } else if (MR_streq(param, "depth") &&
         MR_trace_is_natural_number(value, &depth))
     {
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_depth_from_mdb(print, browse, print_all,
+            ML_BROWSE_set_depth_from_mdb(print, browse, print_all,
                 flat, raw_pretty, verbose, pretty, depth,
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else if (MR_streq(param, "size") &&
+    } else if (MR_streq(param, "size") &&
         MR_trace_is_natural_number(value, &size))
     {
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_size_from_mdb(print, browse, print_all,
+            ML_BROWSE_set_size_from_mdb(print, browse, print_all,
                 flat, raw_pretty, verbose, pretty, size,
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else if (MR_streq(param, "width") &&
+    } else if (MR_streq(param, "width") &&
         MR_trace_is_natural_number(value, &width))
     {
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_width_from_mdb(print, browse, print_all,
+            ML_BROWSE_set_width_from_mdb(print, browse, print_all,
                 flat, raw_pretty, verbose, pretty, width,
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else if (MR_streq(param, "lines") &&
+    } else if (MR_streq(param, "lines") &&
         MR_trace_is_natural_number(value, &lines))
     {
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_lines_from_mdb(print, browse, print_all,
+            ML_BROWSE_set_lines_from_mdb(print, browse, print_all,
                 flat, raw_pretty, verbose, pretty, lines,
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else if (MR_streq(param, "xml_browser_cmd")) {
-        copied_value = (char*)MR_GC_malloc(strlen(value) + 1);
+    } else if (MR_streq(param, "xml_browser_cmd")) {
+        copied_value = (char *) MR_GC_malloc(strlen(value) + 1);
         strcpy(copied_value, value);
         MR_TRACE_USE_HP(
             MR_make_aligned_string(aligned_value, copied_value);
         );
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_xml_browser_cmd_from_mdb(aligned_value, 
+            ML_BROWSE_set_xml_browser_cmd_from_mdb(aligned_value, 
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else if (MR_streq(param, "xml_tmp_filename")) {
-        copied_value = (char*)MR_GC_malloc(strlen(value) + 1);
+    } else if (MR_streq(param, "xml_tmp_filename")) {
+        copied_value = (char *) MR_GC_malloc(strlen(value) + 1);
         strcpy(copied_value, value);
         MR_TRACE_USE_HP(
             MR_make_aligned_string(aligned_value, copied_value);
         );
         MR_TRACE_CALL_MERCURY(
-            ML_BROWSE_set_param_xml_tmp_filename_from_mdb(aligned_value, 
+            ML_BROWSE_set_xml_tmp_filename_from_mdb(aligned_value, 
                 MR_trace_browser_persistent_state,
                 &MR_trace_browser_persistent_state);
         );
-    }
-    else
-    {
+    } else {
         return MR_FALSE;
     }
 
@@ -404,6 +396,20 @@
         return MR_TRUE;
     }
     return MR_FALSE;
+}
+
+void
+MR_trace_print_all_browser_params(FILE *fp, MR_bool mdb_command_format)
+{
+    MR_String   param_string;
+
+    MR_trace_browse_ensure_init();
+    MR_TRACE_CALL_MERCURY(
+        ML_BROWSE_browser_params_to_string(MR_trace_browser_persistent_state,
+            mdb_command_format, &param_string);
+    );
+
+    fprintf(fp, param_string);
 }
 
 void
Index: trace/mercury_trace_browse.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_browse.h,v
retrieving revision 1.21
diff -u -r1.21 mercury_trace_browse.h
--- trace/mercury_trace_browse.h	24 Oct 2005 02:02:17 -0000	1.21
+++ trace/mercury_trace_browse.h	29 Mar 2006 08:21:41 -0000
@@ -44,6 +44,7 @@
 ** browser/browser_info.m, so that it is possible to cast to/from MR_Word
 ** in order to interface with Mercury code.
 */
+
 typedef enum {
 	MR_DEFINE_MERCURY_ENUM_CONST(MR_BROWSE_CALLER_PRINT),
 	MR_DEFINE_MERCURY_ENUM_CONST(MR_BROWSE_CALLER_BROWSE),
@@ -65,6 +66,7 @@
 /*
 ** Interactively browse a term.
 */
+
 extern 	void	MR_trace_browse(MR_Word type_info, MR_Word value,
 			MR_Browse_Format format);
 extern 	void	MR_trace_browse_goal(MR_ConstString name, MR_Word arg_list,
@@ -77,11 +79,13 @@
 /*
 ** Browse a term using an XML browser.
 */
+
 extern	void	MR_trace_save_and_invoke_xml_browser(MR_Word browser_term);
 
 /*
 ** Display a term non-interactively.
 */
+
 extern	void	MR_trace_print(MR_Word type_info, MR_Word value,
 			MR_Browse_Caller_Type caller, MR_Browse_Format format);
 extern	void	MR_trace_print_goal(MR_ConstString name, MR_Word arg_list,
@@ -91,10 +95,20 @@
 /*
 ** Set browser parameters.
 */
+
 extern	MR_bool	MR_trace_set_browser_param(MR_Word print, MR_Word browse,
 			MR_Word print_all, MR_Word flat, MR_Word raw_pretty,
 			MR_Word verbose, MR_Word pretty, const char *param, 
 			const char *value);
+
+/*
+** Print all the browser parameters. If mdb_command_format is true, print them
+** in the form of the mdb commands required to recreate this state; otherwise,
+** print them in a user-friendly form.
+*/
+
+extern	void	MR_trace_print_all_browser_params(FILE *fp,
+			MR_bool mdb_command_format);
 
 /*
 ** Invoke an interactive query.
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.221
diff -u -r1.221 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	1 Mar 2006 22:58:50 -0000	1.221
+++ trace/mercury_trace_internal.c	29 Mar 2006 14:32:23 -0000
@@ -231,11 +231,11 @@
 static  MR_bool     MR_print_goal_paths = MR_TRUE;
 
 /*
-** MR_LISTING_path holds the current value of the listings structure
+** MR_listing_path holds the current value of the listings structure
 ** as defined in browser/listing.m.
 */
 
-static  MR_Word     MR_LISTING_path;
+static  MR_Word     MR_listing_path;
 
 /*
 ** MR_num_context_lines holds the current number of context lines to be
@@ -476,7 +476,7 @@
 static  MR_TraceCmdFunc MR_trace_cmd_view;
 static  MR_TraceCmdFunc MR_trace_cmd_hold;
 static  MR_TraceCmdFunc MR_trace_cmd_diff;
-static  MR_TraceCmdFunc MR_trace_cmd_save_to_file;
+static  MR_TraceCmdFunc MR_trace_cmd_dump;
 static  MR_TraceCmdFunc MR_trace_cmd_list;
 static  MR_TraceCmdFunc MR_trace_cmd_set_list_dir_path;
 static  MR_TraceCmdFunc MR_trace_cmd_push_list_dir;
@@ -629,7 +629,7 @@
                         char ***words, int *word_count);
 static  MR_bool     MR_trace_options_diff(int *start, int *max,
                         char ***words, int *word_count);
-static  MR_bool     MR_trace_options_save_to_file(MR_bool *xml,
+static  MR_bool     MR_trace_options_dump(MR_bool *xml,
                         char ***words, int *word_count);
 static  MR_bool     MR_trace_options_dice(char **pass_trace_counts_file,
                         char **fail_trace_count_file, char **sort_str,
@@ -1016,10 +1016,9 @@
 #if defined(MR_HAVE_TCGETATTR) && defined(MR_HAVE_TCSETATTR) && \
         defined(ECHO) && defined(TCSADRAIN)
     /*
-    ** Turn off echoing before starting the xterm so that
-    ** the user doesn't see the window ID printed by xterm
-    ** on startup (this behaviour is not documented in the
-    ** xterm manual).
+    ** Turn off echoing before starting the xterm so that the user doesn't see
+    ** the window ID printed by xterm on startup (this behaviour is not
+    ** documented in the xterm manual).
     */
     tcgetattr(slave_fd, &termio);
     termio.c_lflag &= ~ECHO;
@@ -1460,8 +1459,8 @@
                 problem = MR_trace_parse_browse_one(MR_mdb_out, MR_TRUE,
                     node->p_name, MR_trace_browse_internal,
                     MR_BROWSE_CALLER_PRINT, node->p_format, MR_FALSE);
-                if (problem != NULL && MR_streq(problem,
-                    "there is no such variable"))
+                if (problem != NULL &&
+                    MR_streq(problem, "there is no such variable"))
                 {
                     if (node->p_warn) {
                         problem = "there is no variable named";
@@ -2307,35 +2306,41 @@
     MR_Word             raw_pretty_format;
     MR_Word             verbose_format;
     MR_Word             pretty_format;
+    int                 max_io_actions;
 
     if (word_count >= 3 && MR_streq(words[1], "list_context_lines")) {
-
         if (word_count > 3
             || !MR_trace_is_natural_number(words[2], &MR_num_context_lines)) {
             MR_trace_usage_cur_cmd();
         }
-
     } else if (word_count >= 3 && MR_streq(words[1], "list_path")) {
-
         MR_trace_cmd_set_list_dir_path(words, word_count, cmd, event_info,
             jumpaddr);
-
-    } else if (word_count == 3 && (  MR_streq(words[1], "fail_trace_count")
-                                  || MR_streq(words[1], "fail_trace_counts")))
+    } else if (word_count == 3 &&
+        (  MR_streq(words[1], "fail_trace_count")
+        || MR_streq(words[1], "fail_trace_counts")))
     {
         if (MR_dice_fail_trace_counts_file != NULL) {
             free(MR_dice_fail_trace_counts_file);
         }
         MR_dice_fail_trace_counts_file = MR_copy_string(words[2]);
-
-    } else if (word_count == 3 && (  MR_streq(words[1], "pass_trace_count")
-                                  || MR_streq(words[1], "pass_trace_counts")))
+    } else if (word_count == 3 &&
+        (  MR_streq(words[1], "pass_trace_count")
+        || MR_streq(words[1], "pass_trace_counts")))
     {
         if (MR_dice_pass_trace_counts_file != NULL) {
             free(MR_dice_pass_trace_counts_file);
         }
         MR_dice_pass_trace_counts_file = MR_copy_string(words[2]);
-
+    } else if (word_count == 3 &&
+        MR_streq(words[1], "max_io_actions") &&
+        MR_trace_is_natural_number(words[2], &max_io_actions))
+    {
+        MR_TRACE_CALL_MERCURY(
+            ML_BROWSE_set_num_io_actions_from_mdb(max_io_actions,
+                MR_trace_browser_persistent_state,
+                &MR_trace_browser_persistent_state);
+        );
     } else if (! MR_trace_options_param_set(&print_set, &browse_set,
         &print_all_set, &flat_format, &raw_pretty_format, &verbose_format,
         &pretty_format, &words, &word_count))
@@ -2500,7 +2505,7 @@
 }
 
 static MR_Next
-MR_trace_cmd_save_to_file(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+MR_trace_cmd_dump(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
     MR_Event_Info *event_info, MR_Code **jumpaddr)
 {
     MR_bool         verbose = MR_FALSE;
@@ -2513,7 +2518,7 @@
     */
     browser_term = (MR_Word) NULL;
 
-    if (! MR_trace_options_save_to_file(&xml, &words, &word_count)) {
+    if (! MR_trace_options_dump(&xml, &words, &word_count)) {
         ; /* the usage message has already been printed */
     } else if (word_count != 3) {
         MR_trace_usage_cur_cmd();
@@ -2582,18 +2587,18 @@
     return KEEP_INTERACTING;
 }
 
-    /*
-    ** list [num]
-    **  List num lines of context around the line number of the context of the
-    **  current point (i.e., level in the call stack).  If num is not given,
-    **  the number of context lines defaults to the value of the context_lines
-    **  setting.
-    **
-    ** TODO: add the following (use MR_parse_source_locn()):
-    ** list filename:num[-num]
-    **  List a range of lines from a given file.  If only one number is
-    **  given, the default number of lines of context is used.
-    */
+/*
+** list [num]
+**  List num lines of context around the line number of the context of the
+**  current point (i.e., level in the call stack).  If num is not given,
+**  the number of context lines defaults to the value of the context_lines
+**  setting.
+**
+** TODO: add the following (use MR_parse_source_locn()):
+** list filename:num[-num]
+**  List a range of lines from a given file.  If only one number is
+**  given, the default number of lines of context is used.
+*/
 
 static MR_Next
 MR_trace_cmd_list(char **words, int word_count,
@@ -2627,8 +2632,8 @@
     );
 
     MR_TRACE_CALL_MERCURY(
-        MR_LISTING_list_file(MR_mdb_out, MR_mdb_err, (char *) aligned_filename,
-            lineno - num, lineno + num, lineno, MR_LISTING_path);
+        ML_LISTING_list_file(MR_mdb_out, MR_mdb_err, (char *) aligned_filename,
+            lineno - num, lineno + num, lineno, MR_listing_path);
     );
 
     return KEEP_INTERACTING;
@@ -2644,13 +2649,13 @@
     MR_trace_listing_path_ensure_init();
 
     MR_TRACE_CALL_MERCURY(
-        MR_LISTING_clear_list_path(MR_LISTING_path, &MR_LISTING_path);
+        ML_LISTING_clear_list_path(MR_listing_path, &MR_listing_path);
         for(i = word_count - 1; i >= 1; i--) {
             MR_TRACE_USE_HP(
                 MR_make_aligned_string(aligned_word, (MR_String) words[i]);
             );
-            MR_LISTING_push_list_path(aligned_word,
-                MR_LISTING_path, &MR_LISTING_path);
+            ML_LISTING_push_list_path(aligned_word,
+                MR_listing_path, &MR_listing_path);
         }
     );
 
@@ -2676,8 +2681,8 @@
             MR_TRACE_USE_HP(
                 MR_make_aligned_string(aligned_word, (MR_String) words[i]);
             );
-            MR_LISTING_push_list_path(aligned_word,
-                MR_LISTING_path, &MR_LISTING_path);
+            ML_LISTING_push_list_path(aligned_word,
+                MR_listing_path, &MR_listing_path);
         }
     );
 
@@ -2696,7 +2701,7 @@
     }
 
     MR_TRACE_CALL_MERCURY(
-        MR_LISTING_pop_list_path(MR_LISTING_path, &MR_LISTING_path);
+        ML_LISTING_pop_list_path(MR_listing_path, &MR_listing_path);
     );
 
     return KEEP_INTERACTING;
@@ -2709,7 +2714,7 @@
 
     if (! MR_trace_listing_path_initialized) {
         MR_TRACE_CALL_MERCURY(
-            MR_LISTING_path = MR_LISTING_new_list_path();
+            MR_listing_path = ML_LISTING_new_list_path();
         );
         MR_trace_listing_path_initialized = MR_TRUE;
     }
@@ -2824,8 +2829,7 @@
             fprintf(MR_mdb_err,
                 "Ambiguous procedure specification. The matches are:\n");
 
-            for (i = 0; i < matches.match_proc_next; i++)
-            {
+            for (i = 0; i < matches.match_proc_next; i++) {
                 fprintf(MR_mdb_out, "%d: ", i);
                 MR_print_proc_id_and_nl(MR_mdb_out, matches.match_procs[i]);
             }
@@ -3019,8 +3023,7 @@
         &words, &word_count))
     {
         ; /* the usage message has already been printed */
-    } else if (word_count == 2 && MR_trace_is_natural_number(words[1], &n))
-    {
+    } else if (word_count == 2 && MR_trace_is_natural_number(words[1], &n)) {
         if (0 <= n && n < MR_spy_point_next && MR_spy_points[n]->spy_exists) {
             problem = MR_ignore_spy_point(n, ignore_when, ignore_count);
             MR_maybe_print_spy_point(n, problem);
@@ -3078,8 +3081,7 @@
         &words, &word_count))
     {
         ; /* the usage message has already been printed */
-    } else if (word_count > 2 && MR_trace_is_natural_number(words[1], &n))
-    {
+    } else if (word_count > 2 && MR_trace_is_natural_number(words[1], &n)) {
         if (word_count == 3 && MR_streq(words[2], "none")) {
             MR_clear_spy_point_print_list(n);
             MR_print_spy_point(MR_mdb_out, n, MR_TRUE);
@@ -4471,7 +4473,7 @@
     } else if (word_count == 2 && MR_streq(words[1], "on")) {
         MR_print_optionals = MR_TRUE;
         MR_trace_set_level(MR_trace_current_level(), MR_print_optionals);
-    } else if (word_count == 1)  {
+    } else if (word_count == 1) {
         fprintf(MR_mdb_out, "optional values are %sbeing printed\n",
             MR_print_optionals? "" : "not ");
     } else {
@@ -4492,7 +4494,7 @@
         MR_trace_unhide_events = MR_TRUE;
         MR_trace_have_unhid_events = MR_TRUE;
         fprintf(MR_mdb_out, "Hidden events are exposed.\n");
-    } else if (word_count == 1)  {
+    } else if (word_count == 1) {
         fprintf(MR_mdb_out, "Hidden events are %s.\n",
             MR_trace_unhide_events? "exposed" : "hidden");
     } else {
@@ -4524,8 +4526,7 @@
         fflush(MR_mdb_out);
         fprintf(MR_mdb_err, "Ambiguous procedure specification. "
             "The matches are:\n");
-        for (i = 0; i < matches.match_proc_next; i++)
-        {
+        for (i = 0; i < matches.match_proc_next; i++) {
             fprintf(MR_mdb_out, "%d: ", i);
             MR_print_proc_id_and_nl(MR_mdb_out, matches.match_procs[i]);
         }
@@ -4869,8 +4870,7 @@
     MR_Integer  n;
     MR_TrieNode table_next;
 
-    if (! MR_trace_is_integer(given_arg, &n))
-    {
+    if (! MR_trace_is_integer(given_arg, &n)) {
         fprintf(MR_mdb_out, "argument %d is not an integer.\n", arg_num);
         return MR_FALSE;
     }
@@ -5778,6 +5778,7 @@
     if (word_count == 2) {
         FILE    *fp;
         MR_bool found_error;
+        MR_Word path_list;
 
         fp = fopen(words[1], "w");
         if (fp == NULL) {
@@ -5788,6 +5789,63 @@
         }
 
         MR_trace_print_all_aliases(fp, MR_TRUE);
+        switch (MR_default_print_level) {
+            case MR_PRINT_LEVEL_NONE:
+                fprintf(fp, "printlevel none\n");
+                break;
+
+            case MR_PRINT_LEVEL_SOME:
+                fprintf(fp, "printlevel some\n");
+                break;
+
+            case MR_PRINT_LEVEL_ALL:
+                fprintf(fp, "printlevel all\n");
+                break;
+        }
+
+        if (MR_echo_commands) {
+            fprintf(fp, "echo on\n");
+        } else {
+            fprintf(fp, "echo off\n");
+        }
+
+        if (MR_scroll_control) {
+            fprintf(fp, "scroll on\n");
+        } else {
+            fprintf(fp, "scroll off\n");
+        }
+
+        fprintf(fp, "scroll %d\n", MR_scroll_limit);
+        fprintf(fp, "stack_default_limit %d\n", MR_stack_default_line_limit);
+
+        switch (MR_context_position) {
+            case MR_CONTEXT_NOWHERE:
+                fprintf(fp, "context nowhere\n");
+                break;
+
+            case MR_CONTEXT_AFTER:
+                fprintf(fp, "context after\n");
+                break;
+
+            case MR_CONTEXT_BEFORE:
+                fprintf(fp, "context before\n");
+                break;
+
+            case MR_CONTEXT_PREVLINE:
+                fprintf(fp, "context prevline\n");
+                break;
+
+            case MR_CONTEXT_NEXTLINE:
+                fprintf(fp, "context nextline\n");
+                break;
+        }
+
+        if (MR_print_goal_paths) {
+            fprintf(fp, "goal_paths on\n");
+        } else {
+            fprintf(fp, "goal_paths off\n");
+        }
+
         found_error = MR_save_spy_points(fp, MR_mdb_err);
 
         switch (MR_default_breakpoint_scope) {
@@ -5803,12 +5861,36 @@
                 fprintf(fp, "scope entry\n");
                 break;
 
-            default:
+            case MR_SPY_LINENO:
+            case MR_SPY_SPECIFIC:
                 MR_fatal_error("save cmd: invalid default scope");
         }
 
+        MR_trace_print_all_browser_params(fp, MR_TRUE);
         MR_decl_print_all_trusted(fp, MR_TRUE);
 
+        if (MR_dice_fail_trace_counts_file != NULL) {
+            fprintf(fp, "set fail_trace_counts %s\n",
+                MR_dice_fail_trace_counts_file);
+        }
+        if (MR_dice_pass_trace_counts_file != NULL) {
+            fprintf(fp, "set pass_trace_counts %s\n",
+                MR_dice_pass_trace_counts_file);
+        }
+
+        fprintf(fp, "set list_context_lines %d\n", MR_num_context_lines);
+        MR_TRACE_CALL_MERCURY(
+            path_list = ML_LISTING_get_list_path(MR_listing_path);
+            if (! MR_list_is_empty(path_list)) {
+                fprintf(fp, "set list_path");
+                while (! MR_list_is_empty(path_list)) {
+                    fprintf(fp, " %s", (const char *) MR_list_head(path_list));
+                    path_list = MR_list_tail(path_list);
+                }
+                fprintf(fp, "\n");
+            }
+        );
+
         if (found_error) {
             fflush(MR_mdb_out);
             fprintf(MR_mdb_err, "mdb: could not save debugger state to %s.\n",
@@ -5975,7 +6057,7 @@
         if (matches.match_proc_next > 0) {
             MR_decl_add_trusted_module(words[1]);
             fprintf(MR_mdb_out, "Trusting module %s\n", words[1]);
-        } else if (MR_parse_proc_spec(words[1], &spec)){
+        } else if (MR_parse_proc_spec(words[1], &spec)) {
             /* Check to see if the argument is a pred/func */
             matches = MR_search_for_matching_procedures(&spec);
             MR_filter_user_preds(&matches);
@@ -6246,8 +6328,8 @@
 */
 static const char *
 MR_trace_new_source_window(const char *window_cmd, const char *server_cmd,
-        const char *server_name, int timeout, MR_bool force,
-        MR_bool verbose, MR_bool split)
+    const char *server_name, int timeout, MR_bool force,
+    MR_bool verbose, MR_bool split)
 {
     const char  *msg;
 
@@ -6269,13 +6351,10 @@
         MR_trace_source_server.server_cmd = NULL;
     }
 
-    if (server_name == NULL)
-    {
+    if (server_name == NULL) {
         msg = MR_trace_source_open_server(&MR_trace_source_server,
                 window_cmd, timeout, verbose);
-    }
-    else
-    {
+    } else {
         MR_trace_source_server.server_name = MR_copy_string(server_name);
         msg = MR_trace_source_attach(&MR_trace_source_server, timeout,
             verbose);
@@ -7557,20 +7636,20 @@
     return MR_TRUE;
 }
 
-static struct MR_option MR_trace_save_to_file_opts[] =
+static struct MR_option MR_trace_dump_opts[] =
 {
     { "xml",        MR_no_argument,     NULL,   'x' },
     { NULL,         MR_no_argument,     NULL,   0 }
 };
 
 static MR_bool
-MR_trace_options_save_to_file(MR_bool *xml, char ***words, int *word_count)
+MR_trace_options_dump(MR_bool *xml, char ***words, int *word_count)
 {
     int c;
 
     MR_optind = 0;
     while ((c = MR_getopt_long(*word_count, *words, "x",
-        MR_trace_save_to_file_opts, NULL)) != EOF)
+        MR_trace_dump_opts, NULL)) != EOF)
     {
         switch (c) {
 
@@ -7869,8 +7948,7 @@
         alias_copy_start = 1;
     }
 
-    if (MR_trace_lookup_alias(alias_key, &alias_words, &alias_word_count))
-    {
+    if (MR_trace_lookup_alias(alias_key, &alias_words, &alias_word_count)) {
         MR_ensure_big_enough(*word_count + alias_word_count, *word, char *,
             MR_INIT_WORD_COUNT);
 
@@ -8419,7 +8497,7 @@
         NULL, MR_trace_var_completer },
     { "browsing", "diff", MR_trace_cmd_diff,
         NULL, MR_trace_var_completer },
-    { "browsing", "save_to_file", MR_trace_cmd_save_to_file,
+    { "browsing", "dump", MR_trace_cmd_dump,
         NULL, MR_trace_var_completer },
     { "browsing", "list", MR_trace_cmd_list,
         NULL, MR_trace_null_completer },
Index: trace/mercury_trace_spy.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_spy.c,v
retrieving revision 1.25
diff -u -r1.25 mercury_trace_spy.c
--- trace/mercury_trace_spy.c	11 Jul 2005 07:30:31 -0000	1.25
+++ trace/mercury_trace_spy.c	29 Mar 2006 14:32:03 -0000
@@ -1065,6 +1065,37 @@
                 return MR_TRUE;
         }
 
+        if (point->spy_cond != NULL) {
+            MR_Spy_Cond *cond;
+
+            cond = point->spy_cond;
+            fprintf(fp, "condition ");
+
+            if (!cond->cond_require_var) {
+                fprintf(fp, "-v "); /* also implies -p */
+            } else if (!cond->cond_require_path) {
+                fprintf(fp, "-p ");
+            }
+
+            fprintf(fp, "%s ", cond->cond_what_string);
+
+            switch (cond->cond_test) {
+                case MR_SPY_TEST_EQUAL:
+                    fprintf(fp, "= ");
+                    break;
+
+                case MR_SPY_TEST_NOT_EQUAL:
+                    fprintf(fp, "!= ");
+                    break;
+
+                default:
+                    MR_fatal_error("MR_save_spy_points: bad condition test");
+                    break;
+            }
+
+            fprintf(fp, "%s\n", cond->cond_term_string);
+        }
+
         if (!point->spy_enabled) {
             fprintf(fp, "disable\n");
         }
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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