[m-rev.] for review: new mdbcomp directory

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Jan 27 15:49:51 AEDT 2005


This diff has passed a test install and a bootcheck, but it will need a
test install of more grades and bootchecks in more grades before
it is ready to be committed. Comments welcome in the meantime.

Zoltan.

Move the mdbcomp library to its own directory. To make this change less painful
to test, improve the way we handle installs.

browser/mdbcomp.m:
browser/mer_mdbcomp.m:
browser/prim_data.m:
browser/program_representation.m:
browser/trace_counts.m:
	Move these files to the mdbcomp directory.

browser/Mmakefile:
browser/Mercury.options:
mdbcomp/Mmakefile:
mdbcomp/Mercury.options:
	Split the contents of the old Mmakefile and Mercury.options file
	in the browser directory between these files as appropriate.
	Simplify away the stuff not needed now that there is only one library
	per directory. Make the browser directory see the relevant files
	from the mdbcomp directory.

Mmake.common.in:
	Separate out the prefixes allowed in the browser and the mdbcomp
	directories.

Mmake.workspace:
	Set up a make variable to refer to the mdbcomp directory.

	Adjust references to the mdbcomp library to point to its new location.

Mmakefile:
	Make invocations visit the mdbcomp library as necessary.

	Improve the way we install grades. Making temporary backups of the
	directories modified by the install process is unsatisfactory for two
	reasons. First, if the install fails, the cleanup script, which is
	necessary for use friendliness, destroys any evidence of the cause.
	Second, the restore of the backup wasn't perfect, e.g. it left the
	.d files modified to depend on .mih files, which don't exist in
	LLDS grades, and also left altered timestamps.

	This diff changes the install process to make a single tmp_dir
	subdirectory of the workspace, with all the work of install_grade
	being done inside tmp_dir. The original directories aren't touched
	at all.

*/Mmakefile:
	Adjust references to the browser directory to refer to the mdbcomp
	directory instead or as well.

scripts/Mmake.rules:
*/Mmakefile:
	Make it easier to debug Mmakefiles. Previously, create a Mmake.makefile
	with mmake -s and invoking "make -d" ignored the most fundamental rules
	of mmake, because Mmake.rules was treating an under MMAKE_USE_MMC_MAKE
	as if it were set to "yes", simply because it was different from "no".
	This diff changes it to treat an unset MMAKE_USE_MMC_MAKE as if it
	were set to "no", which is a more sensible default.

scripts/prepare_tmp_dir_fixed_part.in:
scripts/scripts/prepare_tmp_dir_grade_part:
	Two new scripts that each do half the work of preparing tmp_dir for
	the real work of the install_grade make target. The fixed_part script
	prepares the parts of tmp_dir that are grade-independent, while the
	grade_part scripts prepares the parts that are grade-dependent.

configure.in:
	Test C files in the mdbcomp directory to see whether they need to
	recompiled after reconfiguration.

	Create prepare_tmp_dir_fixed_part from prepare_tmp_dir_fixed_part.in.

compiler/*.m:
runtime/mercury_wrapper.c:
	Update the references to the moved files.

compiler/notes/overall_design.html:
	Mention the new directory.

cvs diff: Diffing .
Index: Mmake.common.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.80
diff -u -b -r1.80 Mmake.common.in
--- Mmake.common.in	14 Jan 2005 05:53:47 -0000	1.80
+++ Mmake.common.in	24 Jan 2005 11:01:02 -0000
@@ -278,8 +278,10 @@
 # 		(the `runtime' and `trace' directories)
 # 	`ML_' for stuff in the Mercury standard library
 # 		(the `library' directory)
-# 	`MDB_' and `MDBCOMP_'for stuff in the browser
+# 	`MDB_' stuff in the browser
 # 		(the `browser' directory)
+# 	`MDBCOMP_'for stuff in the mdbcomp library
+# 		(the `mdbcomp' directory)
 # 	`GC_' for stuff in the Boehm et al conservative garbage collector
 # 		(the `boehm_gc' directory)
 # 	`MPS_' or `mps_' for stuff in the Memory Pool System toolkit
@@ -310,22 +312,34 @@
 
 ifeq ("$(ALLOW_BROWSER_PREFIX)","yes")
 BROWSER_MACRO_PREFIX_EXPRS = \
-	-e '^MDB_' -e '^MDBCOMP_'
+	-e '^MDB_'
 BROWSER_OBJ_PREFIX_EXPRS = \
-	-e '^MDB_' -e '^MDBCOMP_' -e '^mdb_' -e '^mdbcomp_'
+	-e '^MDB_' -e '^mdb_'
 else
 BROWSER_MACRO_PREFIX_EXPRS =
 BROWSER_OBJ_PREFIX_EXPRS =
 endif
 
+ifeq ("$(ALLOW_MDBCOMP_PREFIX)","yes")
+MDBCOMP_MACRO_PREFIX_EXPRS = \
+	-e '^MDBCOMP_'
+MDBCOMP_OBJ_PREFIX_EXPRS = \
+	-e '^MDBCOMP_' -e '^mdbcomp_'
+else
+MDBCOMP_MACRO_PREFIX_EXPRS =
+MDBCOMP_OBJ_PREFIX_EXPRS =
+endif
+
 MACRO_PREFIX_EXPRS = \
 	$(GEN_MACRO_PREFIX_EXPRS) \
 	$(LIB_MACRO_PREFIX_EXPRS) \
-	$(BROWSER_MACRO_PREFIX_EXPRS)
+	$(BROWSER_MACRO_PREFIX_EXPRS) \
+	$(MDBCOMP_MACRO_PREFIX_EXPRS)
 OBJ_PREFIX_EXPRS   = \
 	$(GEN_OBJ_PREFIX_EXPRS) \
 	$(LIB_OBJ_PREFIX_EXPRS) \
-	$(BROWSER_OBJ_PREFIX_EXPRS)
+	$(BROWSER_OBJ_PREFIX_EXPRS) \
+	$(MDBCOMP_OBJ_PREFIX_EXPRS)
 
 HEADER_CLEAN_FILTER = \
 	grep -v $(MACRO_PREFIX_EXPRS) | fgrep -v -x -f RESERVED_MACRO_NAMES
Index: Mmake.workspace
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/Mmake.workspace,v
retrieving revision 1.16
diff -u -b -r1.16 Mmake.workspace
--- Mmake.workspace	15 Dec 2004 06:57:18 -0000	1.16
+++ Mmake.workspace	24 Jan 2005 14:26:24 -0000
@@ -49,6 +49,7 @@
 RUNTIME_DIR = $(WORKSPACE)/runtime
 LIBRARY_DIR = $(WORKSPACE)/library
 TRACE_DIR = $(WORKSPACE)/trace
+MDBCOMP_DIR = $(WORKSPACE)/mdbcomp
 BROWSER_DIR = $(WORKSPACE)/browser
 BOEHM_GC_DIR = $(WORKSPACE)/boehm_gc
 MPS_GC_DIR = $(WORKSPACE)/mps_gc/code
@@ -112,7 +113,7 @@
 MCFLAGS += 	--no-mercury-stdlib-dir -I$(LIBRARY_DIR)
 MGNUCFLAGS +=	--no-mercury-stdlib-dir
 C2INITFLAGS += 	--trace-init-file $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init \
-		--trace-init-file $(BROWSER_DIR)/$(MDBCOMP_LIB_NAME).init
+		--trace-init-file $(MDBCOMP_DIR)/$(MDBCOMP_LIB_NAME).init
 C2INITARGS +=	$(LIBRARY_DIR)/$(STD_LIB_NAME).init \
 		$(RUNTIME_DIR)/$(RT_LIB_NAME).init
 MLFLAGS +=	--no-mercury-stdlib-dir
@@ -126,7 +127,8 @@
 ifneq ($(LINK_RUNTIME_ONLY),yes)
 C_INCL_DIRS +=	-I$(LIBRARY_DIR) -I$(LIBRARY_DIR)/$(mihs_subdir)
 ifneq ($(LINK_STDLIB_ONLY),yes)
-C_INCL_DIRS +=	-I$(BROWSER_DIR) -I$(BROWSER_DIR)/$(mihs_subdir) -I$(TRACE_DIR)
+C_INCL_DIRS +=	-I$(MDBCOMP_DIR) -I$(MDBCOMP_DIR)/$(mihs_subdir) \
+		-I$(BROWSER_DIR) -I$(BROWSER_DIR)/$(mihs_subdir) -I$(TRACE_DIR)
 endif
 endif
 endif
@@ -183,7 +185,7 @@
 ifneq ($(LINK_STDLIB_ONLY),yes)
 STATIC_TRACE_LIBS = $(TRACE_DIR)/lib$(TRACE_LIB_NAME).$A \
 		$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A \
-		$(BROWSER_DIR)/lib$(MDBCOMP_LIB_NAME).$A
+		$(MDBCOMP_DIR)/lib$(MDBCOMP_LIB_NAME).$A
 endif
 endif
 endif
@@ -209,7 +211,8 @@
 LINK_LIB_OPTS = $(LINK_TRACE_LIB_OPTS) $(LINK_STD_LIB_OPTS) \
 			$(LINK_RT_LIB_OPTS) $(SHARED_GC_LIBS) 
 LIB_DIR_OPTS = -L$(BOEHM_GC_DIR) -L$(MPS_GC_DIR) -L$(RUNTIME_DIR) \
-		-L$(LIBRARY_DIR) -L$(TRACE_DIR) -L$(BROWSER_DIR)
+		-L$(LIBRARY_DIR) -L$(TRACE_DIR) -L$(MDBCOMP_DIR) \
+		-L$(BROWSER_DIR)
 
 MLFLAGS +=	$(LIB_DIR_OPTS)
 MCFLAGS +=	$(LIB_DIR_OPTS)
Index: Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.106
diff -u -b -r1.106 Mmakefile
--- Mmakefile	15 Dec 2004 06:57:18 -0000	1.106
+++ Mmakefile	27 Jan 2005 04:21:38 -0000
@@ -30,6 +30,7 @@
 		robdd \
 		library \
 		trace \
+		mdbcomp \
 		browser \
 		analysis \
 		compiler \
@@ -57,8 +58,8 @@
 RT_LIB_NAME = mer_rt
 STD_LIB_NAME = mer_std
 TRACE_LIB_NAME = mer_trace
-BROWSER_LIB_NAME = mer_browser
 MDBCOMP_LIB_NAME = mer_mdbcomp
+BROWSER_LIB_NAME = mer_browser
 ANALYSIS_LIB_NAME = mer_analysis
 
 #-----------------------------------------------------------------------------#
@@ -67,7 +68,7 @@
 # `mmake depend' forces them to be remade to ensure that they are up-to-date.
 
 .PHONY: dep
-dep: dep_library dep_browser dep_analysis dep_compiler \
+dep: dep_library dep_mdbcomp dep_browser dep_analysis dep_compiler \
 		dep_profiler dep_deep_profiler
 
 .PHONY: dep_library
@@ -76,17 +77,20 @@
 library/$(deps_subdir)$(STD_LIB_NAME).dep:
 	+cd library && $(SUBDIR_MMAKE) depend
 
+.PHONY: dep_mdbcomp
+dep_mdbcomp: \
+	mdbcomp/$(deps_subdir)$(MDBCOMP_LIB_NAME).dep
+
+mdbcomp/$(deps_subdir)$(MDBCOMP_LIB_NAME).dep:
+	+cd mdbcomp && $(SUBDIR_MMAKE) $(MDBCOMP_LIB_NAME).depend
+
 .PHONY: dep_browser
 dep_browser: \
-	browser/$(deps_subdir)$(BROWSER_LIB_NAME).dep \
-	browser/$(deps_subdir)$(MDBCOMP_LIB_NAME).dep
+	browser/$(deps_subdir)$(BROWSER_LIB_NAME).dep
 
 browser/$(deps_subdir)$(BROWSER_LIB_NAME).dep:
 	+cd browser && $(SUBDIR_MMAKE) $(BROWSER_LIB_NAME).depend
 
-browser/$(deps_subdir)$(MDBCOMP_LIB_NAME).dep:
-	+cd browser && $(SUBDIR_MMAKE) $(MDBCOMP_LIB_NAME).depend
-
 .PHONY: dep_analysis
 dep_analysis: analysis/$(deps_subdir)$(ANALYSIS_LIB_NAME).dep
 
@@ -127,6 +131,7 @@
 .PHONY: depend
 depend:
 	+cd library && $(SUBDIR_MMAKE) depend
+	+cd mdbcomp && $(SUBDIR_MMAKE) depend
 	+cd browser && $(SUBDIR_MMAKE) depend
 	+cd analysis && $(SUBDIR_MMAKE) depend
 	+cd compiler && $(SUBDIR_MMAKE) depend
@@ -137,6 +142,10 @@
 depend_library:
 	+cd library && $(SUBDIR_MMAKE) depend
 
+.PHONY: depend_mdbcomp
+depend_mdbcomp:
+	+cd mdbcomp && $(SUBDIR_MMAKE) depend
+
 .PHONY: depend_browser
 depend_browser:
 	+cd browser && $(SUBDIR_MMAKE) depend
@@ -183,26 +192,31 @@
 library: dep_library scripts util boehm_gc runtime
 	+cd library && $(SUBDIR_MMAKE)
 
+.PHONY: mdbcomp
+mdbcomp: dep_mdbcomp scripts util boehm_gc runtime library
+	+cd mdbcomp && $(SUBDIR_MMAKE)
+
 .PHONY: browser
-browser: dep_browser scripts util boehm_gc runtime library
+browser: dep_browser scripts util boehm_gc runtime library mdbcomp
 	+cd browser && $(SUBDIR_MMAKE)
 
 .PHONY: analysis
-analysis: dep_analysis scripts util boehm_gc runtime library browser trace
+analysis: dep_analysis scripts util boehm_gc runtime library mdbcomp browser \
+		trace
 	+cd analysis && $(SUBDIR_MMAKE)
 
 .PHONY: runtime
-trace: scripts boehm_gc runtime library browser
+trace: scripts boehm_gc runtime library mdbcomp browser
 	+cd trace && $(SUBDIR_MMAKE)
 
 .PHONY: compiler
 compiler: dep_compiler scripts util boehm_gc runtime library \
-		browser trace analysis
+		mdbcomp browser trace analysis
 	+cd compiler && $(SUBDIR_MMAKE)
 
 .PHONY: libmmc
 libmmc: dep_compiler scripts util boehm_gc runtime library \
-		browser trace analysis
+		mdbcomp browser trace analysis
 	+cd compiler && $(SUBDIR_MMAKE) libmmc
 
 .PHONY: doc
@@ -210,18 +224,19 @@
 	+cd doc && $(SUBDIR_MMAKE)
 
 .PHONY: profiler
-profiler: dep_profiler scripts util boehm_gc runtime library browser trace
+profiler: dep_profiler scripts util boehm_gc runtime library \
+		mdbcomp browser trace
 	+cd profiler && $(SUBDIR_MMAKE)
 
 .PHONY: deep_profiler
 deep_profiler: dep_deep_profiler scripts util boehm_gc runtime library \
-		browser trace
+		mdbcomp browser trace
 	+cd deep_profiler && $(SUBDIR_MMAKE)
 
 #-----------------------------------------------------------------------------#
 
 .PHONY: tags
-tags: tags_compiler tags_library tags_browser tags_analysis \
+tags: tags_compiler tags_library tags_mdbcomp tags_browser tags_analysis \
 		tags_profiler tags_deep_profiler
 
 .PHONY: tags_compiler
@@ -232,6 +247,10 @@
 tags_library:
 	+cd library && $(SUBDIR_MMAKE) tags
 
+.PHONY: tags_mdbcomp
+tags_mdbcomp:
+	+cd mdbcomp && $(SUBDIR_MMAKE) tags
+
 .PHONY: tags_browser
 tags_browser:
 	+cd browser && $(SUBDIR_MMAKE) tags
@@ -253,7 +272,8 @@
 # Remove from each of the listed directories mmc-generated files that don't
 # belong there.
 cleanint:
-	for dir in analysis browser compiler deep_profiler library profiler; \
+	for dir in library mdbcomp browser analysis compiler \
+		profiler deep_profiler; \
 	do \
 		echo Looking for inappropriate files in the $$dir directory: ; \
 		( cd $$dir && ../tools/cleanint > .cleanint ) ; \
@@ -321,9 +341,12 @@
 	+cd runtime && $(SUBDIR_MMAKE) cs $(RT_LIB_NAME).init
 	+cd library && $(SUBDIR_MMAKE) depend
 	+cd library && $(SUBDIR_MMAKE) all-ints cs $(STD_LIB_NAME).init tags
+	+cd mdbcomp && $(SUBDIR_MMAKE) depend
+	+cd mdbcomp && $(SUBDIR_MMAKE) all-ints cs \
+		$(MDBCOMP_LIB_NAME).init tags
 	+cd browser && $(SUBDIR_MMAKE) depend
 	+cd browser && $(SUBDIR_MMAKE) all-ints cs \
-		$(BROWSER_LIB_NAME).init $(MDBCOMP_LIB_NAME).init tags
+		$(BROWSER_LIB_NAME).init tags
 	+cd trace && $(SUBDIR_MMAKE) cs
 	+cd analysis && $(SUBDIR_MMAKE) depend
 	+cd analysis && $(SUBDIR_MMAKE) all-ints cs tags
@@ -425,7 +448,7 @@
 .PHONY: install_main
 install_main: all \
 		install_scripts install_util install_runtime install_boehm_gc \
-  		install_library install_browser install_trace \
+		install_library install_mdbcomp install_browser install_trace \
 		install_compiler install_profiler install_deep_profiler \
 		install_doc install_config
  
@@ -460,6 +483,10 @@
 install_library: dep_library library
 	+cd library && $(SUBDIR_MMAKE) install
 
+.PHONY: install_mdbcomp
+install_mdbcomp: dep_mdbcomp mdbcomp
+	+cd mdbcomp && $(SUBDIR_MMAKE) install
+
 .PHONY: install_browser
 install_browser: dep_browser browser
 	+cd browser && $(SUBDIR_MMAKE) install
@@ -480,20 +507,11 @@
 install_deep_profiler: deep_profiler
 	+cd deep_profiler && $(SUBDIR_MMAKE) install
 
+# LIBGRADE_SUFFIXES = .m .int3 .date3 .int2 .int .date .opt .optdate \
+#	.trans_opt .trans_opt_date .d .mh .mih .c_date  .c .o .pic_o
+
 .PHONY: install_grades
-install_grades: scripts
-	for dir in boehm_gc runtime trace; do \
-	    ( cd $$dir; rm -rf tmp_dir; mkdir tmp_dir; \
-		mv -f *.$O *.pic_o *.$A *.so tmp_dir; true ); \
-	done
-	for dir in library browser; do \
-	    ( cd $$dir && rm -rf tmp_dir && mkdir tmp_dir && \
-		for ext in $(GRADE_SUBDIR_EXTS); do \
-		    mv -f *.$$ext Mercury/$${ext}s/*.$$ext tmp_dir; \
-		done; \
-		mv -f $(deps_subdir)*.dep $(deps_subdir)*.dv *.$O \
-			Mercury/os/*.$O *.$A *.so tmp_dir; true ); \
-	done
+install_grades: all
 	#
 	# Use the newly installed compiler to build the libraries
 	# in various different grades.  We need to override MC=mmc
@@ -501,48 +519,44 @@
 	# runs the newly installed compiler, rather than using the
 	# bootstrap compiler.
 	#
+	/bin/rm -fr tmp_dir
+	scripts/prepare_tmp_dir_fixed_part
 	+for grade in x $(LIBGRADES); do \
 	    if [ "$$grade" != "x" -a "$$grade" != "$(GRADE)" ]; then \
 	    	gc_grade=`scripts/ml --grade $$grade --print-gc-grade`; \
-	        ( cd boehm_gc && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade GC_GRADE=$$gc_grade \
+		TWS=`/bin/pwd`/tmp_dir;					\
+		scripts/prepare_tmp_dir_grade_part;			\
+	        ( cd tmp_dir/boehm_gc &&				\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade			\
+			WORKSPACE=$$TWS GC_GRADE=$$gc_grade		\
 		  	install_lib ) && \
-		( cd runtime && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_lib ) && \
-		( cd library && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade depend && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_library ) && \
-		( cd browser && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade depend && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_library ) && \
-		( cd trace && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_lib ) && \
-		for dir in boehm_gc runtime trace; do \
-			( cd $$dir && rm -f *.$O *.pic_o *.$A *.so ); \
-		done && \
-		for dir in library browser; do \
-		   ( cd $$dir && \
-		   	for ext in $(GRADE_SUBDIR_EXTS); do \
-				rm -f *.$$ext Mercury/$${ext}s/*.$$ext; \
-			done && \
-			rm -f $(deps_subdir)*.dep $(deps_subdir)*.dv *.$O \
-				Mercury/os/*.$O *.$A *.so ); \
-		done \
-		|| { scripts/mercury_cleanup_install; exit 1; }; \
+		( cd tmp_dir/runtime &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			install_lib ) &&				\
+		( cd tmp_dir/library &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			depend &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			install_library ) &&				\
+		( cd tmp_dir/mdbcomp &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			depend &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			install_library ) &&				\
+		( cd tmp_dir/browser &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			depend &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			install_library ) &&				\
+		( cd tmp_dir/trace &&					\
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS	\
+			install_lib ) &&				\
+		true ||							\
+		{ echo "To clean up from failed install, remove tmp_dir"; \
+		  exit 1; };						\
 	    fi; \
 	done
-	for dir in boehm_gc runtime trace; do \
-	    ( cd $$dir && { mv tmp_dir/* . ; rmdir tmp_dir; true; } ); \
-	done
-	for dir in library browser; do \
-	    ( cd $$dir && { \
-		for ext in $(GRADE_SUBDIR_EXTS); do \
-		    [ -d Mercury/$${ext}s ] && \
-		    	mv tmp_dir/*.$$ext Mercury/$${ext}s; \
-		done; \
-		mv tmp_dir/*.dep tmp_dir/*.dv $(deps_subdir).; \
-	    	mv tmp_dir/* . ; rmdir tmp_dir; true; } ); \
-	done
+	if test ! -f .leave_tmp_dir; then rm -fr tmp_dir; fi
 
 .PHONY: install_split_library
 install_split_library: scripts dep_library
@@ -593,6 +607,10 @@
 	touch library/*.optdate
 	chmod +w library/*.dep
 	touch library/*.dep
+	touch mdbcomp/*.date*
+	touch mdbcomp/*.optdate
+	chmod +w mdbcomp/*.dep
+	touch mdbcomp/*.dep
 	touch browser/*.date*
 	touch browser/*.optdate
 	chmod +w browser/*.dep
@@ -614,6 +632,7 @@
 	touch boehm_gc/*.c
 	touch runtime/*.c
 	touch library/*.c
+	touch mdbcomp/*.c
 	touch browser/*.c
 	touch trace/*.c
 	touch compiler/*.c
@@ -646,7 +665,8 @@
 
 .PHONY: clean_subdirs
 clean_subdirs:
-	rm -rf runtime/tmp_dir library/tmp_dir browser/tmp_dir trace/tmp_dir
+	rm -rf runtime/tmp_dir library/tmp_dir mdbcomp/tmp_dir \
+		browser/tmp_dir trace/tmp_dir
 	+for dir in $(SUBDIRS); do \
 		if [ "$$dir" = scripts ]; then continue; fi; \
 		(cd $$dir; $(SUBDIR_MMAKE) clean) \
Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.411
diff -u -b -r1.411 configure.in
--- configure.in	27 Dec 2004 04:17:12 -0000	1.411
+++ configure.in	26 Jan 2005 01:20:14 -0000
@@ -2526,7 +2526,8 @@
 "using grade \`$GRADE' to compile the compiler
 	compiler and library will be rebuilt with new grade
 	installation may take a long time")
-		find library compiler browser analysis profiler deep_profiler \
+		find library compiler browser mdbcomp analysis \
+			profiler deep_profiler \
 			-name \*.c -o -name \*.c_date | \
 			xargs rm > /dev/null 2>&1
 	fi
@@ -3907,7 +3908,7 @@
 to_delete=""
 if test "$BOOTSTRAP_MC" != "" ; then
     MERCURY_MSG("checking whether any C files need to be rebuilt...")
-    for directory in library compiler profiler deep_profiler browser
+    for directory in library compiler profiler deep_profiler mdbcomp browser
     do
         mercury_check_c_files $directory $directory
         mercury_check_c_files $directory/Mercury/cs $directory/Mercury/c_dates
@@ -3975,9 +3976,10 @@
 scripts/mercury.bat scripts/mprof scripts/mercury_update_interface
 scripts/mgnuc scripts/parse_ml_options.sh-subr scripts/ml
 scripts/c2init scripts/mmake scripts/mdb scripts/mdbrc scripts/mdprof
-scripts/canonical_grade
-scripts/mkfifo_using_mknod bindist/bindist.INSTALL bindist/bindist.Makefile
+scripts/canonical_grade scripts/mkfifo_using_mknod
 scripts/mercury_config scripts/Mercury.config scripts/Mercury.config.bootstrap
+scripts/prepare_tmp_dir_fixed_part
+bindist/bindist.INSTALL bindist/bindist.Makefile
 tools/lmc tools/dotime runtime/mercury_dotnet.cs java/runtime/Constants.java
 java/runtime/Native.java
 ,
@@ -4003,10 +4005,12 @@
 	# will work correctly if you rerun configure with a new --prefix and
 	# then don't do a `make clean' before running `make'.
 	rm -f runtime/libmer_rt.so library/libmer_std.so bytecode/libmbi.so
-	rm -f trace/libmer_trace.so browser/libmer_browse.so
+	rm -f trace/libmer_trace.so browser/libmer_browser.so
+	rm -f mdbcomp/libmer_mdbcomp.so
 	rm -f runtime/libmer_rt.dylib library/libmer_std.dylib 
 	rm -f boehm_gc/libgc.dylib bytecode/libmbi.dylib
 	rm -f trace/libmer_trace.dylib browser/libmer_browser.dylib
+	rm -f mdbcomp/libmer_mdbcomp.dylib
 	;;
 esac],
 [reconfiguring=$reconfiguring]
cvs diff: Diffing analysis
Index: analysis/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/analysis/Mmakefile,v
retrieving revision 1.3
diff -u -b -r1.3 Mmakefile
--- analysis/Mmakefile	14 Jan 2005 05:53:18 -0000	1.3
+++ analysis/Mmakefile	26 Jan 2005 07:03:29 -0000
@@ -94,7 +94,7 @@
 #-----------------------------------------------------------------------------#
 
 .PHONY: os cs ss ils
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 os: $($(ANALYSIS_LIB_NAME).os)
 cs: $($(ANALYSIS_LIB_NAME).cs)
 ss: $($(ANALYSIS_LIB_NAME).ss)
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/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/Mercury.options,v
retrieving revision 1.5
diff -u -b -r1.5 Mercury.options
--- browser/Mercury.options	24 Jan 2005 07:53:37 -0000	1.5
+++ browser/Mercury.options	25 Jan 2005 02:45:46 -0000
@@ -7,7 +7,6 @@
 #-----------------------------------------------------------------------------#
 
 MCFLAGS-mer_browser = --no-warn-nothing-exported
-MCFLAGS-mer_mdbcomp = --no-warn-nothing-exported
 
 # XXX Disable higher order specialization for declarative_edt since this
 # optimization has a suspected bug that mdb.declarative_edt.revise_root/3
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.43
diff -u -b -r1.43 Mmakefile
--- browser/Mmakefile	14 Jan 2005 05:53:23 -0000	1.43
+++ browser/Mmakefile	26 Jan 2005 16:29:21 -0000
@@ -23,6 +23,7 @@
 CHECK_OBJS  = $(mer_browser.os)
 ALLOW_LIB_PREFIX=yes
 ALLOW_BROWSER_PREFIX=yes
+ALLOW_MDBCOMP_PREFIX=yes
 
 MERCURY_DIR=..
 LINK_STDLIB_ONLY=yes
@@ -35,9 +36,11 @@
 
 MAIN_TARGET=main
 
-MERCURY_MAIN_LIB_MODULES=$(BROWSER_LIB_NAME) $(MDBCOMP_LIB_NAME)
+MERCURY_MAIN_LIB_MODULES=$(BROWSER_LIB_NAME)
 MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES) browse_test declarative_test
 
+VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR)
+
 DEPENDS =	$(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
 INTS_TARGETS =	$(patsubst %,%.ints,$(MERCURY_MAIN_MODULES))
 INT3S_TARGETS =	$(patsubst %,%.int3s,$(MERCURY_MAIN_MODULES))
@@ -50,10 +53,11 @@
 # Don't change these without good reason - if you want to do a temporary
 # change, change ../Mmake.params, or create Mmake.browser.params.
 
-CFLAGS	+=	$(DLL_CFLAGS) -I$(TRACE_DIR)
+CFLAGS	+=	$(DLL_CFLAGS) -I$(MDBCOMP_DIR) -I$(TRACE_DIR)
 MLFLAGS +=	-R$(FINAL_INSTALL_MERC_LIB_DIR)	\
 		-R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
-MCFLAGS +=	-R$(FINAL_INSTALL_MERC_LIB_DIR)	\
+MCFLAGS +=	-I $(MDBCOMP_DIR) \
+		-R$(FINAL_INSTALL_MERC_LIB_DIR)	\
 		-R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
 MLLIBS +=	$(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY)	\
 		$(READLINE_LIBRARIES)
@@ -75,8 +79,6 @@
 MCFLAGS += --no-shlib-linker-use-install-name
 LD_LIBFLAGS-libmer_browser.dylib = -install_name \
 	$(FINAL_INSTALL_MERC_LIB_DIR)/libmer_browser.dylib
-LD_LIBFLAGS-libmer_mdbcomp.dylib = -install_name \
-	$(FINAL_INSTALL_MERC_LIB_DIR)/libmer_mdbcomp.dylib
 
 #-----------------------------------------------------------------------------#
 
@@ -131,55 +133,33 @@
 depend:	$(DEPENDS)
 $(DEPENDS): Mercury.modules
 
-# This directory contains two libraries, mer_browser and mer_mdbcomp,
-# and mer_browser depends on mer_mdbcomp.  But Mmake will by default
-# assume that each library contains any file referenced from the
-# top-level module which occurs in the current directory, which leads
-# it to incorrectly assume that the mer_browser library should include
-# the mdbcomp.m and program_representation.m files.
-# To avoid this problem, we temporarily rename those files away
-# when building the dependencies for mer_browser.
-#
-# We use the phony .NOTPARALLEL target to disable parallel make,
-# to ensure that we don't try to execute any other rule while
-# the files are renamed.
-# We also need to be careful to ensure that the files get renamed
-# back properly even if making the dependencies fails or a signal occurs.
-# XXX This is all a bit hacky.
-
 .NOTPARALLEL:
 
-$(BROWSER_LIB_NAME).dep $(BROWSER_LIB_NAME).depend:
-	trap 'mv RENAMED_mdbcomp.m mdbcomp.m; \
-		mv RENAMED_program_representation.m program_representation.m; \
-		exit 1' 1 2 3 13 15; \
-	mv mdbcomp.m RENAMED_mdbcomp.m; \
-	mv program_representation.m RENAMED_program_representation.m ;\
-	$(MCD) $(ALL_GRADEFLAGS) $(ALL_MCDFLAGS) $*; \
-	status=$$?; \
-	mv RENAMED_mdbcomp.m mdbcomp.m; \
-	mv RENAMED_program_representation.m program_representation.m; \
-	exit $$status
-
-lib$(BROWSER_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
-lib$(BROWSER_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
-lib$(BROWSER_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
-lib$(BROWSER_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
-lib$(BROWSER_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
-lib$(BROWSER_LIB_NAME).cs: lib$(MDBCOMP_LIB_NAME).cs
-lib$(BROWSER_LIB_NAME).ss: lib$(MDBCOMP_LIB_NAME).ss
-lib$(BROWSER_LIB_NAME).ils: lib$(MDBCOMP_LIB_NAME).ils
-lib$(BROWSER_LIB_NAME).javas: lib$(MDBCOMP_LIB_NAME).javas
-lib$(BROWSER_LIB_NAME).check: lib$(MDBCOMP_LIB_NAME).check
-$($(BROWSER_LIB_NAME).ints): $($(MDBCOMP_LIB_NAME).ints)
-$($(BROWSER_LIB_NAME).cs): $($(MDBCOMP_LIB_NAME).cs)
-$($(BROWSER_LIB_NAME).ss): $($(MDBCOMP_LIB_NAME).ss)
-$($(BROWSER_LIB_NAME).ils): $($(MDBCOMP_LIB_NAME).ils)
-$($(BROWSER_LIB_NAME).javas): $($(MDBCOMP_LIB_NAME).java_dates)
-$($(BROWSER_LIB_NAME).c_dates): $($(MDBCOMP_LIB_NAME).c_dates)
-$($(BROWSER_LIB_NAME).s_dates): $($(MDBCOMP_LIB_NAME).s_dates)
-$($(BROWSER_LIB_NAME).il_dates): $($(MDBCOMP_LIB_NAME).il_dates)
-$($(BROWSER_LIB_NAME).java_dates): $($(MDBCOMP_LIB_NAME).java_dates)
+# $(BROWSER_LIB_NAME).dep $(BROWSER_LIB_NAME).depend:
+# 	$(MCD) $(ALL_GRADEFLAGS) $(ALL_MCDFLAGS) $*
+
+# The need for these dependencies should be obviated by the fact that the
+# mdbcomp directory is brought up-to-date first.
+
+# lib$(BROWSER_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
+# lib$(BROWSER_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
+# lib$(BROWSER_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
+# lib$(BROWSER_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
+# lib$(BROWSER_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
+# lib$(BROWSER_LIB_NAME).cs: lib$(MDBCOMP_LIB_NAME).cs
+# lib$(BROWSER_LIB_NAME).ss: lib$(MDBCOMP_LIB_NAME).ss
+# lib$(BROWSER_LIB_NAME).ils: lib$(MDBCOMP_LIB_NAME).ils
+# lib$(BROWSER_LIB_NAME).javas: lib$(MDBCOMP_LIB_NAME).javas
+# lib$(BROWSER_LIB_NAME).check: lib$(MDBCOMP_LIB_NAME).check
+# $($(BROWSER_LIB_NAME).ints): $($(MDBCOMP_LIB_NAME).ints)
+# $($(BROWSER_LIB_NAME).cs): $($(MDBCOMP_LIB_NAME).cs)
+# $($(BROWSER_LIB_NAME).ss): $($(MDBCOMP_LIB_NAME).ss)
+# $($(BROWSER_LIB_NAME).ils): $($(MDBCOMP_LIB_NAME).ils)
+# $($(BROWSER_LIB_NAME).javas): $($(MDBCOMP_LIB_NAME).java_dates)
+# $($(BROWSER_LIB_NAME).c_dates): $($(MDBCOMP_LIB_NAME).c_dates)
+# $($(BROWSER_LIB_NAME).s_dates): $($(MDBCOMP_LIB_NAME).s_dates)
+# $($(BROWSER_LIB_NAME).il_dates): $($(MDBCOMP_LIB_NAME).il_dates)
+# $($(BROWSER_LIB_NAME).java_dates): $($(MDBCOMP_LIB_NAME).java_dates)
 
 # This directory contains source files for which the module
 # name doesn't match the file name, so smart recompilation
@@ -202,31 +182,24 @@
 
 #-----------------------------------------------------------------------------#
 
-tags:	$(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms)
-	$(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms) \
-		../library/*.m
+tags:	$(MTAGS) $($(BROWSER_LIB_NAME).ms)
+	$(MTAGS) $($(BROWSER_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m
 
 .PHONY: tags_file_exists
 tags_file_exists:
 	@if test ! -f tags; then echo making tags; \
-	$(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms) \
-		../library/*.m ; fi
+	$(MTAGS) $($(BROWSER_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m ; fi
 
 $(BROWSER_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
 		$($(BROWSER_LIB_NAME).ms)
 	awk -f $(COMPILER_DIR)/source_stats.awk \
 		`vpath_find $($(BROWSER_LIB_NAME).ms)` > $@
 
-$(MDBCOMP_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
-		$($(MDBCOMP_LIB_NAME).ms)
-	awk -f $(COMPILER_DIR)/source_stats.awk \
-		`vpath_find $($(MDBCOMP_LIB_NAME).ms)` > $@
-
 #-----------------------------------------------------------------------------#
 
 .PHONY: dates
 dates:
-	touch $($(BROWSER_LIB_NAME).dates) $($(MDBCOMP_LIB_NAME).dates)
+	touch $($(BROWSER_LIB_NAME).dates)
 
 #-----------------------------------------------------------------------------#
 
@@ -234,7 +207,8 @@
 # Some Java compilers require the Java source files to be put in directories
 # which match their package names.  But the Mercury compiler generates them
 # with the package name prefixed to the file name with a ".", not a "/".
-# So we copy the Java source files to where the Java compiler expects them to be.
+# So we copy the Java source files to where the Java compiler expects them
+# to be.
 #
 # XXX This is a hack.  We ought to change the Mercury compiler so that it
 # generates the Java files with the right names in the first place.
@@ -244,15 +218,9 @@
 	[ -d mdb ] || mkdir mdb
 	cp $< $@
 
-mdbcomp/%.java: mdbcomp.%.java
-	[ -d mdbcomp ] || mkdir mdbcomp
-	cp $< $@
+RENAMED_JAVAS = $($(BROWSER_LIB_NAME).javas:mdb.%.java=mdb/%.java)
 
-RENAMED_JAVAS = $($(BROWSER_LIB_NAME).javas:mdb.%.java=mdb/%.java) \
-	$($(MDBCOMP_LIB_NAME).javas:mdbcomp.%.java=mdbcomp/%.java)
-
-RENAMED_CLASSES = $($(BROWSER_LIB_NAME).classes:mdb.%.class=mdb/%.class) \
-	$($(MDBCOMP_LIB_NAME).classes:mdbcomp.%.class=mdbcomp/%.class)
+RENAMED_CLASSES = $($(BROWSER_LIB_NAME).classes:mdb.%.class=mdb/%.class)
 
 .PHONY: javas
 javas: $(RENAMED_JAVAS)
@@ -264,16 +232,16 @@
 #-----------------------------------------------------------------------------#
 
 .PHONY: os cs ss ils
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
-os: $($(BROWSER_LIB_NAME).os) $($(MDBCOMP_LIB_NAME).os)
-cs: $($(BROWSER_LIB_NAME).cs) $($(MDBCOMP_LIB_NAME).cs)
-ss: $($(BROWSER_LIB_NAME).ss) $($(MDBCOMP_LIB_NAME).ss)
-ils: $($(BROWSER_LIB_NAME).ils) $($(MDBCOMP_LIB_NAME).ils)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
+os: $($(BROWSER_LIB_NAME).os)
+cs: $($(BROWSER_LIB_NAME).cs)
+ss: $($(BROWSER_LIB_NAME).ss)
+ils: $($(BROWSER_LIB_NAME).ils)
 else
-os: $(BROWSER_LIB_NAME).os $(MDBCOMP_LIB_NAME).os
-cs: $(BROWSER_LIB_NAME).cs $(MDBCOMP_LIB_NAME).cs
-ss: $(BROWSER_LIB_NAME).ss $(MDBCOMP_LIB_NAME).ss
-ils: $(BROWSER_LIB_NAME).ils $(MDBCOMP_LIB_NAME).ils
+os: $(BROWSER_LIB_NAME).os
+cs: $(BROWSER_LIB_NAME).cs
+ss: $(BROWSER_LIB_NAME).ss
+ils: $(BROWSER_LIB_NAME).ils
 endif
 
 #-----------------------------------------------------------------------------#
@@ -281,8 +249,6 @@
 # Ensure we recompile mdb__version if VERSION is changed.
 $(os_subdir)mdb.o \
 $(os_subdir)mdb.pic_o \
-$(os_subdir)mdbcomp.o \
-$(os_subdir)mdbcomp.pic_o \
         : $(RUNTIME_DIR)/mercury_conf.h
 
 #-----------------------------------------------------------------------------#
@@ -315,24 +281,17 @@
 else 
 
 .PHONY: install_init
-install_init: $(BROWSER_LIB_NAME).init $(MDBCOMP_LIB_NAME).init install_dirs
+install_init: $(BROWSER_LIB_NAME).init install_dirs
 	cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
-	cp `vpath_find $(MDBCOMP_LIB_NAME).init` $(INSTALL_MODULE_DIR)
 
 .PHONY: install_library
 install_library: \
 		lib$(BROWSER_LIB_NAME).$A \
 		lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
-		lib$(MDBCOMP_LIB_NAME).$A \
-		lib$(MDBCOMP_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
 		install_dirs
 	cp `vpath_find lib$(BROWSER_LIB_NAME).$A \
 		lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
 		$(INSTALL_MERC_LIB_DIR)
-	cp `vpath_find lib$(MDBCOMP_LIB_NAME).$A \
-		lib$(MDBCOMP_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
-		$(INSTALL_MERC_LIB_DIR)
 	$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(BROWSER_LIB_NAME).$A
-	$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(MDBCOMP_LIB_NAME).$A
 
 endif
Index: browser/declarative_oracle.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_oracle.m,v
retrieving revision 1.36
diff -u -b -r1.36 declarative_oracle.m
--- browser/declarative_oracle.m	24 Jan 2005 07:41:03 -0000	1.36
+++ browser/declarative_oracle.m	26 Jan 2005 06:14:11 -0000
@@ -119,13 +119,21 @@
 
 :- implementation.
 
-:- import_module mdb__declarative_user.
-:- import_module mdb__util.
-:- import_module mdbcomp__prim_data.
-
-:- import_module map, bool, std_util, set, int, bimap, counter, assoc_list,
-	exception, list.
+:- import_module mdb.declarative_user.
+:- import_module mdb.util.
+:- import_module mdbcomp.prim_data.
+
+:- import_module assoc_list.
+:- import_module bimap.
+:- import_module bool.
+:- import_module counter.
+:- import_module exception.
+:- import_module int.
 :- import_module library.
+:- import_module list.
+:- import_module map.
+:- import_module set.
+:- import_module std_util.
 
 query_oracle(Question, Response, !Oracle, !IO) :-
 	(
Index: browser/mdbcomp.m
===================================================================
RCS file: browser/mdbcomp.m
diff -N browser/mdbcomp.m
--- browser/mdbcomp.m	19 Jan 2005 03:10:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,47 +0,0 @@
-%---------------------------------------------------------------------------%
-% Copyright (C) 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.
-%---------------------------------------------------------------------------%
-%
-% This is the top module of a library that contains information shared
-% between the debugger and the compiler. This means mostly the definitions
-% of data structures that the compiler generates for the debugger, and
-% the predicates that operate on them.
-%
-% The compiler links in this library in all grades, but links in the mdb
-% library (which also in this directory) only when debugging is enabled.
-% Therefore the modules of the mdbcomp library should avoid importing any
-% module of the mdb library.
-
-:- module mdbcomp.
-
-:- interface.
-
-:- pred mdbcomp__version(string::out) is det.
-
-:- include_module prim_data.
-:- include_module program_representation.
-:- include_module trace_counts.
-
-:- implementation.
-
-% See library/library.m for why we implement this predicate this way.
-
-:- pragma foreign_proc("C",
-	mdbcomp__version(Version::out),
-	[will_not_call_mercury, promise_pure, thread_safe],
-"
-	MR_ConstString version_string;
-
-	version_string = MR_VERSION "", configured for "" MR_FULLARCH;
-	/*
-	** Cast away const needed here, because Mercury declares Version
-	** with type MR_String rather than MR_ConstString.
-	*/
-	Version = (MR_String) (MR_Word) version_string;
-").
-
-mdbcomp__version("unknown version").
-
-%---------------------------------------------------------------------------%
Index: browser/mer_mdbcomp.m
===================================================================
RCS file: browser/mer_mdbcomp.m
diff -N browser/mer_mdbcomp.m
--- browser/mer_mdbcomp.m	27 Oct 2003 06:00:32 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-%-----------------------------------------------------------------------------%
-% Copyright (C) 2003 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.
-%-----------------------------------------------------------------------------%
-% File: mer_mdbcomp.m
-%
-% This file is only present so that the mdbcomp library is
-% generated with the correct name.
-%-----------------------------------------------------------------------------%
-
-:- module mer_mdbcomp.
-
-:- implementation.
-
-:- import_module mdbcomp.
Index: browser/prim_data.m
===================================================================
RCS file: browser/prim_data.m
diff -N browser/prim_data.m
--- browser/prim_data.m	24 Jan 2005 07:41:04 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,152 +0,0 @@
-%-----------------------------------------------------------------------------%
-% Copyright (C) 2005 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.
-%-----------------------------------------------------------------------------%
-%
-% File: prim_data.m.
-% Main authors: fjh, zs.
-%
-% This module contains some types and predicates that are, or are planned to 
-% be, shared between the compiler and the debugger.
-
-%-----------------------------------------------------------------------------%
-
-:- module mdbcomp.prim_data.
-
-:- interface.
-
-% was in browser/util.m and compiler/prog_data.m
-
-	% This enumeration must be EXACTLY the same as the MR_PredFunc enum
-	% in runtime/mercury_stack_layout.h, and in the same order, since the
-	% code (in browser) assumes the representation is the same.
-
-:- type pred_or_func
-	--->	predicate
-	;	function.
-
-% was in browser/util.m and compiler/trace_params.m
-
-	% The kinds of events with which MR_trace may be called, either
-	% by compiler-generated code, or by code in the standard library
-	% referring to compiler-generated data structures.
-	%
-	% This enumeration must be EXACTLY the same as the MR_trace_port enum
-	% in runtime/mercury_trace_base.h, and in the same order, since the
-	% code (in browser) assumes the representation is the same.
-
-:- type trace_port
-	--->	call
-	;	exit
-	;	redo
-	;	fail
-	;	exception
-	;	ite_cond
-	;	ite_then
-	;	ite_else
-	;	neg_enter
-	;	neg_success
-	;	neg_failure
-	;	disj
-	;	switch
-	;	nondet_pragma_first
-	;	nondet_pragma_later
-	.
-
-% was in compiler/prog_data.m
-
-	% The order that the sym_name function symbols appear in is
-	% significant for module dependency ordering.
-
-:- type sym_name
-	--->	unqualified(string)
-	;	qualified(sym_name, string).
-
-:- type module_name == sym_name.
-
-% was in compiler/proc_label.m
-
-	% A proc_label is a data structure a backend can use to as the basis
-	% of the label used as the entry point of a procedure.
-	%
-	% The defining module is the module that provides the code for the
-	% predicate, the declaring module contains the `:- pred' declaration.
-	% When these are different, as for specialised versions of predicates
-	% from `.opt' files, the defining module's name may need to be added
-	% as a qualifier to the label.
-
-:- type proc_label
-	--->	proc(
-			module_name,	% defining module
-			pred_or_func,
-			module_name,	% declaring module
-			string,		% name
-			int,		% arity
-			int		% mode number
-		)
-	;	special_proc(
-			module_name,	% defining module
-			special_pred_id,% indirectly defines pred name
-			module_name,	% type module
-			string,		% type name
-			int,		% type arity
-			int		% mode number
-		).
-
-% was in compiler/special_pred.m
-
-:- type special_pred_id
-	--->	unify
-	;	index
-	;	compare
-	;	initialise.
-
-% was in compiler/prog_util.m
-
-	% string_to_sym_name(String, Separator, SymName):
-	%	Convert a string, possibly prefixed with
-	%	module qualifiers (separated by Separator),
-	%	into a symbol name.
-	%
-:- pred string_to_sym_name(string::in, string::in, sym_name::out) is det.
-
-	% insert_module_qualifier(ModuleName, SymName0, SymName):
-	%	prepend the specified ModuleName onto the module
-	%	qualifiers in SymName0, giving SymName.
-:- pred insert_module_qualifier(string::in, sym_name::in, sym_name::out)
-	is det.
-
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-
-:- import_module int, string. 
-
-% This would be simpler if we had a string__rev_sub_string_search/3 pred.
-% With that, we could search for underscores right-to-left,
-% and construct the resulting symbol directly.
-% Instead, we search for them left-to-right, and then call
-% insert_module_qualifier to fix things up.
-
-string_to_sym_name(String, ModuleSeparator, Result) :-
-	(
-		string__sub_string_search(String, ModuleSeparator, LeftLength),
-		LeftLength > 0
-	->
-		string__left(String, LeftLength, ModuleName),
-		string__length(String, StringLength),
-		string__length(ModuleSeparator, SeparatorLength),
-		RightLength = StringLength - LeftLength - SeparatorLength,
-		string__right(String, RightLength, Name),
-		string_to_sym_name(Name, ModuleSeparator, NameSym),
-		insert_module_qualifier(ModuleName, NameSym, Result)
-	;
-		Result = unqualified(String)
-	).
-
-insert_module_qualifier(ModuleName, unqualified(PlainName),
-		qualified(unqualified(ModuleName), PlainName)).
-insert_module_qualifier(ModuleName, qualified(ModuleQual0, PlainName),
-		qualified(ModuleQual, PlainName)) :-
-	insert_module_qualifier(ModuleName, ModuleQual0, ModuleQual).
Index: browser/program_representation.m
===================================================================
RCS file: browser/program_representation.m
diff -N browser/program_representation.m
--- browser/program_representation.m	24 Jan 2005 07:41:04 -0000	1.13
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,347 +0,0 @@
-%-----------------------------------------------------------------------------%
-% Copyright (C) 2001-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.
-%-----------------------------------------------------------------------------%
-%
-% File: program_representation.m
-% Authors: zs, dougl
-%
-% This module defines the representation of procedure bodies
-% used by the declarative debugger.
-%
-% One of the things we want the declarative debugger to be able to do
-% is to let the user specify which part of which output argument of an
-% incorrect or inadmissible atom is suspicious, and then find out where
-% that particular subterm came from, i.e. where it was bound. Doing this
-% requires knowing what the bodies of that procedure and its descendants are.
-%
-% If the Mercury compiler is invoked with options requesting declarative
-% debugging, it will include in each procedure layout a pointer to a simplified
-% representation of the goal that is the body of the corresponding procedure.
-% We use a simplified representation partly because we want to insulate the
-% code of the declarative debugger from irrelevant changes in HLDS types,
-% and partly because we want to minimize the space taken in up in executables
-% by these representations.
-%
-% The current representation is intended to contain all the information
-% we are pretty sure can be usefully exploited by the declarative debugger.
-
-%-----------------------------------------------------------------------------%
-
-:- module mdbcomp.program_representation.
-
-:- interface.
-
-:- import_module char, list, std_util, bool.
-
-	% A representation of the goal we execute.  These need to be
-	% generated statically and stored inside the executable.
-	%
-	% Each element of this structure will correspond one-to-one
-	% to the original stage 90 HLDS.
-
-:- type proc_rep
-	--->	proc_rep(
-			list(var_rep),		% The head variables, in order,
-						% including the ones introduced
-						% by the compiler.
-			goal_rep		% The procedure body.
-		).
-
-:- type goal_rep
-	--->	conj_rep(
-			list(goal_rep)		% The conjuncts in the original
-						% order.
-		)
-	;	disj_rep(
-			list(goal_rep)		% The disjuncts in the original
-						% order.
-		)
-	;	switch_rep(
-			list(goal_rep)		% The switch arms in the
-						% original order.
-		)
-	;	ite_rep(
-			goal_rep,		% Condition.
-			goal_rep,		% Then branch.
-			goal_rep		% Else branch.
-		)
-	;	negation_rep(
-			goal_rep		% The negated goal.
-		)
-	;	some_rep(
-			goal_rep,		% The quantified goal.
-			maybe_cut
-		)
-	;	atomic_goal_rep(
-			detism_rep,
-			string,			% Filename of context.
-			int,			% Line number of context.
-			list(var_rep),		% The sorted list of the
-						% variables bound by the
-						% atomic goal.
-			atomic_goal_rep
-		).
-
-:- type atomic_goal_rep
-	--->	unify_construct_rep(
-			var_rep,
-			cons_id_rep,
-			list(var_rep)
-		)
-	;	unify_deconstruct_rep(
-			var_rep,
-			cons_id_rep,
-			list(var_rep)
-		)
-	;	unify_assign_rep(
-			var_rep,		% target
-			var_rep			% source
-		)
-	;	unsafe_cast_rep(
-			var_rep,		% target
-			var_rep			% source
-		)
-	;	unify_simple_test_rep(
-			var_rep,
-			var_rep
-		)
-	;	pragma_foreign_code_rep(
-			list(var_rep)		% arguments
-		)
-	;	higher_order_call_rep(
-			var_rep,		% the closure to call
-			list(var_rep)		% the call's plain arguments
-		)
-	;	method_call_rep(
-			var_rep,		% typeclass info var
-			int,			% method number
-			list(var_rep)		% the call's plain arguments
-		)
-	;	plain_call_rep(
-			string,			% name of called pred's module
-			string,			% name of the called pred
-			list(var_rep)		% the call's arguments
-		)
-	;	builtin_call_rep(
-			string,			% name of called pred's module
-			string,			% name of the called pred
-			list(var_rep)		% the call's arguments
-		).
-
-:- type var_rep	==	int.
-
-:- type cons_id_rep ==	string.
-
-:- type detism_rep	
-	--->	det_rep
-	;	semidet_rep
-	;	nondet_rep
-	;	multidet_rep
-	;	cc_nondet_rep
-	;	cc_multidet_rep
-	;	erroneous_rep
-	;	failure_rep.
-
-	% If the given atomic goal behaves like a call in the sense that it
-	% generates events, then return the list of variables that are passed
-	% as arguments.
-	%
-:- func atomic_goal_generates_event(atomic_goal_rep) = maybe(list(var_rep)).
-
-	% If the given goal generates internal events directly then this
-	% function will return yes and no otherwise. 
-	%
-:- func goal_generates_internal_event(goal_rep) = bool.
-
-	% call_is_primitive(ModuleName, PredName): succeeds iff a call to the
-	% named predicate behaves like a primitive operation, in the sense that
-	% it does not generate events.
-:- pred call_is_primitive(string::in, string::in) is semidet.
-
-	% The atomic goals module, name and arity
-:- type atomic_goal_id 
-	---> atomic_goal_id(string, string, int).
-
-	% Can we find out the atomic goals name, module and arity from
-	% its atomic_goal_rep?  If so return them, otherwise return no.
-:- func atomic_goal_identifiable(atomic_goal_rep) = 
-	maybe(atomic_goal_id).
-
-%-----------------------------------------------------------------------------%
-
-	% The following three types are derived from compiler/hlds_goal.m.
-
-:- type goal_path == list(goal_path_step).
-
-:- type goal_path_step  --->    conj(int)
-                        ;       disj(int)
-                        ;       switch(int)
-                        ;       ite_cond
-                        ;       ite_then
-                        ;       ite_else
-                        ;       neg
-                        ;       exist(maybe_cut)
-                        ;       first
-                        ;       later.
-
-	% Does `some G' have a different determinism from plain `G'?
-:- type maybe_cut       --->    cut ; no_cut.
-
-:- pred path_from_string_det(string, goal_path).
-:- mode path_from_string_det(in, out) is det.
-
-:- pred path_from_string(string, goal_path).
-:- mode path_from_string(in, out) is semidet.
-
-:- pred path_step_from_string(string, goal_path_step).
-:- mode path_step_from_string(in, out) is semidet.
-
-:- pred is_path_separator(char).
-:- mode is_path_separator(in) is semidet.
-
-	% User-visible head variables are represented by a number from 1..N,
-	% where N is the user-visible arity.
-	%
-	% Both user-visible and compiler-generated head variables can be
-	% referred to via their position in the full list of head variables;
-	% the first head variable is at position 1.
-	
-:- type arg_pos
-	--->	user_head_var(int)	% Nth in the list of arguments after
-					% filtering out non-user-visible vars.
-	;	any_head_var(int)	% Nth in the list of all arguments.
-			
-			% (M-N+1)th argument in the list of all arguments,
-			% where N is the value of the int in the constructor
-			% and M is the total number of arguments.
-	;	any_head_var_from_back(int).
-
-	% A particular subterm within a term is represented by a term_path.
-	% This is the list of argument positions that need to be followed
-	% in order to travel from the root to the subterm.  In contrast to
-	% goal_paths, this list is in top-down order.
-
-:- type term_path ==	list(int).
-
-	% Returns type_of(_ `with_type` proc_rep), for use in C code.
-:- func proc_rep_type = type_desc.
-
-	% Returns type_of(_ `with_type` goal_rep), for use in C code.
-:- func goal_rep_type = type_desc.
-
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-:- import_module string, char, require.
-
-atomic_goal_generates_event(unify_construct_rep(_, _, _)) = no.
-atomic_goal_generates_event(unify_deconstruct_rep(_, _, _)) = no.
-atomic_goal_generates_event(unify_assign_rep(_, _)) = no.
-atomic_goal_generates_event(unify_simple_test_rep(_, _)) = no.
-atomic_goal_generates_event(unsafe_cast_rep(_, _)) = no.
-atomic_goal_generates_event(pragma_foreign_code_rep(_)) = no.
-atomic_goal_generates_event(higher_order_call_rep(_, Args)) = yes(Args).
-atomic_goal_generates_event(method_call_rep(_, _, Args)) = yes(Args).
-atomic_goal_generates_event(builtin_call_rep(_, _, _)) = no.
-atomic_goal_generates_event(plain_call_rep(ModuleName, PredName, Args)) =
-	( call_is_primitive(ModuleName, PredName) ->
-		% These calls behave as primitives and do not generate events.
-		no
-	;
-		yes(Args)
-	).
-
-call_is_primitive(ModuleName, PredName) :-
-	(
-		ModuleName = "builtin",
-		( PredName = "unify"
-		; PredName = "compare"
-		)
-	;
-		ModuleName = "profiling_builtin"
-	;
-		ModuleName = "term_size_prof_builtin"
-	;
-	%
-	% The following are also treated as primitive since
-	% compiler generated predicate events are not 
-	% included in the annotated trace at the moment.
-	%
-		PredName = "__Unify__"
-	;
-		PredName = "__Index__"
-	;
-		PredName = "__Compare__"
-	).
-
-goal_generates_internal_event(conj_rep(_)) = no.
-goal_generates_internal_event(disj_rep(_)) = yes.
-goal_generates_internal_event(switch_rep(_)) = yes.
-goal_generates_internal_event(ite_rep(_, _, _)) = yes.
-goal_generates_internal_event(negation_rep(_)) = yes.
-goal_generates_internal_event(some_rep(_, _)) = no.
-% Atomic goals may generate interface events, not internal events.
-goal_generates_internal_event(atomic_goal_rep(_, _, _, _, _)) = no.
-
-atomic_goal_identifiable(unify_construct_rep(_, _, _)) = no.
-atomic_goal_identifiable(unify_deconstruct_rep(_, _, _)) = no.
-atomic_goal_identifiable(unify_assign_rep(_, _)) = no.
-atomic_goal_identifiable(unify_simple_test_rep(_, _)) = no.
-atomic_goal_identifiable(unsafe_cast_rep(_, _)) = no.
-atomic_goal_identifiable(pragma_foreign_code_rep(_)) = no.
-atomic_goal_identifiable(higher_order_call_rep(_, _)) = no.
-atomic_goal_identifiable(method_call_rep(_, _, _)) = no.
-atomic_goal_identifiable(builtin_call_rep(Module, Name, Args)) = 
-	yes(atomic_goal_id(Module, Name, length(Args))).
-atomic_goal_identifiable(plain_call_rep(Module, Name, Args)) = 
-	yes(atomic_goal_id(Module, Name, length(Args))).
-
-:- pragma export(proc_rep_type = out, "ML_proc_rep_type").
-
-proc_rep_type = type_of(_ `with_type` proc_rep).
-
-:- pragma export(goal_rep_type = out, "ML_goal_rep_type").
-
-goal_rep_type = type_of(_ `with_type` goal_rep).
-
-%-----------------------------------------------------------------------------%
-
-path_from_string_det(GoalPathStr, GoalPath) :-
-	( path_from_string(GoalPathStr, GoalPathPrime) ->
-		GoalPath = GoalPathPrime
-	;
-		error("path_from_string_det: path_from_string failed")
-	).
-
-path_from_string(GoalPathStr, GoalPath) :-
-	StepStrs = string__words(is_path_separator, GoalPathStr),
-	list__map(path_step_from_string, StepStrs, GoalPath).
-
-path_step_from_string(String, Step) :-
-	string__first_char(String, First, Rest),
-	path_step_from_string_2(First, Rest, Step).
-
-:- pred path_step_from_string_2(char, string, goal_path_step).
-:- mode path_step_from_string_2(in, in, out) is semidet.
-
-path_step_from_string_2('c', NStr, conj(N)) :-
-	string__to_int(NStr, N).
-path_step_from_string_2('d', NStr, disj(N)) :-
-	string__to_int(NStr, N).
-path_step_from_string_2('s', NStr, switch(N)) :-
-	string__to_int(NStr, N).
-path_step_from_string_2('?', "", ite_cond).
-path_step_from_string_2('t', "", ite_then).
-path_step_from_string_2('e', "", ite_else).
-path_step_from_string_2('~', "", neg).
-path_step_from_string_2('q', "!", exist(cut)).
-path_step_from_string_2('q', "", exist(no_cut)).
-path_step_from_string_2('f', "", first).
-path_step_from_string_2('l', "", later).
-
-is_path_separator(';').
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
Index: browser/trace_counts.m
===================================================================
RCS file: browser/trace_counts.m
diff -N browser/trace_counts.m
--- browser/trace_counts.m	24 Jan 2005 07:41:05 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,218 +0,0 @@
-%-----------------------------------------------------------------------------%
-% Copyright (C) 2005 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.
-%-----------------------------------------------------------------------------%
-%
-% File: trace_counts.m.
-%
-% Author: wangp.
-%
-% This module defines a predicate to read in the execution trace summaries
-% generated by programs compiled using the compiler's tracing options.
-
-%-----------------------------------------------------------------------------%
-
-:- module mdbcomp.trace_counts.
-
-:- interface.
-
-:- import_module mdbcomp.prim_data.
-:- import_module mdbcomp.program_representation.
-
-:- import_module io, map.
-
-:- type trace_counts		== map(proc_label, proc_trace_counts).
-
-:- type proc_trace_counts	== map(path_port, int).
-
-:- type path_port
-	--->	port_only(trace_port)
-	;	path_only(goal_path)
-	;	port_and_path(trace_port, goal_path).
-
-:- type read_trace_counts_result
-	--->	ok(trace_counts)
-	;	error_message(string)
-	;	io_error(io__error).
-
-:- pred read_trace_counts(string::in, read_trace_counts_result::out,
-	io::di, io::uo) is det.
-
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-
-:- import_module char, exception, int, io, lexer, list, require, std_util.
-:- import_module string, svmap.
-
-read_trace_counts(FileName, ReadResult, !IO) :-
-	io__open_input(FileName, Result, !IO),
-	(
-		Result = ok(FileStream),
-		io__set_input_stream(FileStream, OldInputStream, !IO),
-		promise_only_solution_io(read_trace_counts_2, ReadResult,
-			!IO),
-		io__set_input_stream(OldInputStream, _, !IO),
-		io__close_input(FileStream, !IO)
-	;
-		Result = error(IOError),
-		ReadResult = io_error(IOError)
-	).
-
-:- pred read_trace_counts_2(read_trace_counts_result::out, io::di, io::uo)
-	is cc_multi.
-
-read_trace_counts_2(ReadResult, !IO) :-
-	try_io(read_trace_counts_3(map__init), Result, !IO),
-	(
-		Result = succeeded(TraceCounts),
-		ReadResult = ok(TraceCounts)
-	;
-		Result = exception(Exception),
-		( Exception = univ(IOError) ->
-			ReadResult = io_error(IOError)
-		; Exception = univ(Message) ->
-			ReadResult = error_message(Message)
-		;
-			error("read_trace_counts_2: unexpected exception type")
-		)
-	;
-		Result = failed,
-		error("read_trace_counts_2: IO failure")
-	).
-
-:- pred read_trace_counts_3(trace_counts::in, trace_counts::out,
-	io::di, io::uo) is det.
-
-read_trace_counts_3(!TraceCounts, !IO) :-
-	io__get_line_number(LineNum, !IO),
-	io__read_line_as_string(Result, !IO),
-	(
-		Result = ok(Line),
-		read_proc_trace_counts(LineNum, Line, !TraceCounts, !IO)
-	;
-		Result = eof
-	;
-		Result = error(Error),
-		throw(Error)
-	).
-
-:- pred read_proc_trace_counts(int::in, string::in, trace_counts::in,
-	trace_counts::out, io::di, io::uo) is det.
-
-read_proc_trace_counts(HeaderLineNum, HeaderLine, !TraceCounts, !IO) :-
-	lexer__string_get_token_list(HeaderLine, string__length(HeaderLine),
-		TokenList, posn(HeaderLineNum, 1, 0), _),
-	(if
-		TokenList =
-			token_cons(name("proc"), _,
-			token_cons(name(PredOrFuncStr), _,
-			token_cons(name(ModuleStr), _,
-			token_cons(name(Name), _,
-			token_cons(integer(Arity), _,
-			token_cons(integer(Mode), _,
-			token_nil)))))),
-		string_to_pred_or_func(PredOrFuncStr, PredOrFunc)
-	then
-		string_to_sym_name(ModuleStr, ".", ModuleName),
-		% At the moment runtime/mercury_trace_base.c doesn't
-		% write out data for 'special' procedures.
-		ProcLabel = proc(ModuleName, PredOrFunc, ModuleName, Name,
-				Arity, Mode),
-		% For whatever reason some of the trace counts for a single
-		% procedure or function can be split over multiple spans.
-		% We collate them as if they appeared in a single span.
-		(if svmap__remove(ProcLabel, Probe, !TraceCounts) then
-			ProcData = Probe
-		else
-			ProcData = map__init
-		),
-		read_proc_trace_counts_2(ProcLabel, ProcData, !TraceCounts,
-			!IO)
-	else
-		string__format("parse error on line %d of execution trace",
-			[i(HeaderLineNum)], Message),
-		throw(Message)
-	).
-
-:- pred read_proc_trace_counts_2(proc_label::in, proc_trace_counts::in,
-	trace_counts::in, trace_counts::out, io::di, io::uo) is det.
-
-read_proc_trace_counts_2(ProcLabel, ProcCounts0, !TraceCounts, !IO) :-
-	io__get_line_number(LineNum, !IO),
-	io__read_line_as_string(Result, !IO),
-	(
-		Result = ok(Line),
-		(if parse_path_port_line(Line, PathPort, Count) then
-			map__det_insert(ProcCounts0, PathPort, Count,
-				ProcCounts),
-			read_proc_trace_counts_2(ProcLabel, ProcCounts,
-				!TraceCounts, !IO)
-		else
-			svmap__det_insert(ProcLabel, ProcCounts0,
-				!TraceCounts),
-			read_proc_trace_counts(LineNum, Line,
-				!TraceCounts, !IO)
-		)
-	;
-		Result = eof,
-		svmap__det_insert(ProcLabel, ProcCounts0, !TraceCounts)
-	;
-		Result = error(Error),
-		throw(Error)
-	).
-
-:- pred parse_path_port_line(string::in, path_port::out, int::out) is semidet.
-
-parse_path_port_line(Line, PathPort, Count) :-
-	Words = string__words(Line),
-	(
-		Words = [Word1, CountStr],
-		( Port = string_to_trace_port(Word1) ->
-			PathPort = port_only(Port)
-		; Path = string_to_goal_path(Word1) ->
-			PathPort = path_only(Path)
-		;
-			fail
-		),
-		string__to_int(CountStr, Count)
-	;
-		Words = [PortStr, PathStr, CountStr],
-		Port = string_to_trace_port(PortStr),
-		Path = string_to_goal_path(PathStr),
-		PathPort = port_and_path(Port, Path),
-		string__to_int(CountStr, Count)
-	).
-
-:- pred string_to_pred_or_func(string::in, pred_or_func::out) is semidet.
-
-string_to_pred_or_func("p", predicate).
-string_to_pred_or_func("f", function).
-
-:- func string_to_trace_port(string) = trace_port is semidet.
-
-string_to_trace_port("CALL") = call.
-string_to_trace_port("EXIT") = exit.
-string_to_trace_port("REDO") = redo.
-string_to_trace_port("FAIL") = fail.
-string_to_trace_port("EXCP") = exception.
-string_to_trace_port("COND") = ite_cond.
-string_to_trace_port("THEN") = ite_then.
-string_to_trace_port("ELSE") = ite_else.
-string_to_trace_port("NEGE") = neg_enter.
-string_to_trace_port("NEGS") = neg_success.
-string_to_trace_port("NEGF") = neg_failure.
-string_to_trace_port("DISJ") = disj.
-string_to_trace_port("SWTC") = switch.
-string_to_trace_port("FRST") = nondet_pragma_first.
-string_to_trace_port("LATR") = nondet_pragma_later.
-
-:- func string_to_goal_path(string) = goal_path is semidet.
-
-string_to_goal_path(String) = Path :-
-	string__prefix(String, "<"),
-	string__suffix(String, ">"),
-	string__length(String, Length),
-	string__substring(String, 1, Length-2, SubString),
-	path_from_string(SubString, Path).
cvs diff: Diffing bytecode
Index: bytecode/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/bytecode/Mmakefile,v
retrieving revision 1.19
diff -u -b -r1.19 Mmakefile
--- bytecode/Mmakefile	24 Sep 2002 06:55:08 -0000	1.19
+++ bytecode/Mmakefile	25 Jan 2005 04:03:35 -0000
@@ -57,6 +57,7 @@
 CHECK_OBJS  = $(MB_OBJS)
 ALLOW_LIB_PREFIX=no
 ALLOW_BROWSER_PREFIX=no
+ALLOW_MDBCOMP_PREFIX=no
 
 MERCURY_DIR=..
 include $(MERCURY_DIR)/Mmake.common
@@ -72,7 +73,8 @@
 		$(RUNTIME_DIR)/machdeps/*.c $(RUNTIME_DIR)/machdeps/*.h\
 		$(LIBRARY_DIR)/*.m \
 		$(TRACE_DIR)/*.h $(TRACE_DIR)/*.c \
-		$(BROWSER_DIR)/*.h $(BROWSER_DIR)/*.c \
+		$(BROWSER_DIR)/*.m \
+		$(MDBCOMP_DIR)/*.m \
 		$(BOEHM_GC_DIR)/*.h $(BOEHM_GC_DIR)/include/*.h
 
 MERCURY_INC	= \
cvs diff: Diffing compiler
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.79
diff -u -b -r1.79 Mmakefile
--- compiler/Mmakefile	14 Jan 2005 05:53:26 -0000	1.79
+++ compiler/Mmakefile	26 Jan 2005 07:03:58 -0000
@@ -22,7 +22,7 @@
 
 MERCURY_MAIN_MODULES = top_level mlds_to_gcc
 
-VPATH=$(LIBRARY_DIR) $(BROWSER_DIR) $(ANALYSIS_DIR)
+VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR) $(BROWSER_DIR) $(ANALYSIS_DIR)
 
 #-----------------------------------------------------------------------------#
 
@@ -47,7 +47,7 @@
 $(GCC_MAIN_LIBS): force
 	cd $(GCC_SRC_DIR)/gcc && $(MAKE) mercury_gcc_backend_libs
 
-MCFLAGS +=	-I $(BROWSER_DIR) -I $(ANALYSIS_DIR) \
+MCFLAGS +=	-I $(BROWSER_DIR) -I $(MDBCOMP_DIR) -I $(ANALYSIS_DIR) \
 			--c-include-directory $(ANALYSIS_DIR)
 CFLAGS +=	-I$(ANALYSIS_DIR) -I$(ANALYSIS_DIR)/$(mihs_subdir)
 MLOBJS :=	../main.$O ../analysis/lib$(ANALYSIS_LIB_NAME).$A $(MLOBJS)
@@ -249,7 +249,7 @@
 $(MC_PROG): ../main.$O
 $(MC_PROG): $(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A
 $(MC_PROG): $(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A
-$(MC_PROG): $(BROWSER_DIR)/lib$(MDBCOMP_LIB_NAME).$A
+$(MC_PROG): $(MDBCOMP_DIR)/lib$(MDBCOMP_LIB_NAME).$A
 $(MC_PROG): $(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A
 $(MC_PROG): $(TRACE_DIR)/lib$(TRACE_LIB_NAME).$A
 $(MC_PROG): $(ANALYSIS_DIR)/lib$(ANALYSIS_LIB_NAME).$A
@@ -271,7 +271,7 @@
 #-----------------------------------------------------------------------------#
 
 tags:	$(PREPROCESSED_M_FILES) *.m $(LIBRARY_DIR)/*.m
-	$(MTAGS) $(MTAGSFLAGS) *.m $(LIBRARY_DIR)/*.m
+	$(MTAGS) $(MTAGSFLAGS) *.m $(LIBRARY_DIR)/*.m $(LIBRARY_DIR)/*.m
 
 .PHONY: tags_file_exists
 tags_file_exists:
@@ -292,7 +292,7 @@
 
 # Note that the cs and os targets don't build top_level_init.{c,o}
 .PHONY: os cs ss ils
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 os: $($(MC_PROG).os)
 cs: $($(MC_PROG).cs)
 ss: $($(MC_PROG).ss)
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.122
diff -u -b -r1.122 hlds_goal.m
--- compiler/hlds_goal.m	19 Jan 2005 03:10:35 -0000	1.122
+++ compiler/hlds_goal.m	24 Jan 2005 10:47:32 -0000
@@ -879,7 +879,7 @@
 	% of the list.)
 	%
 	% If any of the following three types is changed, then the
-	% corresponding types in browser/program_representation.m must be
+	% corresponding types in mdbcomp/program_representation.m must be
 	% updated.
 
 :- type goal_path == list(goal_path_step).
@@ -1614,7 +1614,7 @@
 	goal_path_steps_to_strings(Steps, StepStrs).
 
 	% The inverse of this procedure is implemented in
-	% browser/program_representation.m, and must be updated if this
+	% mdbcomp/program_representation.m, and must be updated if this
 	% is changed.
 
 :- pred goal_path_step_to_string(goal_path_step::in, string::out) is det.
Index: compiler/prog_rep.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_rep.m,v
retrieving revision 1.29
diff -u -b -r1.29 prog_rep.m
--- compiler/prog_rep.m	19 Jan 2005 03:10:53 -0000	1.29
+++ compiler/prog_rep.m	24 Jan 2005 10:47:46 -0000
@@ -8,7 +8,7 @@
 % debugger. Since this representation is to be included in debuggable
 % executables, it should be as compact as possible, and therefore contains
 % only the information required by the declarative debugger. The structure
-% of this representation is defined by browser/program_representation.m.
+% of this representation is defined by mdbcomp/program_representation.m.
 %
 % Author: zs.
 %
cvs diff: Diffing compiler/notes
Index: compiler/notes/overall_design.html
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/notes/overall_design.html,v
retrieving revision 1.3
diff -u -b -r1.3 overall_design.html
--- compiler/notes/overall_design.html	30 Oct 2003 04:24:52 -0000	1.3
+++ compiler/notes/overall_design.html	19 Jan 2005 06:30:01 -0000
@@ -48,9 +48,9 @@
 <li> library: the Mercury standard library (written in Mercury)
 <li> compiler: the Mercury compiler (written in Mercury)
 <li> trace: the part of the Mercury debugger that is written in C
-<li> browser: the part of the Mercury debugger that is written in Mercury,
-     including the library that defines the Mercury data structures generated
-     by the compiler for the debugger.
+<li> browser: the part of the Mercury debugger that is written in Mercury
+<li> mdbcomp: the library that defines the Mercury data structures generated
+     by the compiler for the debugger
 <li> profiler: the Mercury profiler (written in Mercury)
 <li> analysis: an inter-module analysis framework (written in Mercury)
 <li> extras: additional Mercury libraries.  These are distributed
@@ -127,8 +127,7 @@
 <h2> Libraries and dependencies </h2>
 
 Each major subsystem (which doesn't include `extras')
-gets compiled to a single library or executable program,
-except for the browser directory, which gets compiled to two libraries.
+gets compiled to a single library or executable program.
 
 On most systems, mutual recursion between libraries is not very
 well supported.  On Unix, for static linking you need to list the
@@ -150,7 +149,7 @@
 <li>    the main program object files (e.g. compiler/*.o or profiler/*.o)
 <li>    trace library (trace/libmer_trace.a)
 <li>    browser library (browser/libmer_browser.a)
-<li>    mdbcomp library (browser/libmer_mdbcomp.a)
+<li>    mdbcomp library (mdbcomp/libmer_mdbcomp.a)
 <li>    standard library (library/libmer_std.a)
 <li>    runtime library (runtime/libmer_rt.a)
 <li>    Boehm collector (boehm_gc/libgc.a)
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
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/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/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/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
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.138
diff -u -b -r1.138 Mmakefile
--- library/Mmakefile	14 Jan 2005 05:53:32 -0000	1.138
+++ library/Mmakefile	26 Jan 2005 15:23:18 -0000
@@ -22,6 +22,7 @@
 CHECK_OBJS  = $(mer_std.os)
 ALLOW_LIB_PREFIX=yes
 ALLOW_BROWSER_PREFIX=no
+ALLOW_MDBCOMP_PREFIX=no
 
 MERCURY_DIR=..
 LINK_RUNTIME_ONLY=yes
@@ -219,7 +220,7 @@
 # So don't remove the pic_ss target here.
 
 .PHONY: os cs ss pic_ss ils 
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 os: $($(STD_LIB_NAME).os)
 cs: $($(STD_LIB_NAME).cs)
 ss: $($(STD_LIB_NAME).ss)
@@ -363,12 +364,12 @@
 # making tree234.$O first improves effective parallelism with parallel makes.
 # `mmc --make' does not support parallel makes, so this dependency just
 # slows things down.
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 lib_std: $(os_subdir)tree234.$O
 endif
 lib_std: lib$(STD_LIB_NAME)
 
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 
 EXTRA_INIT_COMMAND = ./print_extra_inits $($(STD_LIB_NAME).ms)
 
@@ -376,9 +377,10 @@
 
 MCFLAGS += --extra-init-command ./print_extra_inits
 
-endif	# 
+endif
 
 endif	# GRADE != il && GRADE != java
+
 #-----------------------------------------------------------------------------#
 
 # Rebuild all the object files if the configuration macros or VERSION
@@ -481,9 +483,10 @@
 	rm -f $(INSTALL_MODULE_DIR)/library.init \
 		$(INSTALL_MODULE_DIR)/libmercury.init
 
-
 ifneq (,$(findstring il,$(GRADE)))
 
+# some modules of in the browser directory need library.int3
+
 .PHONY: install_library
 install_library: mercury.dll install_grade_dirs install_gac \
 		install_strong_name lib$(STD_LIB_NAME).install_grade_hdrs \
@@ -538,7 +541,7 @@
 else
 
 .PHONY: install_library
-install_library: lib$(STD_LIB_NAME).install_library
+install_library: lib$(STD_LIB_NAME) lib$(STD_LIB_NAME).install_library
 
 endif  #ifneq (,$(findstring java,$(GRADE)))
 
cvs diff: Diffing mdbcomp
Index: mdbcomp/mdbcomp.m
===================================================================
RCS file: mdbcomp/mdbcomp.m
diff -N mdbcomp/mdbcomp.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mdbcomp/mdbcomp.m	19 Jan 2005 04:20:25 -0000
@@ -0,0 +1,47 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 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.
+%---------------------------------------------------------------------------%
+%
+% This is the top module of a library that contains information shared
+% between the debugger and the compiler. This means mostly the definitions
+% of data structures that the compiler generates for the debugger, and
+% the predicates that operate on them.
+%
+% The compiler links in this library in all grades, but links in the mdb
+% library (which also in this directory) only when debugging is enabled.
+% Therefore the modules of the mdbcomp library should avoid importing any
+% module of the mdb library.
+
+:- module mdbcomp.
+
+:- interface.
+
+:- pred mdbcomp__version(string::out) is det.
+
+:- include_module prim_data.
+:- include_module program_representation.
+:- include_module trace_counts.
+
+:- implementation.
+
+% See library/library.m for why we implement this predicate this way.
+
+:- pragma foreign_proc("C",
+	mdbcomp__version(Version::out),
+	[will_not_call_mercury, promise_pure, thread_safe],
+"
+	MR_ConstString version_string;
+
+	version_string = MR_VERSION "", configured for "" MR_FULLARCH;
+	/*
+	** Cast away const needed here, because Mercury declares Version
+	** with type MR_String rather than MR_ConstString.
+	*/
+	Version = (MR_String) (MR_Word) version_string;
+").
+
+mdbcomp__version("unknown version").
+
+%---------------------------------------------------------------------------%
Index: mdbcomp/mer_mdbcomp.m
===================================================================
RCS file: mdbcomp/mer_mdbcomp.m
diff -N mdbcomp/mer_mdbcomp.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mdbcomp/mer_mdbcomp.m	27 Oct 2003 06:00:32 -0000
@@ -0,0 +1,16 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2003 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.
+%-----------------------------------------------------------------------------%
+% File: mer_mdbcomp.m
+%
+% This file is only present so that the mdbcomp library is
+% generated with the correct name.
+%-----------------------------------------------------------------------------%
+
+:- module mer_mdbcomp.
+
+:- implementation.
+
+:- import_module mdbcomp.
Index: mdbcomp/prim_data.m
===================================================================
RCS file: mdbcomp/prim_data.m
diff -N mdbcomp/prim_data.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mdbcomp/prim_data.m	25 Jan 2005 02:49:02 -0000
@@ -0,0 +1,152 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2005 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.
+%-----------------------------------------------------------------------------%
+%
+% File: prim_data.m.
+% Main authors: fjh, zs.
+%
+% This module contains some types and predicates that are, or are planned to 
+% be, shared between the compiler and the debugger.
+
+%-----------------------------------------------------------------------------%
+
+:- module mdbcomp.prim_data.
+
+:- interface.
+
+% was in browser/util.m and compiler/prog_data.m
+
+	% This enumeration must be EXACTLY the same as the MR_PredFunc enum
+	% in runtime/mercury_stack_layout.h, and in the same order, since the
+	% code (in browser) assumes the representation is the same.
+
+:- type pred_or_func
+	--->	predicate
+	;	function.
+
+% was in browser/util.m and compiler/trace_params.m
+
+	% The kinds of events with which MR_trace may be called, either
+	% by compiler-generated code, or by code in the standard library
+	% referring to compiler-generated data structures.
+	%
+	% This enumeration must be EXACTLY the same as the MR_trace_port enum
+	% in runtime/mercury_trace_base.h, and in the same order, since the
+	% code (in browser) assumes the representation is the same.
+
+:- type trace_port
+	--->	call
+	;	exit
+	;	redo
+	;	fail
+	;	exception
+	;	ite_cond
+	;	ite_then
+	;	ite_else
+	;	neg_enter
+	;	neg_success
+	;	neg_failure
+	;	disj
+	;	switch
+	;	nondet_pragma_first
+	;	nondet_pragma_later
+	.
+
+% was in compiler/prog_data.m
+
+	% The order that the sym_name function symbols appear in is
+	% significant for module dependency ordering.
+
+:- type sym_name
+	--->	unqualified(string)
+	;	qualified(sym_name, string).
+
+:- type module_name == sym_name.
+
+% was in compiler/proc_label.m
+
+	% A proc_label is a data structure a backend can use to as the basis
+	% of the label used as the entry point of a procedure.
+	%
+	% The defining module is the module that provides the code for the
+	% predicate, the declaring module contains the `:- pred' declaration.
+	% When these are different, as for specialised versions of predicates
+	% from `.opt' files, the defining module's name may need to be added
+	% as a qualifier to the label.
+
+:- type proc_label
+	--->	proc(
+			module_name,	% defining module
+			pred_or_func,
+			module_name,	% declaring module
+			string,		% name
+			int,		% arity
+			int		% mode number
+		)
+	;	special_proc(
+			module_name,	% defining module
+			special_pred_id,% indirectly defines pred name
+			module_name,	% type module
+			string,		% type name
+			int,		% type arity
+			int		% mode number
+		).
+
+% was in compiler/special_pred.m
+
+:- type special_pred_id
+	--->	unify
+	;	index
+	;	compare
+	;	initialise.
+
+% was in compiler/prog_util.m
+
+	% string_to_sym_name(String, Separator, SymName):
+	%	Convert a string, possibly prefixed with
+	%	module qualifiers (separated by Separator),
+	%	into a symbol name.
+	%
+:- pred string_to_sym_name(string::in, string::in, sym_name::out) is det.
+
+	% insert_module_qualifier(ModuleName, SymName0, SymName):
+	%	prepend the specified ModuleName onto the module
+	%	qualifiers in SymName0, giving SymName.
+:- pred insert_module_qualifier(string::in, sym_name::in, sym_name::out)
+	is det.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int, string. 
+
+% This would be simpler if we had a string__rev_sub_string_search/3 pred.
+% With that, we could search for underscores right-to-left,
+% and construct the resulting symbol directly.
+% Instead, we search for them left-to-right, and then call
+% insert_module_qualifier to fix things up.
+
+string_to_sym_name(String, ModuleSeparator, Result) :-
+	(
+		string__sub_string_search(String, ModuleSeparator, LeftLength),
+		LeftLength > 0
+	->
+		string__left(String, LeftLength, ModuleName),
+		string__length(String, StringLength),
+		string__length(ModuleSeparator, SeparatorLength),
+		RightLength = StringLength - LeftLength - SeparatorLength,
+		string__right(String, RightLength, Name),
+		string_to_sym_name(Name, ModuleSeparator, NameSym),
+		insert_module_qualifier(ModuleName, NameSym, Result)
+	;
+		Result = unqualified(String)
+	).
+
+insert_module_qualifier(ModuleName, unqualified(PlainName),
+		qualified(unqualified(ModuleName), PlainName)).
+insert_module_qualifier(ModuleName, qualified(ModuleQual0, PlainName),
+		qualified(ModuleQual, PlainName)) :-
+	insert_module_qualifier(ModuleName, ModuleQual0, ModuleQual).
Index: mdbcomp/program_representation.m
===================================================================
RCS file: mdbcomp/program_representation.m
diff -N mdbcomp/program_representation.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mdbcomp/program_representation.m	25 Jan 2005 02:49:02 -0000
@@ -0,0 +1,347 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2001-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.
+%-----------------------------------------------------------------------------%
+%
+% File: program_representation.m
+% Authors: zs, dougl
+%
+% This module defines the representation of procedure bodies
+% used by the declarative debugger.
+%
+% One of the things we want the declarative debugger to be able to do
+% is to let the user specify which part of which output argument of an
+% incorrect or inadmissible atom is suspicious, and then find out where
+% that particular subterm came from, i.e. where it was bound. Doing this
+% requires knowing what the bodies of that procedure and its descendants are.
+%
+% If the Mercury compiler is invoked with options requesting declarative
+% debugging, it will include in each procedure layout a pointer to a simplified
+% representation of the goal that is the body of the corresponding procedure.
+% We use a simplified representation partly because we want to insulate the
+% code of the declarative debugger from irrelevant changes in HLDS types,
+% and partly because we want to minimize the space taken in up in executables
+% by these representations.
+%
+% The current representation is intended to contain all the information
+% we are pretty sure can be usefully exploited by the declarative debugger.
+
+%-----------------------------------------------------------------------------%
+
+:- module mdbcomp.program_representation.
+
+:- interface.
+
+:- import_module char, list, std_util, bool.
+
+	% A representation of the goal we execute.  These need to be
+	% generated statically and stored inside the executable.
+	%
+	% Each element of this structure will correspond one-to-one
+	% to the original stage 90 HLDS.
+
+:- type proc_rep
+	--->	proc_rep(
+			list(var_rep),		% The head variables, in order,
+						% including the ones introduced
+						% by the compiler.
+			goal_rep		% The procedure body.
+		).
+
+:- type goal_rep
+	--->	conj_rep(
+			list(goal_rep)		% The conjuncts in the original
+						% order.
+		)
+	;	disj_rep(
+			list(goal_rep)		% The disjuncts in the original
+						% order.
+		)
+	;	switch_rep(
+			list(goal_rep)		% The switch arms in the
+						% original order.
+		)
+	;	ite_rep(
+			goal_rep,		% Condition.
+			goal_rep,		% Then branch.
+			goal_rep		% Else branch.
+		)
+	;	negation_rep(
+			goal_rep		% The negated goal.
+		)
+	;	some_rep(
+			goal_rep,		% The quantified goal.
+			maybe_cut
+		)
+	;	atomic_goal_rep(
+			detism_rep,
+			string,			% Filename of context.
+			int,			% Line number of context.
+			list(var_rep),		% The sorted list of the
+						% variables bound by the
+						% atomic goal.
+			atomic_goal_rep
+		).
+
+:- type atomic_goal_rep
+	--->	unify_construct_rep(
+			var_rep,
+			cons_id_rep,
+			list(var_rep)
+		)
+	;	unify_deconstruct_rep(
+			var_rep,
+			cons_id_rep,
+			list(var_rep)
+		)
+	;	unify_assign_rep(
+			var_rep,		% target
+			var_rep			% source
+		)
+	;	unsafe_cast_rep(
+			var_rep,		% target
+			var_rep			% source
+		)
+	;	unify_simple_test_rep(
+			var_rep,
+			var_rep
+		)
+	;	pragma_foreign_code_rep(
+			list(var_rep)		% arguments
+		)
+	;	higher_order_call_rep(
+			var_rep,		% the closure to call
+			list(var_rep)		% the call's plain arguments
+		)
+	;	method_call_rep(
+			var_rep,		% typeclass info var
+			int,			% method number
+			list(var_rep)		% the call's plain arguments
+		)
+	;	plain_call_rep(
+			string,			% name of called pred's module
+			string,			% name of the called pred
+			list(var_rep)		% the call's arguments
+		)
+	;	builtin_call_rep(
+			string,			% name of called pred's module
+			string,			% name of the called pred
+			list(var_rep)		% the call's arguments
+		).
+
+:- type var_rep	==	int.
+
+:- type cons_id_rep ==	string.
+
+:- type detism_rep	
+	--->	det_rep
+	;	semidet_rep
+	;	nondet_rep
+	;	multidet_rep
+	;	cc_nondet_rep
+	;	cc_multidet_rep
+	;	erroneous_rep
+	;	failure_rep.
+
+	% If the given atomic goal behaves like a call in the sense that it
+	% generates events, then return the list of variables that are passed
+	% as arguments.
+	%
+:- func atomic_goal_generates_event(atomic_goal_rep) = maybe(list(var_rep)).
+
+	% If the given goal generates internal events directly then this
+	% function will return yes and no otherwise. 
+	%
+:- func goal_generates_internal_event(goal_rep) = bool.
+
+	% call_is_primitive(ModuleName, PredName): succeeds iff a call to the
+	% named predicate behaves like a primitive operation, in the sense that
+	% it does not generate events.
+:- pred call_is_primitive(string::in, string::in) is semidet.
+
+	% The atomic goals module, name and arity
+:- type atomic_goal_id 
+	---> atomic_goal_id(string, string, int).
+
+	% Can we find out the atomic goals name, module and arity from
+	% its atomic_goal_rep?  If so return them, otherwise return no.
+:- func atomic_goal_identifiable(atomic_goal_rep) = 
+	maybe(atomic_goal_id).
+
+%-----------------------------------------------------------------------------%
+
+	% The following three types are derived from compiler/hlds_goal.m.
+
+:- type goal_path == list(goal_path_step).
+
+:- type goal_path_step  --->    conj(int)
+                        ;       disj(int)
+                        ;       switch(int)
+                        ;       ite_cond
+                        ;       ite_then
+                        ;       ite_else
+                        ;       neg
+                        ;       exist(maybe_cut)
+                        ;       first
+                        ;       later.
+
+	% Does `some G' have a different determinism from plain `G'?
+:- type maybe_cut       --->    cut ; no_cut.
+
+:- pred path_from_string_det(string, goal_path).
+:- mode path_from_string_det(in, out) is det.
+
+:- pred path_from_string(string, goal_path).
+:- mode path_from_string(in, out) is semidet.
+
+:- pred path_step_from_string(string, goal_path_step).
+:- mode path_step_from_string(in, out) is semidet.
+
+:- pred is_path_separator(char).
+:- mode is_path_separator(in) is semidet.
+
+	% User-visible head variables are represented by a number from 1..N,
+	% where N is the user-visible arity.
+	%
+	% Both user-visible and compiler-generated head variables can be
+	% referred to via their position in the full list of head variables;
+	% the first head variable is at position 1.
+	
+:- type arg_pos
+	--->	user_head_var(int)	% Nth in the list of arguments after
+					% filtering out non-user-visible vars.
+	;	any_head_var(int)	% Nth in the list of all arguments.
+			
+			% (M-N+1)th argument in the list of all arguments,
+			% where N is the value of the int in the constructor
+			% and M is the total number of arguments.
+	;	any_head_var_from_back(int).
+
+	% A particular subterm within a term is represented by a term_path.
+	% This is the list of argument positions that need to be followed
+	% in order to travel from the root to the subterm.  In contrast to
+	% goal_paths, this list is in top-down order.
+
+:- type term_path ==	list(int).
+
+	% Returns type_of(_ `with_type` proc_rep), for use in C code.
+:- func proc_rep_type = type_desc.
+
+	% Returns type_of(_ `with_type` goal_rep), for use in C code.
+:- func goal_rep_type = type_desc.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+:- import_module string, char, require.
+
+atomic_goal_generates_event(unify_construct_rep(_, _, _)) = no.
+atomic_goal_generates_event(unify_deconstruct_rep(_, _, _)) = no.
+atomic_goal_generates_event(unify_assign_rep(_, _)) = no.
+atomic_goal_generates_event(unify_simple_test_rep(_, _)) = no.
+atomic_goal_generates_event(unsafe_cast_rep(_, _)) = no.
+atomic_goal_generates_event(pragma_foreign_code_rep(_)) = no.
+atomic_goal_generates_event(higher_order_call_rep(_, Args)) = yes(Args).
+atomic_goal_generates_event(method_call_rep(_, _, Args)) = yes(Args).
+atomic_goal_generates_event(builtin_call_rep(_, _, _)) = no.
+atomic_goal_generates_event(plain_call_rep(ModuleName, PredName, Args)) =
+	( call_is_primitive(ModuleName, PredName) ->
+		% These calls behave as primitives and do not generate events.
+		no
+	;
+		yes(Args)
+	).
+
+call_is_primitive(ModuleName, PredName) :-
+	(
+		ModuleName = "builtin",
+		( PredName = "unify"
+		; PredName = "compare"
+		)
+	;
+		ModuleName = "profiling_builtin"
+	;
+		ModuleName = "term_size_prof_builtin"
+	;
+	%
+	% The following are also treated as primitive since
+	% compiler generated predicate events are not 
+	% included in the annotated trace at the moment.
+	%
+		PredName = "__Unify__"
+	;
+		PredName = "__Index__"
+	;
+		PredName = "__Compare__"
+	).
+
+goal_generates_internal_event(conj_rep(_)) = no.
+goal_generates_internal_event(disj_rep(_)) = yes.
+goal_generates_internal_event(switch_rep(_)) = yes.
+goal_generates_internal_event(ite_rep(_, _, _)) = yes.
+goal_generates_internal_event(negation_rep(_)) = yes.
+goal_generates_internal_event(some_rep(_, _)) = no.
+% Atomic goals may generate interface events, not internal events.
+goal_generates_internal_event(atomic_goal_rep(_, _, _, _, _)) = no.
+
+atomic_goal_identifiable(unify_construct_rep(_, _, _)) = no.
+atomic_goal_identifiable(unify_deconstruct_rep(_, _, _)) = no.
+atomic_goal_identifiable(unify_assign_rep(_, _)) = no.
+atomic_goal_identifiable(unify_simple_test_rep(_, _)) = no.
+atomic_goal_identifiable(unsafe_cast_rep(_, _)) = no.
+atomic_goal_identifiable(pragma_foreign_code_rep(_)) = no.
+atomic_goal_identifiable(higher_order_call_rep(_, _)) = no.
+atomic_goal_identifiable(method_call_rep(_, _, _)) = no.
+atomic_goal_identifiable(builtin_call_rep(Module, Name, Args)) = 
+	yes(atomic_goal_id(Module, Name, length(Args))).
+atomic_goal_identifiable(plain_call_rep(Module, Name, Args)) = 
+	yes(atomic_goal_id(Module, Name, length(Args))).
+
+:- pragma export(proc_rep_type = out, "ML_proc_rep_type").
+
+proc_rep_type = type_of(_ `with_type` proc_rep).
+
+:- pragma export(goal_rep_type = out, "ML_goal_rep_type").
+
+goal_rep_type = type_of(_ `with_type` goal_rep).
+
+%-----------------------------------------------------------------------------%
+
+path_from_string_det(GoalPathStr, GoalPath) :-
+	( path_from_string(GoalPathStr, GoalPathPrime) ->
+		GoalPath = GoalPathPrime
+	;
+		error("path_from_string_det: path_from_string failed")
+	).
+
+path_from_string(GoalPathStr, GoalPath) :-
+	StepStrs = string__words(is_path_separator, GoalPathStr),
+	list__map(path_step_from_string, StepStrs, GoalPath).
+
+path_step_from_string(String, Step) :-
+	string__first_char(String, First, Rest),
+	path_step_from_string_2(First, Rest, Step).
+
+:- pred path_step_from_string_2(char, string, goal_path_step).
+:- mode path_step_from_string_2(in, in, out) is semidet.
+
+path_step_from_string_2('c', NStr, conj(N)) :-
+	string__to_int(NStr, N).
+path_step_from_string_2('d', NStr, disj(N)) :-
+	string__to_int(NStr, N).
+path_step_from_string_2('s', NStr, switch(N)) :-
+	string__to_int(NStr, N).
+path_step_from_string_2('?', "", ite_cond).
+path_step_from_string_2('t', "", ite_then).
+path_step_from_string_2('e', "", ite_else).
+path_step_from_string_2('~', "", neg).
+path_step_from_string_2('q', "!", exist(cut)).
+path_step_from_string_2('q', "", exist(no_cut)).
+path_step_from_string_2('f', "", first).
+path_step_from_string_2('l', "", later).
+
+is_path_separator(';').
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
Index: mdbcomp/trace_counts.m
===================================================================
RCS file: mdbcomp/trace_counts.m
diff -N mdbcomp/trace_counts.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mdbcomp/trace_counts.m	25 Jan 2005 02:49:02 -0000
@@ -0,0 +1,218 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2005 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.
+%-----------------------------------------------------------------------------%
+%
+% File: trace_counts.m.
+%
+% Author: wangp.
+%
+% This module defines a predicate to read in the execution trace summaries
+% generated by programs compiled using the compiler's tracing options.
+
+%-----------------------------------------------------------------------------%
+
+:- module mdbcomp.trace_counts.
+
+:- interface.
+
+:- import_module mdbcomp.prim_data.
+:- import_module mdbcomp.program_representation.
+
+:- import_module io, map.
+
+:- type trace_counts		== map(proc_label, proc_trace_counts).
+
+:- type proc_trace_counts	== map(path_port, int).
+
+:- type path_port
+	--->	port_only(trace_port)
+	;	path_only(goal_path)
+	;	port_and_path(trace_port, goal_path).
+
+:- type read_trace_counts_result
+	--->	ok(trace_counts)
+	;	error_message(string)
+	;	io_error(io__error).
+
+:- pred read_trace_counts(string::in, read_trace_counts_result::out,
+	io::di, io::uo) is det.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module char, exception, int, io, lexer, list, require, std_util.
+:- import_module string, svmap.
+
+read_trace_counts(FileName, ReadResult, !IO) :-
+	io__open_input(FileName, Result, !IO),
+	(
+		Result = ok(FileStream),
+		io__set_input_stream(FileStream, OldInputStream, !IO),
+		promise_only_solution_io(read_trace_counts_2, ReadResult,
+			!IO),
+		io__set_input_stream(OldInputStream, _, !IO),
+		io__close_input(FileStream, !IO)
+	;
+		Result = error(IOError),
+		ReadResult = io_error(IOError)
+	).
+
+:- pred read_trace_counts_2(read_trace_counts_result::out, io::di, io::uo)
+	is cc_multi.
+
+read_trace_counts_2(ReadResult, !IO) :-
+	try_io(read_trace_counts_3(map__init), Result, !IO),
+	(
+		Result = succeeded(TraceCounts),
+		ReadResult = ok(TraceCounts)
+	;
+		Result = exception(Exception),
+		( Exception = univ(IOError) ->
+			ReadResult = io_error(IOError)
+		; Exception = univ(Message) ->
+			ReadResult = error_message(Message)
+		;
+			error("read_trace_counts_2: unexpected exception type")
+		)
+	;
+		Result = failed,
+		error("read_trace_counts_2: IO failure")
+	).
+
+:- pred read_trace_counts_3(trace_counts::in, trace_counts::out,
+	io::di, io::uo) is det.
+
+read_trace_counts_3(!TraceCounts, !IO) :-
+	io__get_line_number(LineNum, !IO),
+	io__read_line_as_string(Result, !IO),
+	(
+		Result = ok(Line),
+		read_proc_trace_counts(LineNum, Line, !TraceCounts, !IO)
+	;
+		Result = eof
+	;
+		Result = error(Error),
+		throw(Error)
+	).
+
+:- pred read_proc_trace_counts(int::in, string::in, trace_counts::in,
+	trace_counts::out, io::di, io::uo) is det.
+
+read_proc_trace_counts(HeaderLineNum, HeaderLine, !TraceCounts, !IO) :-
+	lexer__string_get_token_list(HeaderLine, string__length(HeaderLine),
+		TokenList, posn(HeaderLineNum, 1, 0), _),
+	(if
+		TokenList =
+			token_cons(name("proc"), _,
+			token_cons(name(PredOrFuncStr), _,
+			token_cons(name(ModuleStr), _,
+			token_cons(name(Name), _,
+			token_cons(integer(Arity), _,
+			token_cons(integer(Mode), _,
+			token_nil)))))),
+		string_to_pred_or_func(PredOrFuncStr, PredOrFunc)
+	then
+		string_to_sym_name(ModuleStr, ".", ModuleName),
+		% At the moment runtime/mercury_trace_base.c doesn't
+		% write out data for 'special' procedures.
+		ProcLabel = proc(ModuleName, PredOrFunc, ModuleName, Name,
+				Arity, Mode),
+		% For whatever reason some of the trace counts for a single
+		% procedure or function can be split over multiple spans.
+		% We collate them as if they appeared in a single span.
+		(if svmap__remove(ProcLabel, Probe, !TraceCounts) then
+			ProcData = Probe
+		else
+			ProcData = map__init
+		),
+		read_proc_trace_counts_2(ProcLabel, ProcData, !TraceCounts,
+			!IO)
+	else
+		string__format("parse error on line %d of execution trace",
+			[i(HeaderLineNum)], Message),
+		throw(Message)
+	).
+
+:- pred read_proc_trace_counts_2(proc_label::in, proc_trace_counts::in,
+	trace_counts::in, trace_counts::out, io::di, io::uo) is det.
+
+read_proc_trace_counts_2(ProcLabel, ProcCounts0, !TraceCounts, !IO) :-
+	io__get_line_number(LineNum, !IO),
+	io__read_line_as_string(Result, !IO),
+	(
+		Result = ok(Line),
+		(if parse_path_port_line(Line, PathPort, Count) then
+			map__det_insert(ProcCounts0, PathPort, Count,
+				ProcCounts),
+			read_proc_trace_counts_2(ProcLabel, ProcCounts,
+				!TraceCounts, !IO)
+		else
+			svmap__det_insert(ProcLabel, ProcCounts0,
+				!TraceCounts),
+			read_proc_trace_counts(LineNum, Line,
+				!TraceCounts, !IO)
+		)
+	;
+		Result = eof,
+		svmap__det_insert(ProcLabel, ProcCounts0, !TraceCounts)
+	;
+		Result = error(Error),
+		throw(Error)
+	).
+
+:- pred parse_path_port_line(string::in, path_port::out, int::out) is semidet.
+
+parse_path_port_line(Line, PathPort, Count) :-
+	Words = string__words(Line),
+	(
+		Words = [Word1, CountStr],
+		( Port = string_to_trace_port(Word1) ->
+			PathPort = port_only(Port)
+		; Path = string_to_goal_path(Word1) ->
+			PathPort = path_only(Path)
+		;
+			fail
+		),
+		string__to_int(CountStr, Count)
+	;
+		Words = [PortStr, PathStr, CountStr],
+		Port = string_to_trace_port(PortStr),
+		Path = string_to_goal_path(PathStr),
+		PathPort = port_and_path(Port, Path),
+		string__to_int(CountStr, Count)
+	).
+
+:- pred string_to_pred_or_func(string::in, pred_or_func::out) is semidet.
+
+string_to_pred_or_func("p", predicate).
+string_to_pred_or_func("f", function).
+
+:- func string_to_trace_port(string) = trace_port is semidet.
+
+string_to_trace_port("CALL") = call.
+string_to_trace_port("EXIT") = exit.
+string_to_trace_port("REDO") = redo.
+string_to_trace_port("FAIL") = fail.
+string_to_trace_port("EXCP") = exception.
+string_to_trace_port("COND") = ite_cond.
+string_to_trace_port("THEN") = ite_then.
+string_to_trace_port("ELSE") = ite_else.
+string_to_trace_port("NEGE") = neg_enter.
+string_to_trace_port("NEGS") = neg_success.
+string_to_trace_port("NEGF") = neg_failure.
+string_to_trace_port("DISJ") = disj.
+string_to_trace_port("SWTC") = switch.
+string_to_trace_port("FRST") = nondet_pragma_first.
+string_to_trace_port("LATR") = nondet_pragma_later.
+
+:- func string_to_goal_path(string) = goal_path is semidet.
+
+string_to_goal_path(String) = Path :-
+	string__prefix(String, "<"),
+	string__suffix(String, ">"),
+	string__length(String, Length),
+	string__substring(String, 1, Length-2, SubString),
+	path_from_string(SubString, Path).
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.116
diff -u -b -r1.116 Mmakefile
--- runtime/Mmakefile	14 Jan 2005 05:53:37 -0000	1.116
+++ runtime/Mmakefile	25 Jan 2005 04:04:18 -0000
@@ -195,6 +195,7 @@
 CHECK_OBJS  = $(CFILES:.c=.$O)
 ALLOW_LIB_PREFIX=no
 ALLOW_BROWSER_PREFIX=no
+ALLOW_MDBCOMP_PREFIX=no
 
 MERCURY_DIR=..
 LINK_BOEHM_GC_ONLY=yes
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.142
diff -u -b -r1.142 mercury_wrapper.c
--- runtime/mercury_wrapper.c	10 Jan 2005 05:27:56 -0000	1.142
+++ runtime/mercury_wrapper.c	25 Jan 2005 04:08:48 -0000
@@ -324,6 +324,7 @@
 ** This ensures that there are no cyclic dependencies;
 ** the order is user program -> trace -> browser -> library -> runtime -> gc,
 ** where `->' means "depends on", i.e. "references a symbol of".
+** In the case of the compiler, we insert mdbcomp between browser and library.
 */
 
 void	(*MR_address_of_mercury_init_io)(void);
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
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.146
diff -u -b -r1.146 Mmake.rules
--- scripts/Mmake.rules	20 Feb 2004 01:05:00 -0000	1.146
+++ scripts/Mmake.rules	26 Jan 2005 07:02:46 -0000
@@ -79,7 +79,7 @@
 # I have sent off a bug report to the GNU Make maintainers (19 March 1998).
 #	-fjh.
 
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 
 # beware the code for `%.depend' and `%.dep'/`%.dv' is duplicated
 $(deps_subdir)%.dep $(deps_subdir)%.dv:
@@ -120,7 +120,7 @@
 	-[ -d Mercury/pic_s_dates ] || mkdir Mercury/pic_s_dates
 endif
 
-endif	# MMAKE_USE_MMC_MAKE == no
+endif	# MMAKE_USE_MMC_MAKE != yes
 
 #-----------------------------------------------------------------------------#
 #
@@ -129,7 +129,7 @@
 # duplicated in compiler/modules.m.
 #
 
-ifeq ($(MMAKE_USE_MMC_MAKE), no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 
 $(date0s_subdir)%.date0 : %.m
 	$(MCPI) $(ALL_GRADEFLAGS) $(ALL_MCPIFLAGS) $(*F)
@@ -170,7 +170,7 @@
 $(trans_opts_subdir)%.trans_opt : $(trans_opt_dates_subdir)%.trans_opt_date
 	@:
 
-endif	# MMAKE_USE_MMC_MAKE == no
+endif	# MMAKE_USE_MMC_MAKE != yes
 
 #-----------------------------------------------------------------------------#
 #
@@ -179,7 +179,7 @@
 # duplicated in compiler/modules.m.
 #
 
-ifeq ($(MMAKE_USE_MMC_MAKE), no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 
 ifeq ($(TARGET_ASM),yes)
 
@@ -306,7 +306,7 @@
 	$(MCE) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) $(*F) $(ERR_REDIRECT)
 	@touch $@
 
-endif	# MMAKE_USE_MMC_MAKE == no
+endif	# MMAKE_USE_MMC_MAKE != yes
 
 .m.ugly:
 	$(MC) --convert-to-mercury $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) $(*F)
@@ -342,7 +342,7 @@
 # the user may have some C files of their own which need to be compiled.
 #
 
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 
 ifneq ("$(cs_subdir)","")
 
@@ -365,7 +365,7 @@
 
 endif # $(cs_subdir) != ""
 
-endif # $(MMAKE_USE_MMC_MAKE) == no
+endif # $(MMAKE_USE_MMC_MAKE) != yes
 
 #-----------------------------------------------------------------------------#
 #
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.94
diff -u -b -r1.94 Mmake.vars.in
--- scripts/Mmake.vars.in	30 Jun 2004 07:04:34 -0000	1.94
+++ scripts/Mmake.vars.in	26 Jan 2005 07:06:36 -0000
@@ -16,7 +16,7 @@
 EXTRA_LIB_DIRS		=
 EXTRA_LIBRARIES		=
 
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 EXTRA_INT_DIRS		= $(patsubst %,%/ints,$(EXTRA_LIB_DIRS))
 MERCURY_EXTRA_INT_DIRS	= $(EXTRA_INT_DIRS)
 EXTRA_C_LIB_DIRS	= \
Index: scripts/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/Mmakefile,v
retrieving revision 1.33
diff -u -b -r1.33 Mmakefile
--- scripts/Mmakefile	11 Dec 2004 01:59:51 -0000	1.33
+++ scripts/Mmakefile	26 Jan 2005 01:23:24 -0000
@@ -17,7 +17,7 @@
 SCRIPTS = mmake mmc mdb c2init mgnuc ml mprof mprof_merge_runs \
 	  mtags vpath_find mercury_update_interface \
 	  mkfifo_using_mknod mercury_cleanup_install canonical_grade \
-	  mercury_config mercury.bat
+	  mercury_config mercury.bat prepare_tmp_dir_fixed_part
 DEBUGGER_SCRIPTS = mdbrc xul_tree.xsl
 EMACS_SCRIPTS = gud.el
 
Index: scripts/mercury_cleanup_install
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/mercury_cleanup_install,v
retrieving revision 1.4
diff -u -b -r1.4 mercury_cleanup_install
--- scripts/mercury_cleanup_install	30 May 2002 12:55:23 -0000	1.4
+++ scripts/mercury_cleanup_install	25 Jan 2005 03:58:21 -0000
@@ -32,7 +32,7 @@
 # If there is an error while doing the clean-up, a more aggressive approach
 # is used.  An "mmake clean" is run on the directory in question, and then
 # the `tmp_dir' is deleted completely.  Note that for some directories (e.g.
-# `library' and `browser'), this deletes some C files, which require a
+# `library', `browser'), this deletes some C files, which require a
 # working version of Mercury to rebuild.  However, if the installation got
 # as far as building the different grades of the library, then the compiler
 # (plus its default grade) has already been installed.  The build scripts
Index: scripts/prepare_tmp_dir_fixed_part.in
===================================================================
RCS file: scripts/prepare_tmp_dir_fixed_part.in
diff -N scripts/prepare_tmp_dir_fixed_part.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/prepare_tmp_dir_fixed_part.in	26 Jan 2005 04:01:04 -0000
@@ -0,0 +1,23 @@
+#!/bin/sh
+ln_s="@LN_S@"
+if test "$ln_s" = "false"
+then
+	ln_s="cp -r"
+fi
+wd=`/bin/pwd`
+
+mkdir tmp_dir
+cp Mmake* tmp_dir
+cp Mercury.* tmp_dir
+cp VERSION tmp_dir
+cp config* tmp_dir
+cp aclocal.m4 tmp_dir
+mkdir tmp_dir/scripts
+cp scripts/* tmp_dir/scripts
+mkdir tmp_dir/tools
+cp tools/* tmp_dir/tools
+$ln_s $wd/compiler tmp_dir
+$ln_s $wd/analysis tmp_dir
+$ln_s $wd/robdd tmp_dir
+$ln_s $wd/util tmp_dir
+exit 0
Index: scripts/prepare_tmp_dir_grade_part
===================================================================
RCS file: scripts/prepare_tmp_dir_grade_part
diff -N scripts/prepare_tmp_dir_grade_part
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/prepare_tmp_dir_grade_part	26 Jan 2005 15:14:49 -0000
@@ -0,0 +1,45 @@
+#!/bin/sh
+rm -fr tmp_dir/boehm_gc
+rm -fr tmp_dir/runtime
+rm -fr tmp_dir/trace
+rm -fr tmp_dir/library
+rm -fr tmp_dir/mdbcomp
+rm -fr tmp_dir/browser
+mkdir tmp_dir/boehm_gc
+mkdir tmp_dir/boehm_gc/Mac_files
+mkdir tmp_dir/boehm_gc/cord
+mkdir tmp_dir/boehm_gc/include
+mkdir tmp_dir/boehm_gc/include/private
+cp boehm_gc/Makefile* tmp_dir/boehm_gc
+cp boehm_gc/Mmake* tmp_dir/boehm_gc
+cp boehm_gc/ac* tmp_dir/boehm_gc
+cp boehm_gc/*.[chsS] tmp_dir/boehm_gc
+cp boehm_gc/Mac_files/*.[ch] tmp_dir/boehm_gc/Mac_files
+cp boehm_gc/cord/*.[ch] tmp_dir/boehm_gc/cord
+cp boehm_gc/include/*.[ch] tmp_dir/boehm_gc/include
+cp boehm_gc/include/private/*.[ch] tmp_dir/boehm_gc/include/private
+mkdir tmp_dir/runtime
+mkdir tmp_dir/runtime/machdeps
+cp runtime/Mmake* tmp_dir/runtime
+cp runtime/*.in tmp_dir/runtime
+cp runtime/*.[ch] tmp_dir/runtime
+cp runtime/*.il tmp_dir/runtime
+cp runtime/machdeps/*.h tmp_dir/runtime/machdeps
+mkdir tmp_dir/trace
+cp trace/Mmake* tmp_dir/trace
+cp trace/*.[ch] tmp_dir/trace
+mkdir tmp_dir/library
+cp library/Mmake* tmp_dir/library
+cp library/Mercury.* tmp_dir/library
+cp library/print_extra_inits tmp_dir/library
+cp library/library_strong_name.sn tmp_dir/library
+cp library/*.m tmp_dir/library
+mkdir tmp_dir/mdbcomp
+cp mdbcomp/Mmake* tmp_dir/mdbcomp
+cp mdbcomp/Mercury.* tmp_dir/mdbcomp
+cp mdbcomp/*.m tmp_dir/mdbcomp
+mkdir tmp_dir/browser
+cp browser/Mmake* tmp_dir/browser
+cp browser/Mercury.* tmp_dir/browser
+cp browser/*.m tmp_dir/browser
+exit 0
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
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/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/binary
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/binary,v
retrieving revision 1.24
diff -u -b -r1.24 binary
--- tools/binary	27 Oct 2003 06:00:47 -0000	1.24
+++ tools/binary	25 Jan 2005 03:59:40 -0000
@@ -276,6 +276,7 @@
 fi
 ln -s $root/boehm_gc .
 ln -s $root/browser .
+ln -s $root/mdbcomp .
 ln -s $root/trace .
 ln -s $root/doc .
 ln -s $root/scripts .
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.163
diff -u -b -r1.163 bootcheck
--- tools/bootcheck	15 Dec 2004 06:57:56 -0000	1.163
+++ tools/bootcheck	25 Jan 2005 00:51:47 -0000
@@ -69,7 +69,7 @@
 		check to have left a working stage 2 directory.
 	--no-check-namespace
 		Don't build the check_namespace targets in the runtime,
-		trace, browser and library directories.
+		trace, browser, mdbcomp and library directories.
 	-t-, --no-test-suite
 		By default, bootcheck will also run the test quite.
 		This option prevents that.
@@ -569,12 +569,18 @@
 		$LN_S $root/library/$STD_LIB_NAME.init .
 		$LN_S $root/library/RESERVED_MACRO_NAMES .
 		cd $root/$stage2dir
+		mkdir mdbcomp
+		cd mdbcomp
+		$LN_S $root/mdbcomp/*.m .
+		cp $root/mdbcomp/Mmake* $root/mdbcomp/Mercury.options .
+		$LN_S $root/mdbcomp/$MDCOMP_LIB_NAME.init .
+		$LN_S $root/mdbcomp/RESERVED_MACRO_NAMES .
+		cd $root/$stage2dir
 		mkdir browser
 		cd browser
 		$LN_S $root/browser/*.m .
 		cp $root/browser/Mmake* $root/browser/Mercury.options .
 		$LN_S $root/browser/$BROWSER_LIB_NAME.init .
-		$LN_S $root/browser/$MDCOMP_LIB_NAME.init .
 		$LN_S $root/browser/RESERVED_MACRO_NAMES .
 		cd $root/$stage2dir
 		mkdir analysis
@@ -686,6 +692,11 @@
 			/bin/rm -f Mmake.params
 			cp $root/Mmake.stage.params Mmake.params
 		fi
+		if test -f $root/Mmake.stage.mdbcomp.params
+		then
+			/bin/rm -f mdbcomp/Mmake.mdbcomp.params
+			cp $root/Mmake.stage.mdbcomp.params mdbcomp/Mmake.mdbcomp.params
+		fi
 		if test -f $root/Mmake.stage.browser.params
 		then
 			/bin/rm -f browser/Mmake.browser.params
@@ -743,8 +754,8 @@
 		fi
 
 		if (cd $stage2dir && \
-			$MMAKE $mmake_opts dep_library dep_browser \
-			dep_analysis dep_compiler dep_profiler \
+			$MMAKE $mmake_opts dep_library dep_mdbcomp \
+			dep_browser dep_analysis dep_compiler dep_profiler \
 			dep_deep_profiler)
 		then
 			echo "building of stage 2 dependencies successful"
@@ -777,6 +788,15 @@
 				$stage2dir/library/$STD_LIB_NAME.a
 		fi
 
+		if (cd $stage2dir/mdbcomp && \
+			$MMAKE $mmake_opts $jfactor library)
+		then
+			echo "building of stage 2 mdbcomp successful"
+		else
+			echo "building of stage 2 mdbcomp not successful"
+			exit 1
+		fi
+
 		if (cd $stage2dir/browser && \
 			$MMAKE $mmake_opts $jfactor library)
 		then
@@ -859,6 +879,11 @@
 			echo '** mmake check_namespace failed in library!'
 			check_namespace_status=1
 		}
+		cd $root/$stage2dir/mdbcomp
+		mmake $mmake_opts check_namespace || {
+			echo '** mmake check_namespace failed in mdbcomp!'
+			check_namespace_status=1
+		}
 		cd $root/$stage2dir/browser
 		mmake $mmake_opts check_namespace || {
 			echo '** mmake check_namespace failed in browser!'
@@ -879,7 +904,7 @@
 	then
 		true
 	else
-		libdirs="library browser"
+		libdirs="library mdbcomp browser"
 		if $copy_profiler
 		then
 			profdirs="profiler deep_profiler"
@@ -900,7 +925,7 @@
 			/bin/rm -f *.o *.pic_o
 		done
 
-		for cleandir in runtime trace library browser
+		for cleandir in runtime trace library mdbcomp browser
 		do
 			cd $root/$stage2dir/$cleandir
 			mmake clean_check
@@ -954,12 +979,17 @@
 	cp $root/library/Mmake* $root/library/Mercury.options .
 	$LN_S $root/library/$STD_LIB_NAME.init .
 	cd $root/$stage3dir
+	mkdir mdbcomp
+	cd mdbcomp
+	$LN_S $root/mdbcomp/*.m .
+	cp $root/mdbcomp/Mmake* $root/mdbcomp/Mercury.options .
+	$LN_S $root/mdbcomp/$MDBCOMP_LIB_NAME.init .
+	cd $root/$stage3dir
 	mkdir browser
 	cd browser
 	$LN_S $root/browser/*.m .
 	cp $root/browser/Mmake* $root/browser/Mercury.options .
 	$LN_S $root/browser/$BROWSER_LIB_NAME.init .
-	$LN_S $root/browser/$MDBCOMP_LIB_NAME.init .
 	cd $root/$stage3dir
 	mkdir analysis
 	cd analysis
@@ -1010,8 +1040,8 @@
 		cp /dev/null "$type_stats"
 	fi
 
-	if (cd $stage3dir && $MMAKE $mmake_opts dep_library dep_browser \
-		dep_analysis dep_compiler)
+	if (cd $stage3dir && $MMAKE $mmake_opts dep_library dep_mdbcomp \
+		dep_browser dep_analysis dep_compiler)
 	then
 		echo "building of stage 3 dependencies successful"
 	else
@@ -1053,6 +1083,23 @@
 		xargs /bin/rm -f
 	fi
 
+	if (cd $stage3dir/mdbcomp && $MMAKE $mmake_opts $jfactor ${target_ext}s)
+	then
+		echo "building of stage 3 mdbcomp successful"
+	else
+		echo "building of stage 3 mdbcomp initially not successful"
+		df .
+		# try again, in case the failure cause was transient
+		if (cd $stage3dir/mdbcomp && \
+			$MMAKE $mmake_opts $jfactor ${target_ext}s)
+		then
+			echo "building of stage 3 mdbcomp successful"
+		else
+			echo "building of stage 3 mdbcomp not successful"
+			exit 1
+		fi
+	fi
+
 	if (cd $stage3dir/browser && $MMAKE $mmake_opts $jfactor ${target_ext}s)
 	then
 		echo "building of stage 3 browser successful"
@@ -1123,7 +1170,7 @@
 		exec > "$outfile"	# redirect stdout to $outfile
 	fi
 
-	for dir in library browser analysis compiler; do
+	for dir in library mdbcomp browser analysis compiler; do
 		# `mmake cs' in the compiler directory doesn't build
 		# `top_level_init.c', so we only compare the `.c'
 		# files present in the stage 3 directory.
@@ -1162,6 +1209,7 @@
 				# files to be reconstructed
 				# relatively quickly.
 				gzip $root/$stage2dir/library/*.c
+				gzip $root/$stage2dir/mdbcomp/*.c
 				gzip $root/$stage2dir/browser/*.c
 				gzip $root/$stage2dir/compiler/*.c
 				;;
Index: tools/lmc.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/lmc.in,v
retrieving revision 1.5
diff -u -b -r1.5 lmc.in
--- tools/lmc.in	24 Nov 2004 08:46:29 -0000	1.5
+++ tools/lmc.in	24 Jan 2005 10:45:42 -0000
@@ -89,10 +89,9 @@
 	echo "$WORKSPACE/boehm_gc does not have a gc library"
 fi
 
-LIB_FLAGS="--link-object $WORKSPACE/trace/libmer_trace.$O --link-object
-$WORKSPACE/browser/libmer_browser.$O --link-object $WORKSPACE/browser/libmer_mdbcomp.$O --link-object $WORKSPACE/library/libmer_std.$O --link-object $WORKSPACE/runtime/libmer_rt.$O --link-object $gclib -lm @TRACE_LIBS_SYSTEM@ @READLINE_LIBRARIES@"
+LIB_FLAGS="--link-object $WORKSPACE/trace/libmer_trace.$O --link-object $WORKSPACE/browser/libmer_browser.$O --link-object $WORKSPACE/mdbcomp/libmer_mdbcomp.$O --link-object $WORKSPACE/library/libmer_std.$O --link-object $WORKSPACE/runtime/libmer_rt.$O --link-object $gclib -lm @TRACE_LIBS_SYSTEM@ @READLINE_LIBRARIES@"
 
-INIT_FLAGS="--trace-init-file $WORKSPACE/browser/mer_browser.init --init-file $WORKSPACE/library/mer_std.init --init-file $WORKSPACE/runtime/mer_rt.init"
+INIT_FLAGS="--trace-init-file $WORKSPACE/browser/mer_browser.init --trace-init-file $WORKSPACE/mdbcomp/mer_mdbcomp.init --init-file $WORKSPACE/library/mer_std.init --init-file $WORKSPACE/runtime/mer_rt.init"
 
 LINK_FLAGS=""
 
Index: tools/lml
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/lml,v
retrieving revision 1.2
diff -u -b -r1.2 lml
--- tools/lml	27 Oct 2003 06:00:47 -0000	1.2
+++ tools/lml	25 Jan 2005 03:59:55 -0000
@@ -34,7 +34,7 @@
 	echo "$WORKSPACE/boehm_gc does not have a gc library"
 fi
 
-MERCURY_LIBS="$WORKSPACE/trace/libmer_trace.a $WORKSPACE/browser/libmer_browser.a $WORKSPACE/browser/libmer_mdbcomp.a $WORKSPACE/library/libmer_std.a $WORKSPACE/runtime/libmer_rt.a $gclib -lm"
+MERCURY_LIBS="$WORKSPACE/trace/libmer_trace.a $WORKSPACE/browser/libmer_browser.a $WORKSPACE/mdbcomp/libmer_mdbcomp.a $WORKSPACE/library/libmer_std.a $WORKSPACE/runtime/libmer_rt.a $gclib -lm"
 export MERCURY_LIBS
 
 PATH="$WORKSPACE/scripts:$WORKSPACE/util:$PATH"
Index: tools/make_arena
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/make_arena,v
retrieving revision 1.3
diff -u -b -r1.3 make_arena
--- tools/make_arena	13 Jan 2003 09:30:34 -0000	1.3
+++ tools/make_arena	25 Jan 2005 04:00:38 -0000
@@ -23,7 +23,7 @@
 done
 
 # copy the interface files and possibly optimization files they will need
-for dir in library browser analysis compiler
+for dir in library mdbcomp analysis compiler
 do
 	cp $dir/*.int* arena
 	cp $dir/*.*opt arena > /dev/null 2>&1
cvs diff: Diffing trace
Index: trace/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/Mmakefile,v
retrieving revision 1.41
diff -u -b -r1.41 Mmakefile
--- trace/Mmakefile	14 Jan 2005 05:53:41 -0000	1.41
+++ trace/Mmakefile	24 Jan 2005 08:06:07 -0000
@@ -54,7 +54,7 @@
 OBJS		= $(CFILES:.c=.$O)
 PIC_OBJS	= $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS))
 
-LDFLAGS		= -L$(BROWSER_DIR) -L$(LIBRARY_DIR) \
+LDFLAGS		= -L$(BROWSER_DIR) -L$(MDBCOMP_DIR) -L$(LIBRARY_DIR) \
 			-L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR) -L/usr/local/lib
 LDLIBS		= -l$(BROWSER_LIB_NAME) -l$(MDBCOMP_LIB_NAME) \
 			$(MLLIBS) $(SOCKET_LIBRARY) \
@@ -74,6 +74,7 @@
 CHECK_OBJS  = $(OBJS)
 ALLOW_LIB_PREFIX=no
 ALLOW_BROWSER_PREFIX=no
+ALLOW_MDBCOMP_PREFIX=no
 
 MERCURY_DIR=..
 LINK_STDLIB_ONLY=yes
@@ -85,7 +86,7 @@
 
 #-----------------------------------------------------------------------------#
 
-CFLAGS		+= -I$(BROWSER_DIR) -g $(DLL_CFLAGS) \
+CFLAGS		+= -I$(BROWSER_DIR) -I$(MDBCOMP_DIR) -g $(DLL_CFLAGS) \
 			-DMR_NO_BACKWARDS_COMPAT -DMERCURY_CONF_BOOTSTRAP_H
 MGNUCFLAGS	+= --no-ansi
 
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