[m-rev.] for review: add 4 new mdb commands
Ian MacLarty
maclarty at cs.mu.OZ.AU
Sun Mar 19 01:32:00 AEDT 2006
On Tue, Mar 14, 2006 at 11:43:50AM +1100, Julien Fischer wrote:
>
> On Tue, 14 Mar 2006, Ian MacLarty wrote:
>
> > >
> >
> > Okay I will make the requested changes and submit an interdiff in the
> > next few days. I have one problem though: I don't think edit is a good
> > name for the command to invoke the editor since it suggests that you're
> > updating the value of the term in the program, which you're not. What
> > about 'open' or 'view'?
>
> Either seems okay, although I'd lean towards the latter.
>
Unfortunately 'view' is already an mdb command, so it has to be 'open'.
Here's the interdiff (I also added a detailed section for the debugger
in the NEWS file):
diff -u NEWS NEWS
--- NEWS 12 Mar 2006 00:09:13 -0000
+++ NEWS 18 Mar 2006 13:53:36 -0000
@@ -54,10 +54,11 @@
* The source command now accepts optional additional arguments which
are substituted into the sourced file, allowing for parameterised
scripts.
-* Users can now open terms, goals or exceptions in vim or emacs, or
- perform a grep on the term, goal or exception.
-* The declarative debugger now supports an `undo' command, and allows users to
- select the search algorithm.
+* Users can now open terms in their favourate editor, or
+ perform a grep on a term.
+* The declarative debugger now supports an `undo' command.
+* The declarative debugger now allows users to
+ change the search algorithm mid-session.
* The declarative debugger can now exploit information from the "code
footprints" of passed and failed test cases to find bugs with fewer
questions. We have also added two tools, mslice and mdice, to manipulate
@@ -228,6 +229,46 @@
in which the format string or the structure of the list of values to be
printed are not statically available.
+Changes to the Mercury debugger:
+
+* A `list' command has ben added that displays a listing of the source code
+ lines referred to by the current environment. To supporting commands
+ `pop_list_dir' and `push_list_dir' have also been added.
+
+* Users can now keep hold of a term, referring to it even when execution has
+ left the goal at which the term was available as the value of a program
+ variable. The name of the new command is `hold'.
+
+* A `diff' command has been added that allows users to see the set of places
+ where two terms differ from each other.
+
+* A `shell' (or `!' for short) command has been added that allows users to
+ execute system shell commands from within the debugger.
+
+* The `source' command now accepts optional additional arguments which
+ are substituted into the sourced file, allowing for parameterised
+ scripts. The strings "$1" through "$9" in the sourced file are replaced with
+ the corresponding argument of the `source' command.
+
+* The above two features have been used to create two additional commands: an
+ `open' command that lets users open a term in their favourite editor for
+ browsing and a `grep' command that can be used to check if a term contains
+ a particular pattern.
+
+* The declarative debugger now allows users to take back answers they gave
+ by means of an multi-level `undo' command.
+
+* The declarative debugger now allows users to change the search algorithm
+ mid-session by means of a `mode' command.
+
+* The declarative debugger can now exploit information from the "code
+ footprints" of passed and failed test cases to find bugs with fewer
+ questions. We have also added two tools, mslice and mdice, to manipulate
+ files containing such footprints.
+
+* Subterm dependency tracking in the declarative debugger is now significantly
+ faster.
+
Changes to the extras distribution:
* We've added a library of data structures designed to work for solver types.
diff -u doc/mdb_categories doc/mdb_categories
--- doc/mdb_categories 12 Mar 2006 00:00:10 -0000
+++ doc/mdb_categories 15 Mar 2006 23:20:59 -0000
@@ -27,7 +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', `vim', `emacs', `grep', `list',
+ `diff', `save_to_file', `open', `grep', `list',
`push_list_dir' and `pop_list_dir'.
end
diff -u doc/user_guide.texi doc/user_guide.texi
--- doc/user_guide.texi 11 Mar 2006 23:43:13 -0000
+++ doc/user_guide.texi 18 Mar 2006 14:18:05 -0000
@@ -2867,32 +2867,20 @@
to the specified file. The option @samp{-x} (or @samp{--xml}) causes the
output to be in XML.
@sp 1
- at item vim @var{object}
-Save @var{object} to a temporary file and open the file with the vim
-editor.
- at var{object} may be a variable name or number,
-the word @samp{goal} or
-the word @samp{exception},
- at c or the word proc_body,
-the meanings of which are the same as for the @samp{safe_to_file} command.
+ at item open @var{term}
+Save @var{term} to a temporary file and open the file in an editor.
+The environment variable EDITOR is consulted to determine what editor to
+use.
+ at var{term} may be any term that can be saved to a file with the
+ at samp{save_to_file} command.
@sp 1
- at item emacs @var{object}
-Save @var{object} to a temporary file and open the file with the emacs
-editor.
- at var{object} may be a variable name or number,
-the word @samp{goal} or
-the word @samp{exception},
- at c or the word proc_body,
-the meanings of which are the same as for the @samp{safe_to_file} command.
- at sp 1
- at item grep @var{pattern} @var{object}
-Save the given object to a temporary file and perform a grep on the
+ at item grep @var{pattern} @var{term}
+Save the given term to a temporary file and perform a grep on the
file using @var{pattern}.
- at var{object} may be a variable name or number,
-the word @samp{goal} or
-the word @samp{exception},
- at c or the word proc_body,
-the meanings of which are the same as for the @samp{safe_to_file} command.
+ at var{term} may be any term that can be saved to a file with the
+ at samp{save_to_file} command.
+The unix `grep' command must be available from the shell for this command
+to work.
@c @sp 1
@c @item save_to_file [-x] proc_body @var{filename}
@c Writes the representation of the body of the current procedure,
@@ -3773,7 +3761,7 @@
@kindex source (mdb command)
Executes the commands in the file named @var{filename}.
Optionally a list of at most nine arguments can be given.
-Occurances of the strings "$1" to "$9" in the sourced file
+Occurrences of the strings "$1" to "$9" in the sourced file
will be replaced by the corresponding arguments given in the source
command before the commands in the sourced file are executed.
@sp 1
diff -u scripts/Mmakefile scripts/Mmakefile
--- scripts/Mmakefile 11 Mar 2006 23:20:38 -0000
+++ scripts/Mmakefile 15 Mar 2006 23:20:59 -0000
@@ -50,8 +50,7 @@
DEBUGGER_SCRIPTS = $(CONF_DEBUG_SCRIPTS) \
xul_tree.xsl \
- mdb_vim \
- mdb_emacs \
+ mdb_open \
mdb_grep
EMACS_SCRIPTS = gud.el
reverted:
--- scripts/mdb_emacs 11 Mar 2006 20:56:23 -0000
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-save_to_file $1 .mdb_emacs_tmp
-shell emacs .mdb_emacs_tmp
-shell rm .mdb_emacs_tmp
reverted:
--- scripts/mdb_vim 11 Mar 2006 21:21:34 -0000
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-save_to_file $1 .mdb_vim_tmp
-shell vim .mdb_vim_tmp
-shell rm .mdb_vim_tmp
diff -u scripts/mdbrc.in scripts/mdbrc.in
--- scripts/mdbrc.in 11 Mar 2006 20:52:31 -0000
+++ scripts/mdbrc.in 15 Mar 2006 23:29:17 -0000
@@ -16,8 +16,7 @@
alias EMPTY step
alias NUMBER step
alias ! shell
-alias vim source @DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdb_vim
-alias emacs source @DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdb_emacs
+alias open source @DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdb_open
alias grep source @DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdb_grep
set xml_browser_cmd '@DEFAULT_XML_BROWSER_CMD@'
set xml_tmp_filename '@DEFAULT_XML_TMP_FILENAME@'
diff -u tests/debugger/shell.exp tests/debugger/shell.exp
--- tests/debugger/shell.exp 11 Mar 2006 16:44:38 -0000
+++ tests/debugger/shell.exp 15 Mar 2006 23:20:59 -0000
@@ -1,10 +1,16 @@
-Melbourne Mercury Debugger, mdb version DEV.
-Copyright 1998-2006 The University of Melbourne, Australia.
-mdb is free software, covered by the GNU General Public License.
-There is absolutely no warranty for mdb.
E1: C1 CALL pred shell.main/2-0 (det) shell.m:12
mdb> echo on
Command echo enabled.
mdb> shell echo hello
hello
+mdb> alias test source shell_test_script
+test => source shell_test_script
+mdb> test value1 value2 3 'value 4' "a" '' 'b' file_name.ext 9
+value1 value2
+value2 value1
+value1 value2 $ $abc 3 value 4 a b file_name.ext 9 $0 $b $
+mdb> test only_one_value
+only_one_value
+only_one_value
+only_one_value $ $abc $0 $b $
mdb> quit -y
diff -u trace/mercury_trace_internal.c trace/mercury_trace_internal.c
--- trace/mercury_trace_internal.c 11 Mar 2006 21:45:44 -0000
+++ trace/mercury_trace_internal.c 15 Mar 2006 23:20:59 -0000
@@ -6211,7 +6211,7 @@
MR_Event_Info *event_info, MR_Code **jumpaddr)
{
char* command_string;
- int command_string_length;
+ size_t command_string_length;
int word_num;
command_string_length = 1;
@@ -6225,7 +6225,7 @@
strcat(command_string, " ");
}
- system(command_string);
+ MR_trace_call_system_display_error_on_failure(MR_mdb_err, command_string);
MR_free(command_string);
return KEEP_INTERACTING;
diff -u trace/mercury_trace_readline.c trace/mercury_trace_readline.c
--- trace/mercury_trace_readline.c 11 Mar 2006 23:58:42 -0000
+++ trace/mercury_trace_readline.c 15 Mar 2006 23:20:59 -0000
@@ -171,13 +171,13 @@
MR_trace_readline_expand_args(FILE *fp, char **args, int num_args)
{
char *line;
- int line_length;
+ size_t line_length;
int line_index;
- int expanded_line_length;
+ size_t expanded_line_length;
char *expanded_line;
int expanded_line_index;
int arg_num;
- int arg_length;
+ size_t arg_length;
char *arg;
line = MR_trace_readline_raw(fp);
diff -u trace/mercury_trace_readline.h trace/mercury_trace_readline.h
--- trace/mercury_trace_readline.h 11 Mar 2006 23:55:05 -0000
+++ trace/mercury_trace_readline.h 15 Mar 2006 23:20:59 -0000
@@ -30,9 +30,9 @@
char * MR_trace_readline_raw(FILE *in);
/*
-** Read a line from a file and replace occurances of the strings "$1" to
+** Read a line from a file and replace occurrences of the strings "$1" to
** "$9" with the corresponding values in the args array. If there is no
-** value in the args array, then the "$n$ string is replaced by the empty
+** value in the args array, then the "$n" string is replaced by the empty
** string.
** Return a pointer to a MR_malloc'd buffer holding the new string (without
** the final newline). If EOF occurs on a nonempty line, treat the EOF as a
only in patch2:
unchanged:
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ scripts/mdb_open 15 Mar 2006 23:20:59 -0000
@@ -0,0 +1,3 @@
+save_to_file $1 .mdb_open_tmp
+shell $EDITOR .mdb_open_tmp
+shell rm .mdb_open_tmp
only in patch2:
unchanged:
--- tests/debugger/completion.exp 25 Oct 2005 04:00:53 -0000 1.31
+++ tests/debugger/completion.exp 18 Mar 2006 14:07:57 -0000
@@ -3,41 +3,42 @@
Command echo enabled.
mdb> register --quiet
mdb>
-? exception query
-P excp quit
-alias f r
-all_class_decls finish register
-all_procedures flag retry
-all_regs forward return
-all_type_ctors g s
-ambiguity gen_stack save
-b goal_paths save_to_file
-break goto scope
+! exception push_list_dir
+? excp query
+P f quit
+alias finish r
+all_class_decls flag register
+all_procedures forward retry
+all_regs g return
+all_type_ctors gen_stack s
+ambiguity goal_paths save
+b goto save_to_file
+break grep scope
break_print h scroll
browse held_vars set
-c help source
-cc_query histogram_all stack
-class_decl histogram_exp stack_default_limit
-clear_histogram hold stack_regs
-condition ignore stats
-consumer io_query step
-context level subgoal
-continue list table
-current maxdepth table_io
-cut_stack mindepth term_size
-d mm_stacks trust
-dd mmc_options trusted
-debug_vars modules type_ctor
-delete next unalias
-dice nondet_stack unhide_events
-diff p untrust
-disable pneg_stack up
-document pop_list_dir v
-document_category print var_details
-down print_optionals vars
-e printlevel view
-echo procedures
-enable push_list_dir
+c help shell
+cc_query histogram_all source
+class_decl histogram_exp stack
+clear_histogram hold stack_default_limit
+condition ignore stack_regs
+consumer io_query stats
+context level step
+continue list subgoal
+current maxdepth table
+cut_stack mindepth table_io
+d mm_stacks term_size
+dd mmc_options trust
+debug_vars modules trusted
+delete next type_ctor
+dice nondet_stack unalias
+diff open unhide_events
+disable p untrust
+document pneg_stack up
+document_category pop_list_dir v
+down print var_details
+e print_optionals vars
+echo printlevel view
+enable procedures
h help histogram_exp
held_vars histogram_all hold
var_details vars view
only in patch2:
unchanged:
--- tests/debugger/mdb_command_test.inp 2 Nov 2005 14:02:11 -0000 1.48
+++ tests/debugger/mdb_command_test.inp 16 Mar 2006 00:35:21 -0000
@@ -40,6 +40,8 @@
hold xyzzy xyzzy xyzzy xyzzy xyzzy
diff xyzzy xyzzy xyzzy xyzzy xyzzy
save_to_file xyzzy xyzzy xyzzy xyzzy xyzzy
+open xyzzy xyzzy xyzzy xyzzy xyzzy
+grep 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
@@ -68,6 +70,7 @@
trusted xyzzy xyzzy xyzzy xyzzy xyzzy
untrust xyzzy xyzzy xyzzy xyzzy xyzzy
set xyzzy xyzzy xyzzy xyzzy xyzzy
+shell xyzzy xyzzy xyzzy xyzzy xyzzy
source xyzzy xyzzy xyzzy xyzzy xyzzy
save xyzzy xyzzy xyzzy xyzzy xyzzy
quit xyzzy xyzzy xyzzy xyzzy xyzzy
only in patch2:
unchanged:
--- trace/mercury_trace_declarative.c 8 Feb 2006 21:54:32 -0000 1.99
+++ trace/mercury_trace_declarative.c 15 Mar 2006 23:20:59 -0000
@@ -2434,7 +2434,7 @@
pid = getpid();
sprintf(cmdstr, "ps -p %i -o rss,vsz | tail -1 |"
"awk '{print \"RSS = \" $1 \"\\nVSZ = \" $2}' 1>&2", pid);
- system(cmdstr);
+ MR_trace_call_system_display_error_on_failure(stderr, cmdstr);
MR_debug_enabled = MR_FALSE;
MR_update_trace_func_enabled();
only in patch2:
unchanged:
--- trace/mercury_trace_util.c 8 Feb 2006 21:54:34 -0000 1.18
+++ trace/mercury_trace_util.c 18 Mar 2006 14:19:52 -0000
@@ -207,3 +207,21 @@
}
return MR_FALSE;
}
+
+void
+MR_trace_call_system_display_error_on_failure(FILE *err_stream, char *command)
+{
+ int system_rv;
+
+ if (system(NULL)) {
+ system_rv = system(command);
+ if (system_rv != 0) {
+ fprintf(err_stream,
+ "mdb: the shell command returned a non-zero exit code or was"
+ " terminated abnormally.\n",
+ system_rv);
+ }
+ } else {
+ fprintf(err_stream, "mdb: no shell found.\n");
+ }
+}
only in patch2:
unchanged:
--- trace/mercury_trace_util.h 8 Feb 2006 21:54:34 -0000 1.14
+++ trace/mercury_trace_util.h 15 Mar 2006 23:20:59 -0000
@@ -77,4 +77,13 @@
extern MR_bool MR_trace_proc_layout_is_builtin_catch(
const MR_Proc_Layout *layout);
+/*
+** MR_trace_call_system_display_error_on_failure executes the given command
+** and displays an error message if the command returned a non-zero exit
+** status, there was a problem executing the command, or no usable shell was
+** available.
+*/
+extern void MR_trace_call_system_display_error_on_failure(
+ FILE *err_stream, char *command);
+
#endif /* MERCURY_TRACE_UTIL_H */
--------------------------------------------------------------------------
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