[m-rev.] for review: Allow --xml browse option from within declarative debugger
Ian MacLarty
maclarty at cs.mu.OZ.AU
Sat Feb 19 16:38:47 AEDT 2005
For review by anyone.
Estimated hours taken: 6
Branches: main
Allow an XML term browser to be called from the declarative debugger.
browser/browse.m
Add a predicate to save a term to an XML file and then launch an
XML browser.
Add a predicate that saves a term to an XML file and doesn't print
any error messages, but just returns an io.res result and use this
in save_term_to_file_xml and the predicate mentioned above.
browser/browser_info.m
Add two fields to the browser's persistent state - one to record the
temporary filename to use when saving a term to an XML file and one
to hold the command to launch the XML browser. Previously these were
stored in C global variables which were not accessable from the
declarative debugger.
Export the browser_persistent_state type so the field access functions
can be used from browse.m.
browser/declarative_user.m
Allow the user to give an -x or --xml option to the browse command from
within the declarative debugger.
Reformat the user_command type and add a new functor: browse_xml_arg/1.
Describe the -x or --xml browse option in the help message and reformat
the trust command help message as it was looking a bit untidy.
tests/debugger/browser_test.exp
tests/debugger/browser_test.inp
Test the --xml option from within the declarative debugger.
trace/mercury_trace_browse.c
trace/mercury_trace_browse.h
trace/mercury_trace_internal.c
Move MR_trace_save_and_invoke_xml_browser from mercury_trace_internal.c
to mercury_trace_browse.c so it can call the new Mercury code in
browser/browse.m.
Handle the `set xml_browser_cmd' and `set xml_tmp_filename' commands by
calling Mercury code to set the appropriate fields in the persistent
browser state.
Index: browser/browse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/browse.m,v
retrieving revision 1.50
diff -u -r1.50 browse.m
--- browser/browse.m 24 Jan 2005 07:41:02 -0000 1.50
+++ browser/browse.m 19 Feb 2005 05:06:15 -0000
@@ -44,6 +44,13 @@
browser_persistent_state::in, browser_persistent_state::out,
io::di, io::uo) is cc_multi.
+ % Dump the term as an XML file and launch the XML browser specified
+ % by the xml_browser_cmd field in the browser_persistent_state.
+ %
+:- pred browse__save_and_browse_browser_term_xml(browser_term::in,
+ io__output_stream::in, io__output_stream::in,
+ browser_persistent_state::in, io::di, io::uo) is cc_multi.
+
% As above, except that the supplied format will override the default.
% Again, this is exported to C code, so the browser term mode function
% can't be supplied.
@@ -168,6 +175,9 @@
:- pragma export(save_term_to_file_xml(in, in, in, di, uo),
"ML_BROWSE_save_term_to_file_xml").
+:- pragma export(browse__save_and_browse_browser_term_xml(in, in, in, in,
+ di, uo), "ML_BROWSE_browse_term_xml").
+
%---------------------------------------------------------------------------%
%
% If the term browser is called from the internal debugger, input is
@@ -241,6 +251,20 @@
).
save_term_to_file_xml(FileName, BrowserTerm, OutStream, !IO) :-
+ maybe_save_term_to_file_xml(FileName, BrowserTerm, Result, !IO),
+ (
+ Result = ok
+ ;
+ Result = error(Error),
+ io__error_message(Error, Msg),
+ io__write_string(OutStream, Msg, !IO),
+ io__nl(!IO)
+ ).
+
+:- pred maybe_save_term_to_file_xml(string::in, browser_term::in,
+ io.res::out, io::di, io::uo) is cc_multi.
+
+maybe_save_term_to_file_xml(FileName, BrowserTerm, FileStreamRes, !IO) :-
io__tell(FileName, FileStreamRes, !IO),
(
FileStreamRes = ok,
@@ -265,9 +289,80 @@
),
io__told(!IO)
;
- FileStreamRes = error(Error),
- io__error_message(Error, Msg),
- io__write_string(OutStream, Msg, !IO)
+ FileStreamRes = error(_)
+ ).
+
+browse__save_and_browse_browser_term_xml(Term, OutStream, ErrStream, State,
+ !IO) :-
+ (
+ State ^ xml_browser_cmd = yes(CommandStr),
+ (
+ State ^ xml_tmp_filename = 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)
+ )
+ ;
+ State ^ xml_tmp_filename = no,
+ io.write_string(ErrStream,
+ "mdb: You need to issue a " ++
+ "\"set xml_tmp_filename '<filename>'\" " ++
+ " command first.\n", !IO)
+ )
+ ;
+ State ^ xml_browser_cmd = no,
+ io.write_string(ErrStream, "mdb: You need to issue a " ++
+ "\"set xml_browser_cmd '<command>'\" " ++
+ " command first.\n", !IO)
+ ).
+
+:- pred launch_xml_browser(io.output_stream::in, io.output_stream::in,
+ string::in, io::di, io::uo) is det.
+
+launch_xml_browser(OutStream, ErrStream, CommandStr, !IO) :-
+ io.write_string(OutStream, "Launching XML browser "
+ ++ "(this may take some time) ...\n", !IO),
+ % Flush the output stream, so output appears in the correct order
+ % for tests where the `cat' command is used as the XML browser.
+ io.flush_output(OutStream, !IO),
+ io.call_system_return_signal(CommandStr, Result, !IO),
+ (
+ Result = ok(ExitStatus),
+ (
+ ExitStatus = exited(ExitCode),
+ (
+ ExitCode = 0
+ ->
+ true
+ ;
+ io.write_string(ErrStream,
+ "mdb: The command `" ++ CommandStr ++
+ "' terminated with a non-zero exit "++
+ "code.\n", !IO)
+ )
+ ;
+ ExitStatus = signalled(_),
+ io.write_string(ErrStream, "mdb: The browser " ++
+ "was killed.\n", !IO)
+ )
+ ;
+ Result = error(Error),
+ io.write_string(ErrStream, "mdb: Error launching browser"
+ ++ ": " ++ string.string(Error) ++
+ ".\n", !IO)
).
:- pred save_univ(int::in, univ::in, io::di, io::uo) is cc_multi.
Index: browser/browser_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/browser_info.m,v
retrieving revision 1.18
diff -u -r1.18 browser_info.m
--- browser/browser_info.m 24 Jan 2005 07:41:02 -0000 1.18
+++ browser/browser_info.m 18 Feb 2005 08:31:31 -0000
@@ -116,7 +116,9 @@
; format(portray_format)
; width(int)
; lines(int)
- ; num_io_actions(int).
+ ; num_io_actions(int)
+ ; xml_browser_cmd(string)
+ ; xml_tmp_filename(string).
% Initialise a new browser_info. The optional portray_format
% overrides the default format.
@@ -145,11 +147,24 @@
%---------------------------------------------------------------------------%
- % An abstract data type that holds persistent browser settings.
+ % An data type that holds persistent browser settings.
% This state must be saved by the caller of the browse module
% between calls.
%
-:- type browser_persistent_state.
+:- type browser_persistent_state
+ ---> browser_persistent_state(
+ print_params :: caller_params,
+ browse_params :: caller_params,
+ print_all_params :: caller_params,
+ num_printed_io_actions :: int,
+ % The command to lauch the user's
+ % prefered XML browser.
+ xml_browser_cmd :: maybe(string),
+ % The file to save XML to before
+ % lauching the browser.
+ xml_tmp_filename :: maybe(string)
+ ).
+
% Initialize the persistent browser state with default values.
%
@@ -272,6 +287,29 @@
%
browser_info__set_param(no, P, B, A, no, no, no, no, format(Format)).
+:- pred set_param_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_browser_cmd_from_mdb(in, in,
+ out), "ML_BROWSE_set_param_xml_browser_cmd_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).
+
+:- pred set_param_xml_tmp_filename_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").
+
+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).
+
%
% The following exported functions allow C code to create
% Mercury values of type bool.
@@ -315,14 +353,6 @@
%---------------------------------------------------------------------------%
-:- type browser_persistent_state
- ---> browser_persistent_state(
- print_params :: caller_params,
- browse_params :: caller_params,
- print_all_params :: caller_params,
- num_printed_io_actions :: int
- ).
-
:- type caller_params
---> caller_params(
default_format :: portray_format,
@@ -355,7 +385,7 @@
caller_type_browse_defaults(Browse),
caller_type_print_all_defaults(PrintAll),
State = browser_persistent_state(Print, Browse, PrintAll,
- num_printed_io_actions_default).
+ num_printed_io_actions_default, no, no).
:- pred caller_type_print_defaults(caller_params).
:- mode caller_type_print_defaults(out) is det.
@@ -407,6 +437,10 @@
Setting, State0, State) :-
( Setting = num_io_actions(NumIoActions) ->
State = State0 ^ num_printed_io_actions := NumIoActions
+ ; Setting = xml_browser_cmd(CommandStr) ->
+ State = State0 ^ xml_browser_cmd := yes(CommandStr)
+ ; Setting = xml_tmp_filename(CommandStr) ->
+ State = State0 ^ xml_tmp_filename := yes(CommandStr)
;
(
FromBrowser = no,
@@ -433,7 +467,8 @@
maybe_set_param(B, F, Pr, V, NPr, Setting, BParams0, BParams),
maybe_set_param(A, F, Pr, V, NPr, Setting, AParams0, AParams),
State = browser_persistent_state(PParams, BParams, AParams,
- State0 ^ num_printed_io_actions)
+ State0 ^ num_printed_io_actions,
+ State0 ^ xml_browser_cmd, State0 ^ xml_tmp_filename)
).
browser_info.set_param(FromBrowser, OptionTable, Setting, !State) :-
@@ -542,6 +577,10 @@
maybe_set_param_2(yes, lines(L), Params, Params ^ lines := L).
maybe_set_param_2(yes, num_io_actions(_), _, _) :-
error("maybe_set_param_2: num_io_actions").
+maybe_set_param_2(yes, xml_browser_cmd(_), _, _) :-
+ error("maybe_set_param_2: xml_browser_cmd").
+maybe_set_param_2(yes, xml_tmp_filename(_), _, _) :-
+ error("maybe_set_param_2: xml_tmp_filename").
:- pred get_caller_params(browser_persistent_state::in, browse_caller_type::in,
caller_params::out) is det.
Index: browser/declarative_user.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_user.m,v
retrieving revision 1.43
diff -u -r1.43 declarative_user.m
--- browser/declarative_user.m 10 Feb 2005 04:41:43 -0000 1.43
+++ browser/declarative_user.m 19 Feb 2005 05:15:59 -0000
@@ -161,6 +161,19 @@
)
).
+handle_command(browse_xml_arg(MaybeArgNum), UserQuestion, Response,
+ !User, !IO) :-
+ Question = get_decl_question(UserQuestion),
+ edt_node_trace_atoms(Question, _, FinalAtom),
+ (
+ MaybeArgNum = yes(ArgNum),
+ browse_xml_atom_argument(FinalAtom, ArgNum, !.User, !IO)
+ ;
+ MaybeArgNum = no,
+ browse_xml_atom(FinalAtom, !.User, !IO)
+ ),
+ query_user(UserQuestion, Response, !User, !IO).
+
handle_command(print_arg(From, To), UserQuestion, Response,
!User, !IO) :-
Question = get_decl_question(UserQuestion),
@@ -383,6 +396,19 @@
browse_atom(InitAtom, FinalAtom, _, !User, !IO)
).
+:- pred browse_xml_decl_bug(decl_bug::in, maybe(int)::in, user_state::in,
+ io::di, io::uo) is cc_multi.
+
+browse_xml_decl_bug(Bug, MaybeArgNum, User, !IO) :-
+ decl_bug_trace_atom(Bug, _, FinalAtom),
+ (
+ MaybeArgNum = yes(ArgNum),
+ browse_xml_atom_argument(FinalAtom, ArgNum, User, !IO)
+ ;
+ MaybeArgNum = no,
+ browse_xml_atom(FinalAtom, User, !IO)
+ ).
+
:- pred browse_atom_argument(trace_atom::in, trace_atom::in, int::in,
maybe(term_path)::out, user_state::in, user_state::out,
io::di, io::uo) is cc_multi.
@@ -409,6 +435,25 @@
MaybeMark = no
).
+:- pred browse_xml_atom_argument(trace_atom::in, int::in, user_state::in,
+ io::di, io::uo) is cc_multi.
+
+browse_xml_atom_argument(Atom, ArgNum, User, !IO) :-
+ Atom = atom(_, Args0),
+ maybe_filter_headvars(chosen_head_vars_presentation, Args0, Args),
+ (
+ list.index1(Args, ArgNum, ArgInfo),
+ ArgInfo = arg_info(_, _, MaybeArg),
+ MaybeArg = yes(ArgRep),
+ term_rep.rep_to_univ(ArgRep, Arg)
+ ->
+ save_and_browse_browser_term_xml(univ_to_browser_term(Arg),
+ User ^ outstr, User ^ outstr, User ^ browser, !IO)
+ ;
+ io.write_string(User ^ outstr, "Invalid argument number\n",
+ !IO)
+ ).
+
:- pred browse_atom(trace_atom::in, trace_atom::in, maybe(term_path)::out,
user_state::in, user_state::out, io::di, io::uo) is cc_multi.
@@ -427,6 +472,21 @@
maybe_convert_dirs_to_path(MaybeDirs, MaybeMark),
!:User = !.User ^ browser := Browser.
+:- pred browse_xml_atom(trace_atom::in, user_state::in, io::di, io::uo)
+ is cc_multi.
+
+browse_xml_atom(Atom, User, !IO) :-
+ Atom = atom(ProcLayout, Args),
+ ProcLabel = get_proc_label_from_layout(ProcLayout),
+ get_user_arg_values(Args, ArgValues),
+ get_pred_attributes(ProcLabel, Module, Name, _, PredOrFunc),
+ Function = pred_to_bool(unify(PredOrFunc,function)),
+ sym_name_to_string(Module, ".", ModuleStr),
+ BrowserTerm = synthetic_term_to_browser_term(ModuleStr ++ "." ++ Name,
+ ArgValues, Function),
+ save_and_browse_browser_term_xml(BrowserTerm, User ^ outstr,
+ User ^ outstr, User ^ browser, !IO).
+
:- func get_subterm_mode_from_atoms(trace_atom, trace_atom, list(dir))
= browser_term_mode.
@@ -538,31 +598,61 @@
%-----------------------------------------------------------------------------%
:- type user_command
- ---> yes % The node is correct.
- ; no % The node is incorrect.
- ; inadmissible % The node is inadmissible.
- ; skip % The user has no answer.
- ; browse_arg(maybe(int)) % Browse the nth argument before
- % answering. Or browse the whole
- % predicate/function if the maybe is
- % no.
- ; browse_io(int) % Browse the nth IO action before
- % answering.
- ; print_arg(int, int) % Print the nth to the mth arguments
- % before answering.
- ; print_io(int, int) % Print the nth to the mth IO actions
- % before answering.
- ; pd % Commence procedural debugging from
- % this point.
+ % The node is correct.
+ ---> yes
+
+ % The node is erroneous.
+ ; no
+
+ % The node is inadmissible.
+ ; inadmissible
+
+ % The user has no answer.
+ ; skip
+
+ % Browse the nth argument before answering. Or browse
+ % the whole predicate/function if the maybe is no.
+ ; browse_arg(maybe(int))
+
+ % Browse the argument using an XML browser.
+ ; browse_xml_arg(maybe(int))
+
+ % Browse the nth IO action before answering.
+ ; browse_io(int)
+
+ % Print the nth to the mth arguments
+ % before answering.
+ ; print_arg(int, int)
+
+ % Print the nth to the mth IO actions
+ % before answering.
+ ; print_io(int, int)
+
+ % Commence procedural debugging from
+ % this point.
+ ; pd
+
+ % Set a browser option.
; set(maybe_option_table(setting_option), setting)
- % Set a browser option.
- ; trust_predicate % Trust the predicate being asked
- % about.
- ; trust_module % Trust the module being asked about.
- ; abort % Abort this diagnosis session.
- ; help % Request help before answering.
- ; empty_command % User just pressed return.
- ; illegal_command. % None of the above.
+
+ % Trust the predicate being asked
+ % about.
+ ; trust_predicate
+
+ % Trust the module being asked about.
+ ; trust_module
+
+ % Abort this diagnosis session.
+ ; abort
+
+ % Request help before answering.
+ ; help
+
+ % User just pressed return.
+ ; empty_command
+
+ % None of the above.
+ ; illegal_command.
:- pred user_help_message(user_state::in, io::di, io::uo) is det.
@@ -574,14 +664,17 @@
"\tn\tno\t\tthe node is incorrect\n",
"\ti\tinadmissible\tthe input arguments are out of range\n",
"\ts\tskip\t\tskip this question\n",
- "\tt [module]\ttrust [module]\tTrust the predicate/function ",
- "about\n",
- "\t\twhich the current question is being asked. If the word\n",
+ "\tt [module]\ttrust [module]\t\n",
+ "\t\tTrust the predicate/function about which\n",
+ "\t\tthe current question is being asked. If the word\n",
"\t\t`module' is given as an argument then trust all the\n",
"\t\tpredicates/functions in the same module as the\n",
"\t\tpredicate/function about which the current question is\n",
"\t\tbeing asked.\n",
- "\tb [<n>]\tbrowse [<n>]\tbrowse the atom, or its nth argument\n",
+ "\tb [-x] [<n>]\tbrowse [-x] [<n>]\n",
+ "\t\tBrowse the atom, or its nth argument.\n",
+ "\t\tIf the `-x' or `--xml' option is given, then browse\n",
+ "\t\tthe term with an XML browser.\n",
"\tb io <n>\tbrowse io <n>\tbrowse the atom's nth I/O action\n",
"\tp <n>\tprint <n>\tprint the nth argument of the atom\n",
"\tp <n-m>\tprint <n-m>\tprint the nth to the mth arguments of the atom\n",
@@ -674,9 +767,20 @@
:- func browse_arg_cmd(list(string)::in) = (user_command::out) is semidet.
-browse_arg_cmd([Arg]) = browse_arg(yes(ArgNum)) :-
- string.to_int(Arg, ArgNum).
browse_arg_cmd([]) = browse_arg(no).
+browse_arg_cmd([Arg]) = BrowseCmd :-
+ (
+ string.to_int(Arg, ArgNum)
+ ->
+ BrowseCmd = browse_arg(yes(ArgNum))
+ ;
+ ( Arg = "-x" ; Arg = "--xml" ),
+ BrowseCmd = browse_xml_arg(no)
+ ).
+browse_arg_cmd(["-x", Arg]) = browse_xml_arg(yes(ArgNum)) :-
+ string.to_int(Arg, ArgNum).
+browse_arg_cmd(["--xml", Arg]) = browse_xml_arg(yes(ArgNum)) :-
+ string.to_int(Arg, ArgNum).
browse_arg_cmd(["io", Arg]) = browse_io(ArgNum) :-
string.to_int(Arg, ArgNum).
@@ -744,6 +848,11 @@
browse_decl_bug(Bug, MaybeArgNum, !User, !IO),
user_confirm_bug(Bug, Response, !User, !IO)
;
+ Command = browse_xml_arg(MaybeArgNum)
+ ->
+ browse_xml_decl_bug(Bug, MaybeArgNum, !.User, !IO),
+ user_confirm_bug(Bug, Response, !User, !IO)
+ ;
Command = browse_io(ActionNum)
->
decl_bug_io_actions(Bug, IoActions),
Index: tests/debugger/browser_test.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.exp,v
retrieving revision 1.22
diff -u -r1.22 browser_test.exp
--- tests/debugger/browser_test.exp 8 Feb 2005 03:16:39 -0000 1.22
+++ tests/debugger/browser_test.exp 19 Feb 2005 05:13:36 -0000
@@ -166,6 +166,79 @@
<small functor="small" type="browser_test.big" arity="0" />
</big>
</big>
+mdb> dd
+big_data(big(big(big/3, 2, small), 3, big(big/3, 6, small)))
+Valid? browse --xml 1
+Saving term to XML file...
+Launching XML browser (this may take some time) ...
+<?xml version="1.0"?>
+<big functor="big" type="browser_test.big" arity="3">
+ <big functor="big" type="browser_test.big" arity="3">
+ <big functor="big" type="browser_test.big" arity="3">
+ <small functor="small" type="browser_test.big" arity="0" />
+ <Int type="int">1</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ <Int type="int">2</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ <Int type="int">3</Int>
+ <big functor="big" type="browser_test.big" arity="3">
+ <big functor="big" type="browser_test.big" arity="3">
+ <small functor="small" type="browser_test.big" arity="0" />
+ <Int type="int">4</Int>
+ <big functor="big" type="browser_test.big" arity="3">
+ <small functor="small" type="browser_test.big" arity="0" />
+ <Int type="int">5</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ </big>
+ <Int type="int">6</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+</big>
+big_data(big(big(big/3, 2, small), 3, big(big/3, 6, small)))
+Valid? b -x
+Saving term to XML file...
+Launching XML browser (this may take some time) ...
+<?xml version="1.0"?>
+<predicate functor="predicate" type="mdb.browse.xml_predicate_wrapper" arity="2">
+ <String type="string" field="predicate_name">browser_test.big_data</String>
+ <List functor="[|]" field="predicate_arguments" type="list.list(std_util.univ)" arity="2">
+ <univ_cons functor="univ_cons" type="std_util.univ" arity="1">
+ <big functor="big" type="browser_test.big" arity="3">
+ <big functor="big" type="browser_test.big" arity="3">
+ <big functor="big" type="browser_test.big" arity="3">
+ <small functor="small" type="browser_test.big" arity="0" />
+ <Int type="int">1</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ <Int type="int">2</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ <Int type="int">3</Int>
+ <big functor="big" type="browser_test.big" arity="3">
+ <big functor="big" type="browser_test.big" arity="3">
+ <small functor="small" type="browser_test.big" arity="0" />
+ <Int type="int">4</Int>
+ <big functor="big" type="browser_test.big" arity="3">
+ <small functor="small" type="browser_test.big" arity="0" />
+ <Int type="int">5</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ </big>
+ <Int type="int">6</Int>
+ <small functor="small" type="browser_test.big" arity="0" />
+ </big>
+ </big>
+ </univ_cons>
+ <Nil functor="[]" type="list.list(std_util.univ)" arity="0" />
+ </List>
+</predicate>
+big_data(big(big(big/3, 2, small), 3, big(big/3, 6, small)))
+Valid? abort
+Diagnosis aborted.
+ E3: C2 EXIT pred browser_test.big_data/1-0 (det) browser_test.m:37 (browser_test.m:20)
mdb> set -A -f depth 1
mdb> print *
Data (arg 1) big(big/3, 3, big/3)
Index: tests/debugger/browser_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.inp,v
retrieving revision 1.12
diff -u -r1.12 browser_test.inp
--- tests/debugger/browser_test.inp 11 Dec 2004 01:59:52 -0000 1.12
+++ tests/debugger/browser_test.inp 18 Feb 2005 08:21:09 -0000
@@ -40,6 +40,10 @@
set xml_browser_cmd 'cat ./browser_test.xml.out'
browse --xml 1
browse -x Data
+dd
+browse --xml 1
+b -x
+abort
set -A -f depth 1
print *
print Data/1
Index: trace/mercury_trace_browse.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_browse.c,v
retrieving revision 1.35
diff -u -r1.35 mercury_trace_browse.c
--- trace/mercury_trace_browse.c 28 Jan 2005 02:47:42 -0000 1.35
+++ trace/mercury_trace_browse.c 19 Feb 2005 05:10:09 -0000
@@ -118,6 +118,19 @@
}
void
+MR_trace_save_and_invoke_xml_browser(MR_Word browser_term)
+{
+ MercuryFile mdb_out;
+ MercuryFile mdb_err;
+
+ MR_c_file_to_mercury_file(MR_mdb_out, &mdb_out);
+ MR_c_file_to_mercury_file(MR_mdb_err, &mdb_err);
+
+ ML_BROWSE_browse_term_xml(browser_term, &mdb_out, &mdb_err,
+ MR_trace_browser_persistent_state);
+}
+
+void
MR_trace_browse(MR_Word type_info, MR_Word value, MR_Browse_Format format)
{
MercuryFile mdb_in;
@@ -280,6 +293,8 @@
int width;
int lines;
MR_Browse_Format new_format;
+ MR_String aligned_value;
+ char *copied_value;
MR_trace_browse_ensure_init();
@@ -333,6 +348,30 @@
&MR_trace_browser_persistent_state);
);
}
+ 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,
+ 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);
+ 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,
+ MR_trace_browser_persistent_state,
+ &MR_trace_browser_persistent_state);
+ );
+ }
else
{
return MR_FALSE;
Index: trace/mercury_trace_browse.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_browse.h,v
retrieving revision 1.18
diff -u -r1.18 mercury_trace_browse.h
--- trace/mercury_trace_browse.h 11 Dec 2004 01:59:52 -0000 1.18
+++ trace/mercury_trace_browse.h 18 Feb 2005 03:53:05 -0000
@@ -73,6 +73,11 @@
#endif
/*
+** 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,
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.194
diff -u -r1.194 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 14 Feb 2005 08:04:02 -0000 1.194
+++ trace/mercury_trace_internal.c 18 Feb 2005 04:35:39 -0000
@@ -195,13 +195,6 @@
static MR_bool MR_print_optionals = MR_FALSE;
/*
-** These variables tell mdb how to invoke the user's xml browser.
-*/
-
-static char *MR_xml_browser_command = NULL;
-static char *MR_xml_tmp_filename = NULL;
-
-/*
** This variable holds the name of a file which contains a list of
** the file names of passing test case trace counts.
*/
@@ -714,7 +707,6 @@
MR_Browse_Format format);
/* Functions to invoke the user's XML browser on terms or goals */
-static void MR_trace_save_and_invoke_xml_browser(MR_Word browser_term);
static void MR_trace_browse_xml(MR_Word type_info, MR_Word value,
MR_Browse_Caller_Type caller, MR_Browse_Format format);
static void MR_trace_browse_goal_xml(MR_ConstString name,
@@ -1316,37 +1308,6 @@
}
static void
-MR_trace_save_and_invoke_xml_browser(MR_Word browser_term)
-{
- if (MR_xml_tmp_filename != NULL && (!MR_streq(MR_xml_tmp_filename, ""))) {
- fprintf(MR_mdb_out, "Saving term to XML file...\n");
- fflush(MR_mdb_out);
- MR_trace_save_term_xml(MR_xml_tmp_filename, browser_term);
- } else {
- fflush(MR_mdb_out);
- fprintf(MR_mdb_err, "mdb: You need to issue a "
- "\"set xml_tmp_filename '...'\" command first.\n");
- }
-
- if (MR_xml_browser_command != NULL &&
- (!MR_streq(MR_xml_browser_command, "")))
- {
- fprintf(MR_mdb_out, "Launching XML browser (this may take some time) "
- "...\n");
- fflush(MR_mdb_out);
- if (system(MR_xml_browser_command) == -1) {
- fflush(MR_mdb_out);
- fprintf(MR_mdb_err, "\nmdb: Error invoking XML browser using "
- "command:\n\"%s\"\n", MR_xml_browser_command);
- }
- } else {
- fflush(MR_mdb_out);
- fprintf(MR_mdb_err, "mdb: You need to issue a "
- "\"set xml_browser_cmd '...'\" command first.\n");
- }
-}
-
-static void
MR_trace_browse_xml(MR_Word type_info, MR_Word value,
MR_Browse_Caller_Type caller, MR_Browse_Format format)
{
@@ -2370,23 +2331,7 @@
MR_Word verbose_format;
MR_Word pretty_format;
- if (word_count == 3 && MR_streq(words[1], "xml_browser_cmd")) {
- if (MR_xml_browser_command == NULL) {
- MR_xml_browser_command = (char*) malloc(strlen(words[2]) + 1);
- } else {
- MR_xml_browser_command = (char*) realloc(MR_xml_browser_command,
- strlen(words[2]) + 1);
- }
- strcpy(MR_xml_browser_command, words[2]);
- } else if (word_count == 3 && MR_streq(words[1], "xml_tmp_filename")) {
- if (MR_xml_tmp_filename == NULL) {
- MR_xml_tmp_filename = (char*) malloc(strlen(words[2]) + 1);
- } else {
- MR_xml_tmp_filename = (char*) realloc(MR_xml_tmp_filename,
- strlen(words[2]) + 1);
- }
- strcpy(MR_xml_tmp_filename, words[2]);
- } else if (word_count == 3 && MR_streq(words[1], "fail_trace_count")) {
+ if (word_count == 3 && MR_streq(words[1], "fail_trace_count")) {
if (MR_dice_fail_trace_count_file == NULL) {
MR_dice_fail_trace_count_file = (char*)malloc(strlen(words[2])
+ 1);
--------------------------------------------------------------------------
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