Add a new mdb command, 'shell', that allows users to execute shell commands

Estimated hours taken: 5
Branches: main

Add a new mdb command, 'shell', that allows users to execute shell commands
from within the debugger.

Allow the user to give up to nine additional arguments to the 'source' command.
Occurrences of the strings "$1" through "$9" in the sourced file are replaced
by the corresponding additional arguments, allowing for parameterised scripts.

Use the two new features mentioned above to add two more mdb commands: one
to open a term, goal or exception in an external editor another command
to perform a grep on a term, goal or exception (useful for seeing if a value
occurs in a big map, for example).

NEWS
	Mention the new commands.

doc/mdb_categories:
doc/user_guide.texi:
	Document the new commands.

scripts/Mmakefile:
scripts/mdb_open:
scripts/mdb_vim:
	Add scripts for the new commands.

scripts/mdbrc.in:
	Add aliases for the new shell, emacs, grep and vim commands.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Adjust for new commands.

tests/debugger/save.exp:
tests/debugger/save.exp2:
	Adjust for new commands.  Replace system dependent strings
	with ZZZ instead of XXX.

tests/debugger/Mmakefile:
tests/debugger/shell.exp:
tests/debugger/shell.inp:
tests/debugger/shell.m:
tests/debugger/shell_test_script:
	Test the shell and source commands.

trace/mercury_trace_cmd_misc.c:
	Check if there are extra arguments to the source mdb command
	and pass them to MR_trace_source if there are.

trace/mercury_trace_cmd_misc.h:
	Add shell command handling function prototype.

trace/mercury_trace_declarative.c:
	Call MR_trace_call_system_display_error_on_failure instead
	of system when displaying benchmarking statistics for the
	declarative debugger.

trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
	Implement the shell command and extend the source command
	to handle the optional extra arguments.

trace/mercury_trace_readline.c:
trace/mercury_trace_readline.h:
	Add a new function to read a line and replace all the
	occurrences of "$[1-9]" with the corresponding value from an array.

	Delete comments in the .c file that are duplicated in the .h file.

trace/mercury_trace_util.c:
trace/mercury_trace_util.h:
	Implement MR_trace_call_system_display_error_on_failure that
	executes a system call and displays an error message if the system
	call terminates abnormally.
This commit is contained in:
Ian MacLarty
2006-06-13 09:49:04 +00:00
parent fc94027616
commit 2ece43e394
25 changed files with 334 additions and 77 deletions

View File

@@ -45,10 +45,14 @@ CONF_FILES = \
Mmake.vars \
parse_ml_options.sh-subr
CONF_DEBUG_SCRIPTS = \
CONF_DEBUG_SCRIPTS = \
mdbrc
DEBUGGER_SCRIPTS = $(CONF_DEBUG_SCRIPTS) xul_tree.xsl
DEBUGGER_SCRIPTS = $(CONF_DEBUG_SCRIPTS) \
xul_tree.xsl \
mdb_open \
mdb_grep
EMACS_SCRIPTS = gud.el
#-----------------------------------------------------------------------------#

3
scripts/mdb_grep Normal file
View File

@@ -0,0 +1,3 @@
save_to_file $2 .mdb_grep_tmp
shell grep $1 .mdb_grep_tmp
shell rm .mdb_grep_tmp

3
scripts/mdb_open Normal file
View File

@@ -0,0 +1,3 @@
save_to_file $1 .mdb_open_tmp
shell ${EDITOR-vi} .mdb_open_tmp
shell rm .mdb_open_tmp

View File

@@ -15,5 +15,8 @@ alias excp exception
alias e exception
alias EMPTY step
alias NUMBER step
alias ! shell
alias open source @DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdb_open
alias grep source @DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdb_grep
xml_browser_cmd '@DEFAULT_XML_BROWSER_CMD@'
xml_tmp_filename '@DEFAULT_XML_TMP_FILENAME@'