Files
mercury/scripts/Mmakefile
Ian MacLarty 2ece43e394 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.
2006-06-13 09:49:04 +00:00

173 lines
5.4 KiB
Plaintext

#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Copyright (C) 1996-2006 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# Mmake - Mmake file for the Mercury scripts
MAIN_TARGET=all
MERCURY_DIR=..
include $(MERCURY_DIR)/Mmake.common
#-----------------------------------------------------------------------------#
NONCONF_SCRIPTS = \
mercury_cleanup_install \
mprof_merge_runs \
mtags \
mtc \
vpath_find
CONF_SCRIPTS = \
c2init \
canonical_grade \
mdb \
mdprof \
mercury.bat \
mercury_config \
mercury_update_interface \
mgnuc \
mkfifo_using_mknod \
ml \
mmake \
mmc \
mprof \
prepare_tmp_dir_fixed_part
SCRIPTS = $(NONCONF_SCRIPTS) $(CONF_SCRIPTS)
CONF_FILES = \
Mercury.config.bootstrap \
Mercury.config \
Mmake.vars \
parse_ml_options.sh-subr
CONF_DEBUG_SCRIPTS = \
mdbrc
DEBUGGER_SCRIPTS = $(CONF_DEBUG_SCRIPTS) \
xul_tree.xsl \
mdb_open \
mdb_grep
EMACS_SCRIPTS = gud.el
#-----------------------------------------------------------------------------#
# .SUFFIXES: .in
# we test membership of CONF_SCRIPTS and CONF_FILES, because testing $(@D)
# (the directory part of $*) does the wrong thing for Mercury.config.
# Not testing anything would make this rule apply even to ../Mmake.common.
# The grep is there to ensure that there were no mispelt autoconf variable
# names.
%:: %.in $(MERCURY_DIR)/config.status
@for file in $(CONF_SCRIPTS) ; do \
if test "$*" = "$$file" ; then \
$(MERCURY_DIR)/config.status --file=$* ; \
if grep -n '[^$$]@' $@; then false; else true; fi ; \
chmod a+x $* ; \
fi \
done
@for file in $(CONF_FILES) $(CONF_DEBUG_SCRIPTS) ; do \
if test "$*" = "$$file" ; then \
$(MERCURY_DIR)/config.status --file=$* ; \
if grep -n '[^$$]@' $@; then false; else true; fi \
fi \
done
#-----------------------------------------------------------------------------#
.PHONY: all
all: $(CONF_FILES) $(SCRIPTS) $(DEBUGGER_SCRIPTS) $(EMACS_SCRIPTS)
#-----------------------------------------------------------------------------#
parse_ml_options.sh-subr mgnuc canonical_grade: init_grade_options.sh-subr
parse_ml_options.sh-subr mgnuc canonical_grade: parse_grade_options.sh-subr
parse_ml_options.sh-subr mgnuc canonical_grade: final_grade_options.sh-subr
ml c2init: parse_ml_options.sh-subr
ml c2init canonical_grade: canonical_grade.sh-subr
mercury_config: ../configure.help
#-----------------------------------------------------------------------------#
.PHONY: install
install: install_mmake install_scripts install_config \
install_debugger_scripts install_emacs_scripts
.PHONY: install_dirs
install_dirs:
[ -d $(INSTALL_BINDIR) ] || mkdir -p $(INSTALL_BINDIR)
[ -d $(INSTALL_LIBDIR)/mmake ] || mkdir -p $(INSTALL_LIBDIR)/mmake
[ -d $(INSTALL_LIBDIR)/mdb ] || mkdir -p $(INSTALL_LIBDIR)/mdb
[ -d $(INSTALL_CONF_DIR) ] || mkdir -p $(INSTALL_CONF_DIR)
[ -d $(INSTALL_ELISP_DIR) ] || mkdir -p $(INSTALL_ELISP_DIR)
[ -d $(INSTALL_RECONF_DIR)/scripts ] || \
mkdir -p $(INSTALL_RECONF_DIR)/scripts
.PHONY: install_mmake
install_mmake: Mmake.vars Mmake.rules install_dirs
rm -f $(INSTALL_LIBDIR)/mmake/Mmake.vars
cp `vpath_find Mmake.vars Mmake.rules` $(INSTALL_LIBDIR)/mmake
.PHONY: install_scripts
install_scripts: $(SCRIPTS) install_dirs
# we move the installed `mmake' script before (re)installing it
# to avoid overwriting the script while it is running
# (just removing it doesn't work very well on win32, which will
# deny you permission to write the file while mmake is running).
-mv $(INSTALL_BINDIR)/mmake $(INSTALL_BINDIR)/mmake.old
cp $(SCRIPTS) $(INSTALL_BINDIR)
-for file in $(SCRIPTS); do \
chmod u+w $(INSTALL_BINDIR)/$$file ;\
done
cp *.in *.sh-subr $(SCRIPTS) $(INSTALL_RECONF_DIR)/scripts
-rm -f $(INSTALL_BINDIR)/mmake.old
.PHONY: install_config
install_config: Mercury.config install_dirs
rm -f $(INSTALL_CONF_DIR)/Mercury.config
cp `vpath_find Mercury.config` $(INSTALL_CONF_DIR)
.PHONY: install_debugger_scripts
install_debugger_scripts: $(DEBUGGER_SCRIPTS) install_dirs
# Reportedly old versions of Mercury
# used to install mdbrc as read-only.
# If that is the case, then we need to make sure
# that it gets made writable before we install the
# new version.
-chmod u+w $(INSTALL_LIBDIR)/mdb/*
cp $(DEBUGGER_SCRIPTS) $(INSTALL_LIBDIR)/mdb
.PHONY: install_emacs_scripts
install_emacs_scripts: $(EMACS_SCRIPTS) install_dirs
cp $(EMACS_SCRIPTS) $(INSTALL_ELISP_DIR)
#-----------------------------------------------------------------------------#
.PHONY: uninstall
uninstall:
-rm -r $(INSTALL_LIBDIR)/mmake
-cd $(INSTALL_BINDIR) && rm $(SCRIPTS)
-cd $(INSTALL_LIBDIR)/mdb && rm $(DEBUGGER_SCRIPTS)
# The reason why we don't uninstall $(EMACS_SCRIPTS) specifically here
# is that the uninstall rule in the top-level Mmakefile does an "rm -r"
# on $(INSTALL_LIBDIR), and the directory into which $(EMACS_SCRIPTS)
# is installed, $(INSTALL_ELISP_DIR), is configured to be a
# subdirectory of $(INSTALL_LIBDIR).
#-----------------------------------------------------------------------------#
realclean_local: clean_scripts
.PHONY: clean_scripts
clean_scripts:
for file in *.in; do rm -f `basename $$file .in`; done
#-----------------------------------------------------------------------------#