for review: introduce the trace and browser directories

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Sep 28 17:09:34 AEST 1998


For Fergus.

The functionality of the debugger is not affected by this change.

Estimated hours taken: 8

Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.

After this change, the linking order becomes:

	program object files, and the object of the auto-generated init file
	trace library (libmer_trace.a)
	browser library (libmer_browser.a)
	standard library (libmer_std.a)
	runtime library (libmer_rt.a)
	Boehm collector (libgc.a)

In case the program does not contain calls to the tracer but the standard
library does, which can happen if the library is compiled with tracing in a
non-debug grade, the above structure allows circularities. To avoid them,
MR_trace, which is in the runtime, calls either a dummy tracer in the runtime
or a real tracer in the trace directory, depending on the value assigned to
a new global variable by the automatically generated init file. This is
controlled by a new option to mkinit/c2init.

Makefile.DLLs:
	Reserve random locations for the two new libraries. Whether they work
	will be decided by testing on Windows.

Mmake.common.in:
	Add variables naming the new directories, and create variables
	naming the libraries.

Mmakefile:
	Add targets for the new directories, and modify existing rules
	as appropriate.

browser/Mmakefile:
	Mmakefile for the new directory, modelled on library/Mmakefile.

browser/browser_library.m:
	Umbrella file for the new directory, modelled on library/library.m.

{browser,library}/debugger_interface.m:
	Moved this file from library to browser without change.

browser/help.m:
	A new module for the help system of the debugger. Not yet used.

compiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

doc/Mmakefile:
	Remove the special treatment of library/debugger_interface.m.

library/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

library/library.m:
	Do not import debugger_interface.

profiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

runtime/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

	Remove references to files being moved to the trace directory.

runtime/mercury_init.h:
	Refer to the automatically generated dll header file by its new name
	(renamed because the runtime library is renamed).

	Add declarations to support the new global variable MR_trace_func_ptr.

runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
	Remove inappropriate #includes of "mercury_trace.h", and substitute
	a #include of "mercury_trace_base.h" if necessary.

{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
	Move these files to from the runtime to the trace directory.

	The only changes are the removal from mercury_trace.h of declarations
	added to runtime/mercury_trace_base.h, and the change from MR_trace
	to MR_trace_real.

runtime/mercury_trace_base.[ch]:
	Define MR_trace(), which does an indirect call through
	MR_trace_func_ptr if the event should be traced.

	Define MR_trace_fake, which just prints an error message.
	Its address will be assigned to MR_trace_func_ptr if tracing
	is not enabled.

	Define the types needed by the signature of MR_trace.

	Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.

runtime/mercury_wrapper.[ch]:
	Add the new global variable MR_trace_func_ptr.

scripts/c2init.in:
	Add a new option, -t/--trace, which enables tracing by causing the
	address of MR_trace_real to be assigned to MR_trace_func_ptr.

	Have this option be implied by the grade. Also have the old option
	-i (need initialization code) be implied by the grade, as well as by 
	-t.

scripts/ml.in:
	Include the new libraries in the link command.

tests/debugger/Mmakefile:
	Include -t instead of -i in the list of c2init options. (-t implies
	-i.)

tools/bootcheck:
	Copy and build the new directories as appropriate. The trace directory
	is treated like the runtime, the browser directory is treated like the
	library.

trace/Mmakefile:
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/mkinit.c:
	Add the new option -t, as discussed above.
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/Mmakefile:
	Specify -O0, since with the default optimization level, gcc on
	cyclone ignores the assignment of TRUE to need_tracing when -t is
	given (!!!).

Zoltan.

cvs diff: Diffing .
Index: Makefile.DLLs
===================================================================
RCS file: /home/mercury1/repository/mercury/Makefile.DLLs,v
retrieving revision 1.2
diff -u -u -r1.2 Makefile.DLLs
--- Makefile.DLLs	1997/09/29 17:22:07	1.2
+++ Makefile.DLLs	1998/09/24 11:55:42
@@ -109,11 +109,13 @@
 
 # Making relocatable DLLs doesn't seem to work.
 # Note quite sure why.  The --image-base values below
-# where chosen at random, they seem to work on my machine.
+# where chosen at random, the first two at least seem to work on my machine.
 RELOCATABLE=no
-LDFLAGS-libgc +=	--image-base=0x2345000
-LDFLAGS-libmer +=	--image-base=0x1234000
-LDFLAGS-libmercury +=	--image-base=0x3456000
+LDFLAGS-libgc +=	  --image-base=0x2345000
+LDFLAGS-libmer_rt +=	  --image-base=0x1234000
+LDFLAGS-libmer_std +=	  --image-base=0x3456000
+LDFLAGS-libmer_trace +=	  --image-base=0x4567000
+LDFLAGS-libmer_browser += --image-base=0x5678000
 
 ifeq "$(strip $(RELOCATABLE))" "yes"
 
Index: Mmake.common.in
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.28
diff -u -u -r1.28 Mmake.common.in
--- Mmake.common.in	1998/08/04 14:05:50	1.28
+++ Mmake.common.in	1998/09/24 11:55:42
@@ -164,9 +164,23 @@
 SCRIPTS_DIR = $(MERCURY_DIR)/scripts
 RUNTIME_DIR = $(MERCURY_DIR)/runtime
 LIBRARY_DIR = $(MERCURY_DIR)/library
+TRACE_DIR = $(MERCURY_DIR)/trace
+BROWSER_DIR = $(MERCURY_DIR)/browser
 BOEHM_GC_DIR = $(MERCURY_DIR)/boehm_gc
 COMPILER_DIR = $(MERCURY_DIR)/compiler
 UTIL_DIR = $(MERCURY_DIR)/util
+
+# The names of the various libraries.
+# The archives and shared object objects have a "lib" prefix and a ".a" or
+# ".so" suffix around these names; the initialization files have just a
+# ".init" suffix.
+#
+# If you change these, you will also need to change script/ml.in
+# and tools/bootcheck.
+RT_LIB_NAME = mer_rt
+STD_LIB_NAME = mer_std
+TRACE_LIB_NAME = mer_trace
+BROWSER_LIB_NAME = mer_browser
 
 # Options to pass to the Mercury compiler
 MCFLAGS	= --no-infer-all --halt-at-warn
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.24
diff -u -u -r1.24 Mmakefile
--- Mmakefile	1998/09/10 03:21:38	1.24
+++ Mmakefile	1998/09/25 07:40:47
@@ -13,7 +13,17 @@
 
 #-----------------------------------------------------------------------------#
 
-SUBDIRS = scripts util boehm_gc runtime library compiler doc profiler
+SUBDIRS = \
+		scripts \
+		util \
+		boehm_gc \
+		runtime \
+		library \
+		trace \
+		browser \
+		compiler \
+		doc \
+		profiler
 
 MMAKEFLAGS =
 
@@ -37,7 +47,7 @@
 # `mmake depend' forces them to be remade to ensure that they are up-to-date.
 
 .PHONY: dep
-dep: dep_library dep_compiler dep_profiler
+dep: dep_library dep_browser dep_compiler dep_profiler
 
 .PHONY: dep_library
 dep_library: library/$(deps_subdir)library.dep
@@ -45,6 +55,12 @@
 library/$(deps_subdir)library.dep:
 	cd library && $(SUBDIR_MMAKE) depend
 
+.PHONY: dep_browser
+dep_browser: browser/$(deps_subdir)browser.dep
+
+browser/$(deps_subdir)browser.dep:
+	cd browser && $(SUBDIR_MMAKE) depend
+
 .PHONY: dep_compiler
 dep_compiler: compiler/$(deps_subdir)mercury_compile.dep
 
@@ -62,6 +78,7 @@
 .PHONY: depend
 depend:
 	cd library && $(SUBDIR_MMAKE) depend
+	cd browser && $(SUBDIR_MMAKE) depend
 	cd compiler && $(SUBDIR_MMAKE) depend
 	cd profiler && $(SUBDIR_MMAKE) depend
 
@@ -69,6 +86,10 @@
 depend_library:
 	cd library && $(SUBDIR_MMAKE) depend
 
+.PHONY: depend_browser
+depend_browser:
+	cd browser && $(SUBDIR_MMAKE) depend
+
 .PHONY: depend_compiler
 depend_compiler:
 	cd compiler && $(SUBDIR_MMAKE) depend
@@ -82,14 +103,14 @@
 .PHONY: all
 all: README INSTALL $(SUBDIRS)
 
+.PHONY: util
+util: scripts
+	cd util && $(SUBDIR_MMAKE)
+
 .PHONY: scripts
 scripts:
 	cd scripts && $(SUBDIR_MMAKE)
 
-.PHONY: runtime
-runtime: scripts boehm_gc
-	cd runtime && $(SUBDIR_MMAKE)
-
 .PHONY: boehm_gc
 boehm_gc: scripts
 	case "$$grade" in \
@@ -102,30 +123,38 @@
 	esac; \
 	cd boehm_gc && $(SUBDIR_MMAKE) PROF=$$prof
 
+.PHONY: runtime
+runtime: scripts boehm_gc
+	cd runtime && $(SUBDIR_MMAKE)
+
 .PHONY: library
-library: dep_library scripts runtime boehm_gc
+library: dep_library scripts util boehm_gc runtime
 	cd library && $(SUBDIR_MMAKE)
 
+.PHONY: browser
+browser: dep_browser scripts util boehm_gc runtime library
+	cd browser && $(SUBDIR_MMAKE)
+
+.PHONY: runtime
+trace: scripts boehm_gc runtime library browser
+	cd trace && $(SUBDIR_MMAKE)
+
 .PHONY: compiler
-compiler: dep_compiler scripts util runtime boehm_gc library
+compiler: dep_compiler scripts util boehm_gc runtime library browser trace
 	cd compiler && $(SUBDIR_MMAKE)
 
 .PHONY: doc
 doc: scripts
 	cd doc && $(SUBDIR_MMAKE)
 
-.PHONY: util
-util: scripts
-	cd util && $(SUBDIR_MMAKE)
-
 .PHONY: profiler
-profiler: dep_profiler scripts util runtime boehm_gc library
+profiler: dep_profiler scripts util boehm_gc runtime library
 	cd profiler && $(SUBDIR_MMAKE)
 
 #-----------------------------------------------------------------------------#
 
 .PHONY: tags
-tags: tags_compiler tags_profiler tags_library
+tags: tags_compiler tags_library tags_browser tags_profiler
 
 .PHONY: tags_compiler
 tags_compiler:
@@ -135,6 +164,10 @@
 tags_library:
 	cd library && $(SUBDIR_MMAKE) tags
 
+.PHONY: tags_browser
+tags_browser:
+	cd browser && $(SUBDIR_MMAKE) tags
+
 .PHONY: tags_profiler
 tags_profiler:
 	cd profiler && $(SUBDIR_MMAKE) tags
@@ -169,9 +202,12 @@
 tar: README INSTALL
 	touch Mmake.params
 	cd util && mmake
-	cd runtime && $(SUBDIR_MMAKE) cs runtime.init
+	cd runtime && $(SUBDIR_MMAKE) cs $(RT_LIB_NAME).init
 	cd library && $(SUBDIR_MMAKE) depend
-	cd library && $(SUBDIR_MMAKE) all-ints cs libmercury.init tags
+	cd library && $(SUBDIR_MMAKE) all-ints cs $(STD_LIB_NAME).init tags
+	cd browser && $(SUBDIR_MMAKE) depend
+	cd browser && $(SUBDIR_MMAKE) all-ints cs $(BROWSER_LIB_NAME).init tags
+	cd trace && $(SUBDIR_MMAKE) cs
 	cd compiler && $(SUBDIR_MMAKE) depend
 	cd compiler && $(SUBDIR_MMAKE) cs tags
 	cd profiler && $(SUBDIR_MMAKE) depend
@@ -228,7 +264,8 @@
 .PHONY: install_main
 install_main: all $(PREINSTALL_HACK) \
 		install_scripts install_util install_runtime install_boehm_gc \
-  		install_library install_compiler install_profiler install_doc \
+  		install_library install_browser install_trace \
+		install_compiler install_profiler install_doc \
 		$(POSTINSTALL_HACK)
  
 .PHONY: install_scripts
@@ -243,6 +280,10 @@
 install_runtime: runtime
 	cd runtime && $(SUBDIR_MMAKE) install
 
+.PHONY: install_trace
+install_trace: trace
+	cd trace && $(SUBDIR_MMAKE) install
+
 .PHONY: install_boehm_gc
 install_boehm_gc: boehm_gc
 	case "$$grade" in \
@@ -259,6 +300,10 @@
 install_library: dep_library library
 	cd library && $(SUBDIR_MMAKE) install
 
+.PHONY: install_browser
+install_browser: dep_browser browser
+	cd browser && $(SUBDIR_MMAKE) install
+
 .PHONY: install_compiler
 install_compiler: dep_compiler compiler
 	cd compiler && $(SUBDIR_MMAKE) install
@@ -272,13 +317,17 @@
 	cd profiler && $(SUBDIR_MMAKE) install
 
 .PHONY: install_grades
-install_grades: scripts dep_library
+install_grades: scripts dep_library dep_browser
 	cd boehm_gc && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.o *.pic_o *.a *.so tmp_dir || true; }
 	cd runtime && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.o *.pic_o *.a *.so tmp_dir || true; }
 	cd library && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.c *.o *.pic_o *.a *.so tmp_dir || true; }
+	cd browser && rm -rf tmp_dir && mkdir tmp_dir && \
+		{ mv -f *.c *.o *.pic_o *.a *.so tmp_dir || true; }
+	cd trace && rm -rf tmp_dir && mkdir tmp_dir && \
+		{ mv -f *.o *.pic_o *.a *.so tmp_dir || true; }
 	for grade in x $(LIBGRADES); do \
 	    if [ "$$grade" != "x" ]; then \
 	        case "$$grade" in \
@@ -295,9 +344,15 @@
 		  $(SUBDIR_MMAKE) GRADE=$$grade install_lib ) && \
 		( cd library && \
 		  $(SUBDIR_MMAKE) GRADE=$$grade install_library ) && \
+		( cd browser && \
+		  $(SUBDIR_MMAKE) GRADE=$$grade install_library ) && \
+		( cd trace && \
+		  $(SUBDIR_MMAKE) GRADE=$$grade install_lib ) && \
 		( cd boehm_gc && rm -f *.o *.pic_o *.a *.so ) && \
 		( cd runtime && rm -f *.o *.pic_o *.a *.so ) && \
 		( cd library && rm -f *.c *.o *.pic_o *.a *.so ) && \
+		( cd browser && rm -f *.c *.o *.pic_o *.a *.so ) && \
+		( cd trace && rm -f *.o *.pic_o *.a *.so ) && \
 		true \
 		|| exit 1; \
 	    fi; \
@@ -305,6 +360,8 @@
 	cd boehm_gc && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd runtime  && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd library  && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
+	cd browser  && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
+	cd trace    && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 
 .PHONY: install_split_library
 install_split_library: scripts dep_library
@@ -333,6 +390,10 @@
 	touch library/*.optdate
 	chmod +w library/*.dep
 	touch library/*.dep
+	touch browser/*.date*
+	touch browser/*.optdate
+	chmod +w browser/*.dep
+	touch browser/*.dep
 	touch compiler/*.date*
 	chmod +w compiler/*.dep
 	touch compiler/*.dep
@@ -344,6 +405,8 @@
 	touch boehm_gc/*.c
 	touch runtime/*.c
 	touch library/*.c
+	touch browser/*.c
+	touch trace/*.c
 	touch compiler/*.c
 	touch profiler/*.c
 	touch doc/*.info doc/*.dvi doc/*.html config.status
@@ -387,7 +450,7 @@
 
 .PHONY: clean_subdirs
 clean_subdirs:
-	rm -rf runtime/tmp_dir library/tmp_dir
+	rm -rf runtime/tmp_dir library/tmp_dir browser/tmp_dir trace/tmp_dir
 	for dir in $(SUBDIRS); do \
 		if [ "$$dir" = scripts ]; then continue; fi; \
 		(cd $$dir; $(SUBDIR_MMAKE) clean) \
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
Index: browser/Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Wed May 28 10:49:58 1997
+++ Mmakefile	Fri Sep 25 16:54:29 1998
@@ -0,0 +1,183 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 1998 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.
+#-----------------------------------------------------------------------------#
+
+# browser/Mmakefile - this is the Mmakefile for building the Mercury
+# browser library, which also includes other functionality needed
+# by Mercury debuggers.
+
+# Since the code in this directory is intended to be invoked only from
+# the trace library, which turns off tracing in the Mercury code it calls,
+# compiling the modules in this directory with tracing on only makes
+# the generated code much bigger. However, since all Mercury code
+# in an executable must be of the same grade, we need to be able to
+# compile the modules in this directory in debug grades as well.
+
+MERCURY_DIR=..
+include $(MERCURY_DIR)/Mmake.common
+
+MAIN_TARGET=library
+
+VPATH=$(LIBRARY_DIR)
+
+#-----------------------------------------------------------------------------#
+
+# If we're going to generate both `.o' files and `.pic_o' files, then
+# don't remove the intermediate `.c' files.
+RM_C	=	$(LIBRARY_RM_C)
+
+#-----------------------------------------------------------------------------#
+
+# Specify which compilers to use to compile the library.
+# Don't change these without good reason - if you want to
+# do a temporary change, change ../Mmake.params.
+
+MCD	=	MERCURY_INT_DIR=$(LIBRARY_DIR) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --generate-dependencies
+MCI	=	MERCURY_INT_DIR=$(LIBRARY_DIR) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --make-interface
+MCOI	=	MERCURY_INT_DIR=$(LIBRARY_DIR) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --make-opt-int
+MCTOI	=	MERCURY_INT_DIR=$(LIBRARY_DIR) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --make-trans-opt
+MCG	=	MERCURY_INT_DIR=$(LIBRARY_DIR) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --compile-to-c
+MCS	=	MERCURY_INT_DIR=$(LIBRARY_DIR) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --split-c-files -c \
+			--cflags "-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			--cflags "-I$(BOEHM_GC_DIR) $(EXTRA_CFLAGS)"
+MGNUC	=	MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(SCRIPTS_DIR)/mgnuc
+MGNUCFLAGS =	-I$(TRACE_DIR) -I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR) \
+			$(EXTRA_MGNUCFLAGS) $(DLL_CFLAGS) $(EXTRA_CFLAGS)
+LDFLAGS	=	-L$(LIBRARY_DIR) -L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR)
+LDLIBS	=	-l$(STD_LIB_NAME) -l$(RT_LIB_NAME) \
+		` case "$(GRADE)" in 					\
+		    *.gc*.prof*) echo "-lgc_prof" ;;			\
+		    *.gc*)	 echo "-lgc" ;;				\
+		  esac							\
+		`
+
+MTAGS	=	$(SCRIPTS_DIR)/mtags
+
+#-----------------------------------------------------------------------------#
+
+# Stuff for Windows DLLS using gnu-win32
+
+ifeq ($(USE_DLLS),yes)
+
+DLL_CFLAGS = -Dlib$(BROWSER_LIB_NAME)_DEFINE_DLL
+
+include $(MERCURY_DIR)/Makefile.DLLs
+
+else
+
+DLL_CFLAGS =
+DLL_DEF_LIB =
+
+endif
+
+#-----------------------------------------------------------------------------#
+
+# targets
+
+.PHONY: all
+all : library
+
+.PHONY: depend
+depend		: browser_library.depend
+
+.PHONY: check
+check		: browser_library.check
+
+.PHONY: all-ints 
+all-ints: ints int3s
+
+.PHONY: ints 
+ints		: browser_library.ints
+
+.PHONY: int3s 
+int3s		: browser_library.int3s
+
+#-----------------------------------------------------------------------------#
+
+tags		: $(MTAGS) $(browser_library.ms)
+	$(MTAGS) $(browser_library.ms)
+
+browser_library.stats : $(COMPILER_DIR)/source_stats.awk $(browser_library.ms)
+	awk -f $(COMPILER_DIR)/source_stats.awk \
+		`vpath_find $(browser_library.ms)` > $@
+	
+#-----------------------------------------------------------------------------#
+
+.PHONY: dates
+dates		:
+	touch $(browser_library.dates)
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: os cs
+os: $(browser_library.os)
+cs: $(browser_library.cs)
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: library
+library: lib$(BROWSER_LIB_NAME).a lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)
+library: $(BROWSER_LIB_NAME).init
+
+lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a : $(browser_library.os)
+	rm -f lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a
+	ar cr lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a $(browser_library.os)
+	$(RANLIB) lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a
+
+RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
+RPATH_2=$(SHLIB_RPATH_SEP)$(FINAL_INSTALL_MERC_GC_LIB_DIR)
+
+lib$(BROWSER_LIB_NAME).so : $(browser_library.pic_os)
+	$(LINK_SHARED_OBJ) -o lib$(BROWSER_LIB_NAME).so \
+		$(browser_library.pic_os)				\
+		$(RPATH_1)$(RPATH_2)					\
+		$(LDFLAGS) $(LDLIBS)					\
+		$(SHARED_LIBS)
+
+$(BROWSER_LIB_NAME).init: $(deps_subdir)browser_library.dep
+	for file in $(browser_library.ms); do \
+		grep '^INIT ' $$file; \
+		echo "INIT mercury__`basename $$file .m`__init"; \
+	done > $(BROWSER_LIB_NAME).init
+
+#-----------------------------------------------------------------------------#
+
+realclean:
+	rm -f lib$(BROWSER_LIB_NAME).a lib$(BROWSER_LIB_NAME).so \
+		$(BROWSER_LIB_NAME).init
+	rm -f tags
+
+#-----------------------------------------------------------------------------#
+
+# Installation targets
+
+.PHONY: install
+install: install_init install_library
+
+.PHONY: install_init
+install_init: $(BROWSER_LIB_NAME).init
+	[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
+	cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
+
+.PHONY: install_library
+install_library: lib$(BROWSER_LIB_NAME).a \
+		lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)
+	[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
+	cp `vpath_find lib$(BROWSER_LIB_NAME).a \
+		lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
+		$(INSTALL_MERC_LIB_DIR)
Index: browser/browser_library.m
===================================================================
RCS file: browser_library.m
diff -N browser_library.m
--- /dev/null	Wed May 28 10:49:58 1997
+++ browser_library.m	Fri Sep 25 17:00:00 1998
@@ -0,0 +1,31 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 1998 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.
+%---------------------------------------------------------------------------%
+
+:- module browser_library.
+
+:- interface.
+
+:- pred browser_library__version(string::out) is det.
+
+:- implementation.
+
+:- import_module help.
+:- import_module debugger_interface.
+
+% Se library/library.m for why we implement this predicate this way.
+
+:- pragma c_code(browser_library__version(Version::out),
+		will_not_call_mercury, "
+	ConstString version_string = 
+		MR_VERSION "", configured for "" MR_FULLARCH;
+	/*
+	** Cast away const needed here, because Mercury declares Version
+	** with type String rather than ConstString.
+	*/
+	Version = (String) (Word) version_string;
+").
+
+%---------------------------------------------------------------------------%
Index: browser/debugger_interface.m
===================================================================
RCS file: debugger_interface.m
diff -N debugger_interface.m
--- /dev/null	Wed May 28 10:49:58 1997
+++ debugger_interface.m	Tue Sep 22 16:13:48 1998
<identical to the old contents of library/debugger_interface.m>
Index: browser/help.m
===================================================================
RCS file: help.m
diff -N help.m
--- /dev/null	Wed May 28 10:49:58 1997
+++ help.m	Thu Sep 24 22:20:36 1998
@@ -0,0 +1,281 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 1998 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: help.m.
+% Author: zs.
+% Stability: low.
+%
+% This file provides a basic help system that stores information in help nodes
+% which are organized as a tree structure of arbitrary depth.
+%
+% The help system consists of a list of help list entries. Each entry
+% has a name, an index (an integer that determines its position in the list),
+% and a help node. Each node contains text that should shed some light
+% on the topic named by the node's entry. Each node also has an associated
+% list of child entries; this list may of course be empty.
+%
+%-----------------------------------------------------------------------------%
+
+:- module help.
+
+:- interface.
+
+:- import_module list, io, std_util.
+
+:- type help__system.
+
+:- type help__path	==	list(string).
+
+:- type help__res	--->	help__ok ; help__error(string).
+
+%-----------------------------------------------------------------------------%
+
+	% Initialize an empty help system.
+:- pred help__init(help__system::out) is det.
+
+	% Add a node to the given help system, at the given path, and with
+	% the given name and index. If successful, return ok and the
+	% updated help system; if not, return an error message and the
+	% original help system.
+:- pred help__add_help_node(help__system::in, help__path::in, int::in,
+	string::in, string::in, help__res::out, help__system::out) is det.
+
+	% Print the top-level help nodes. This should give an overview
+	% of the main topics for which help is available.
+:- pred help__help(help__system::in, io__output_stream::in,
+	io__state::di, io__state::uo) is det.
+
+	% Print the help node at the given path. If there is none,
+	% print the top-level nodes.
+:- pred help__path(help__system::in, help__path::in, io__output_stream::in,
+	help__res::out, io__state::di, io__state::uo) is det.
+
+	% Print all help nodes with the given name. If there are none,
+	% print the top-level nodes.
+:- pred help__name(help__system::in, string::in, io__output_stream::in,
+	io__state::di, io__state::uo) is det.
+
+%-----------------------------------------------------------------------------%
+
+	% Return the type_info for the type help__system, for use by C code.
+:- pred help__help_system_type(type_info::out) is det.
+
+	% Help interpret a help__res for C code.
+:- pred help__result_is_error(help__res::in, string::out) is semidet.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int, string, require.
+
+:- type help__system	==	list(help__entry).
+
+:- type help__node
+	--->	node(
+			help__text,
+			list(help__entry)
+		).
+
+:- type help__text	==	string. % Should be one or more complete lines.
+
+:- type help__entry
+	--->	entry(
+			int,		% This integer determines the position
+					% of the node in the node list. A node
+					% list is always sorted on this field.
+			string,		% The name of the node, which should
+					% be one word or phrase. It must be
+					% unique within the node list, but
+					% need not be unique globally.
+			node
+		).
+
+%-----------------------------------------------------------------------------%
+
+:- pragma export(help__init(out), "ML_HELP_init").
+:- pragma export(help__add_help_node(in, in, in, in, in, out, out),
+	"ML_HELP_add_help_node").
+:- pragma export(help__help(in, in, di, uo), "ML_HELP_help").
+:- pragma export(help__path(in, in, in, out, di, uo), "ML_HELP_path").
+:- pragma export(help__name(in, in, in, di, uo), "ML_HELP_name").
+:- pragma export(help__help_system_type(out), "ML_HELP_help_system_type").
+:- pragma export(help__result_is_error(in, out), "ML_HELP_result_is_error").
+
+%-----------------------------------------------------------------------------%
+
+help__init([]).
+
+help__add_help_node(Sys0, Path, Index, Name, Text, Res, Sys) :-
+	Node = node(Text, []),
+	help__add_node(Sys0, Path, Index, Name, Node, Res, Sys).
+
+:- pred help__add_node(help__system::in, help__path::in, int::in,
+	string::in, help__node::in, help__res::out, help__system::out) is det.
+
+help__add_node(Nodes0, [Step | Steps], Index, Name, NewNode, Res, Nodes) :-
+	( help__one_path_step(Nodes0, Step, Entry0) ->
+		Entry0 = entry(EntryIndex, EntryName, EntryNode0),
+		EntryNode0 = node(Text, SubNodes0),
+		help__add_node(SubNodes0, Steps, Index, Name, NewNode,
+			Res, SubNodes),
+		EntryNode = node(Text, SubNodes),
+		Entry = entry(EntryIndex, EntryName, EntryNode),
+		help__replace_entry(Nodes0, Entry, Nodes)
+	;
+		string__append("invalid path component ", Step, Msg),
+		Res = help__error(Msg),
+		Nodes = Nodes0
+	).
+help__add_node(Nodes0, [], Index, Name, Node, Res, Nodes) :-
+	(
+		list__member(Entry1, Nodes0),
+		Entry1 = entry(Index, _, _)
+	->
+		Res = help__error("entry with given index already exists"),
+		Nodes = Nodes0
+	;
+		list__member(Entry1, Nodes0),
+		Entry1 = entry(_, Name, _)
+	->
+		Res = help__error("entry with given name already exists"),
+		Nodes = Nodes0
+	;
+		Res = help__ok,
+		help__insert_into_entry_list(Nodes0, Index, Name, Node, Nodes)
+	).
+
+:- pred help__insert_into_entry_list(list(help__entry)::in,
+	int::in, string::in, help__node::in, list(help__entry)::out) is det.
+
+help__insert_into_entry_list([], Index, Name, Node, [Entry]) :-
+	Entry = entry(Index, Name, Node).
+help__insert_into_entry_list([Head | Tail], Index, Name, Node, List) :-
+	Head = entry(HeadIndex, _, _),
+	( HeadIndex < Index ->
+		help__insert_into_entry_list(Tail, Index, Name, Node, NewTail),
+		List = [Head | NewTail]
+	;
+		Entry = entry(Index, Name, Node),
+		List = [Entry, Head | Tail]
+	).
+
+%-----------------------------------------------------------------------------%
+
+help__help(Sys, Stream) -->
+	help__print_entry_list(Sys, Stream).
+
+help__name(Sys, Name, Stream) -->
+	help__search_entry_list(Sys, Name, 0, Count, Stream),
+	( { Count = 0 } ->
+		io__write_string("There is no such help topic.\n"),
+		help__help(Sys, Stream)
+	;
+		[]
+	).
+
+:- pred help__search_entry_list(list(help__entry)::in, string::in,
+	int::in, int::out, io__output_stream::in,
+	io__state::di, io__state::uo) is det.
+
+help__search_entry_list([], _, C, C, _) --> [].
+help__search_entry_list([Entry | Tail], Name, C0, C, Stream) -->
+	{ Entry = entry(_, EntryName, Node) },
+	( { Name = EntryName } ->
+		% We print this node, but don't search its children.
+		help__print_node(Node, Stream),
+		{ C is C0 + 1 }
+	;
+		help__search_node(Node, Name, C0, C1, Stream),
+		help__search_entry_list(Tail, Name, C1, C, Stream)
+	).
+
+:- pred help__search_node(help__node::in, string::in, int::in, int::out,
+	io__output_stream::in, io__state::di, io__state::uo) is det.
+
+help__search_node(node(_, SubNodes), Name, C0, C, Stream) -->
+	help__search_entry_list(SubNodes, Name, C0, C, Stream).
+
+help__path(Entries, Path, Stream, Result) -->
+	( { Path = [Step] } ->
+		( { help__one_path_step(Entries, Step, Entry) } ->
+			{ Entry = entry(_, _, EntryNode) },
+			{ EntryNode = node(Text, _) },
+			io__write_string(Stream, Text),
+			{ Result = help__ok }
+		;
+			{ string__append_list(["error at path component """,
+				Step, """"], Msg) },
+			{ Result = help__error(Msg) }
+		)
+	; { Path = [Step | Tail] } ->
+		( { help__one_path_step(Entries, Step, Entry) } ->
+			{ Entry = entry(_, _, EntryNode) },
+			{ EntryNode = node(_, SubEntries) },
+			help__path(SubEntries, Tail, Stream, Result)
+		;
+			{ string__append_list(["error at path component """,
+				Step, """"], Msg) },
+			{ Result = help__error(Msg) }
+		)
+	;
+		{ Result = help__error("the path does not go that deep") }
+	).
+
+%-----------------------------------------------------------------------------%
+
+:- pred help__print_entry_list(list(help__entry)::in, io__output_stream::in,
+	io__state::di, io__state::uo) is det.
+
+help__print_entry_list([], _) --> [].
+help__print_entry_list([entry(_, _, Node) | Nodes], Stream) -->
+	help__print_node(Node, Stream),
+	help__print_entry_list(Nodes, Stream).
+
+:- pred help__print_node(help__node::in, io__output_stream::in,
+	io__state::di, io__state::uo) is det.
+
+help__print_node(node(Text, _Nodes), Stream) -->
+	io__write_string(Stream, Text).
+	% XXX help__print_entry_list(Nodes, Stream).
+
+%-----------------------------------------------------------------------------%
+
+:- pred help__one_path_step(list(help__entry)::in, string::in,
+	help__entry::out) is semidet.
+
+help__one_path_step([Head | Tail], Name, Entry) :-
+	Head = entry(_, HeadName, _),
+	( HeadName = Name ->
+		Entry = Head
+	;
+		help__one_path_step(Tail, Name, Entry)
+	).
+
+:- pred help__replace_entry(list(help__entry)::in, help__entry::in,
+	list(help__entry)::out) is det.
+
+help__replace_entry([], _, _) :-
+	error("help__replace_entry: entry to be replaced not found").
+help__replace_entry([Head | Tail], Entry, List) :-
+	Head = entry(HeadIndex, _, _),
+	Entry = entry(EntryIndex, _, _),
+	( HeadIndex = EntryIndex ->
+		List = [Entry | Tail]
+	;
+		help__replace_entry(Tail, Entry, NewTail),
+		List = [Head | NewTail]
+	).
+
+%-----------------------------------------------------------------------------%
+
+help__help_system_type(Type) :-
+	help__init(HelpInit),
+	Type = type_of(HelpInit).
+
+help__result_is_error(help__error(Msg), Msg).
+
+%-----------------------------------------------------------------------------%
cvs diff: Diffing bytecode
cvs diff: Diffing bytecode/test
cvs diff: Diffing compiler
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.11
diff -u -u -r1.11 Mmakefile
--- Mmakefile	1998/03/30 13:03:05	1.11
+++ Mmakefile	1998/09/24 11:58:54
@@ -26,23 +26,26 @@
 			--make-optimization-interface
 MCTOI	=	MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) \
 			--make-transitive-optimization-interface
-MCG	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) \
+MCG	=	MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
 		MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) --compile-to-c
-MCS	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) \
+MCS	=	MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
 		MERCURY_INT_DIR=$(LIBRARY_DIR) \
 		$(MC) --cflags -I$(BOEHM_GC_DIR) --split-c-files -c 
-MGNUC	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(SCRIPTS_DIR)/mgnuc
+MGNUC	=	MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(SCRIPTS_DIR)/mgnuc
 MGNUCFLAGS =	$(EXTRA_MGNUCFLAGS) -I$(BOEHM_GC_DIR) $(EXTRA_CFLAGS)
-C2INIT =	\
-MERCURY_MOD_LIB_MODS="$(RUNTIME_DIR)/runtime.init $(LIBRARY_DIR)/libmercury.init" \
+C2INIT =	MERCURY_MOD_LIB_MODS="$(TRACE_DIR)/$(TRACE_LIB_NAME).init $(LIBRARY_DIR)/$(STD_LIB_NAME).init $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init $(RUNTIME_DIR)/$(RT_LIB_NAME).init" \
 		MERCURY_MKINIT=$(UTIL_DIR)/mkinit $(SCRIPTS_DIR)/c2init
 ML	=	MERCURY_C_LIB_DIR=. $(SCRIPTS_DIR)/ml
 MLFLAGS =	--mercury-libs none $(EXTRA_MLFLAGS)
-MLLIBS  =	$(EXTRA_MLLIBS) $(LIBRARY_DIR)/libmercury.a \
-		$(RUNTIME_DIR)/libmer.a ` \
+MLLIBS  =	$(EXTRA_MLLIBS) \
+		$(TRACE_DIR)/lib$(TRACE_LIB_NAME).a \
+		$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).a \
+		$(LIBRARY_DIR)/lib$(STD_LIB_NAME).a \
+		$(RUNTIME_DIR)/lib$(RT_LIB_NAME).a ` \
 		    case $(GRADE) in \
-			*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.a ;; \
-			*.gc*) echo $(BOEHM_GC_DIR)/libgc.a ;; \
+			*.gc*.prof*)	echo $(BOEHM_GC_DIR)/libgc_prof.a ;; \
+			*.gc*)		echo $(BOEHM_GC_DIR)/libgc.a ;; \
 		    esac \
 		` -lm
 MSC	=	MERCURY_SICSTUS_COMPILER=$(LIBRARY_DIR)/sicstus_compile \
@@ -88,7 +91,10 @@
 # Add some additional dependencies, so that Mmake knows to remake the
 # compiler if one of the libraries changes.
 
-mercury_compile: $(RUNTIME_DIR)/libmer.a $(LIBRARY_DIR)/libmercury.a
+mercury_compile: $(RUNTIME_DIR)/lib$(RT_LIB_NAME).a
+mercury_compile: $(LIBRARY_DIR)/lib$(STD_LIB_NAME).a
+mercury_compile: $(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).a
+mercury_compile: $(TRACE_DIR)/lib$(TRACE_LIB_NAME).a
 # Should also depend on $(BOEHM_GC_DIR)/libgc(_prof).a, but only
 # if in .gc(.prof) grade; GNU make does not support dynamic dependencies,
 # so just leave it out.
cvs diff: Diffing compiler/notes
cvs diff: Diffing doc
Index: doc/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/Mmakefile,v
retrieving revision 1.11
diff -u -u -r1.11 Mmakefile
--- Mmakefile	1998/09/01 05:17:38	1.11
+++ Mmakefile	1998/09/24 12:52:45
@@ -95,17 +95,14 @@
 
 # The following rules automatically build the library documentation
 # by extracting the module interfaces from the library source code.
-# Note that the debugger_interface.m module is just an implementation
+# Note that the private_builtin.m module is just an implementation
 # detail of the library, so it is not documented.
-# Same goes for private_builtin.m.
 
 library-menu.texi: $(LIBRARY_DIR)/*.m
 	{								\
 	echo "";							\
 	for filename in $(LIBRARY_DIR)/*.m; do				\
 		case $$filename in					\
-			$(LIBRARY_DIR)/debugger_interface.m)		\
-				;;					\
 			$(LIBRARY_DIR)/private_builtin.m)		\
 				;;					\
 			*)						\
@@ -118,8 +115,6 @@
 library-chapters.texi: $(LIBRARY_DIR)/*.m
 	for filename in $(LIBRARY_DIR)/*.m; do 				\
 		case $$filename in					\
-			$(LIBRARY_DIR)/debugger_interface.m)		\
-				;;					\
 			$(LIBRARY_DIR)/private_builtin.m)		\
 				;;					\
 			*)						\
cvs diff: Diffing extras
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/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/Togl-1.2
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/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.33
diff -u -u -r1.33 Mmakefile
--- Mmakefile	1998/06/30 06:32:17	1.33
+++ Mmakefile	1998/09/24 12:02:04
@@ -63,37 +63,39 @@
 endif
 
 MCD	=	MERCURY_INT_DIR=. \
-		MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(MC) \
-			--generate-dependencies $(INTERMODULE_OPTS)
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --generate-dependencies $(INTERMODULE_OPTS)
 MCI	=	MERCURY_INT_DIR=. \
-		MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(MC) \
-			--make-interface $(INTERMODULE_OPTS) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --make-interface $(INTERMODULE_OPTS) \
 			$(ENABLE_TERM_OPTS)
 MCOI	=	MERCURY_INT_DIR=. \
-		MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(MC) \
-			--make-opt-int $(INTERMODULE_OPTS) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --make-opt-int $(INTERMODULE_OPTS) \
 			$(ENABLE_TERM_OPTS)
 MCTOI	=	MERCURY_INT_DIR=. \
-		MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(MC) \
-			--make-trans-opt $(INTERMODULE_OPTS) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --make-trans-opt $(INTERMODULE_OPTS) \
 			$(ENABLE_TERM_OPTS)
 MCG	=	MERCURY_INT_DIR=. \
-		MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(MC) \
-			--compile-to-c $(INTERMODULE_OPTS) \
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --compile-to-c $(INTERMODULE_OPTS) \
 			$(CHECK_TERM_OPTS)
 MCS	=	MERCURY_INT_DIR=. \
-		MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(MC) \
-		--split-c-files -c \
-		--cflags "-I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR) $(EXTRA_CFLAGS)" \
-		$(INTERMODULE_OPTS) $(CHECK_TERM_OPTS)
-MGNUC	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(SCRIPTS_DIR)/mgnuc
-MGNUCFLAGS =	$(EXTRA_MGNUCFLAGS) -I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR)  \
-		$(DLL_CFLAGS) $(EXTRA_CFLAGS)
+		MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(MC) --split-c-files -c \
+			--cflags "-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			--cflags "-I$(BOEHM_GC_DIR) $(EXTRA_CFLAGS)" \
+			$(INTERMODULE_OPTS) $(CHECK_TERM_OPTS)
+MGNUC	=	MERCURY_ALL_C_INCL_DIRS="-I$(TRACE_DIR) -I$(RUNTIME_DIR)" \
+			$(SCRIPTS_DIR)/mgnuc
+MGNUCFLAGS =	-I$(TRACE_DIR) -I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR) \
+			$(EXTRA_MGNUCFLAGS) $(DLL_CFLAGS) $(EXTRA_CFLAGS)
 LDFLAGS	=	-L$(BOEHM_GC_DIR) -L$(RUNTIME_DIR)
-LDLIBS	=	-lmer							\
+LDLIBS	=	-l$(RT_LIB_NAME) \
 		` case "$(GRADE)" in 					\
 		    *.gc*.prof*) echo "-lgc_prof" ;;			\
-		    *.gc*)	echo "-lgc" ;;				\
+		    *.gc*)	 echo "-lgc" ;;				\
 		  esac							\
 		`
 
@@ -105,7 +107,7 @@
 
 ifeq ($(USE_DLLS),yes)
 
-DLL_CFLAGS = -Dlibmercury_DEFINE_DLL
+DLL_CFLAGS = -Dlib$(STD_LIB_NAME)_DEFINE_DLL
 
 include $(MERCURY_DIR)/Makefile.DLLs
 
@@ -141,7 +143,7 @@
 all : mercury nuprolog sicstus
 
 .PHONY: mercury
-mercury : all-ints libmercury
+mercury : all-ints lib_std
 
 .PHONY: nuprolog
 nuprolog : all-ints library.nu library.nu.debug \
@@ -213,31 +215,32 @@
 
 #-----------------------------------------------------------------------------#
 
-.PHONY: libmercury
+.PHONY: lib_std
 # the following dependency is just there to improve compilation speed;
 # making tree234.o first improves effective parallelism with parallel makes.
-libmercury : $(os_subdir)tree234.o
-libmercury : libmercury.a libmercury.$(EXT_FOR_SHARED_LIB) libmercury.init
+lib_std: $(os_subdir)tree234.o
+lib_std: lib$(STD_LIB_NAME).a lib$(STD_LIB_NAME).$(EXT_FOR_SHARED_LIB)
+lib_std: $(STD_LIB_NAME).init
+
+lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a : $(library.os)
+	rm -f lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a
+	ar cr lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a $(library.os)
+	$(RANLIB) lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a
 
-libmercury$(DLL_DEF_LIB).a : $(library.os)
-	rm -f libmercury$(DLL_DEF_LIB).a
-	ar cr libmercury$(DLL_DEF_LIB).a $(library.os)
-	$(RANLIB) libmercury$(DLL_DEF_LIB).a
-
 RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
 RPATH_2=$(SHLIB_RPATH_SEP)$(FINAL_INSTALL_MERC_GC_LIB_DIR)
 
-libmercury.so : $(library.pic_os)
-	$(LINK_SHARED_OBJ) -o libmercury.so $(library.pic_os)		\
+lib$(STD_LIB_NAME).so : $(library.pic_os)
+	$(LINK_SHARED_OBJ) -o lib$(STD_LIB_NAME).so $(library.pic_os)	\
 		$(RPATH_1)$(RPATH_2)					\
 		$(LDFLAGS) $(LDLIBS)					\
 		$(SHARED_LIBS)
 
-libmercury.init: $(deps_subdir)library.dep
+$(STD_LIB_NAME).init: $(deps_subdir)library.dep
 	for file in $(library.ms); do \
 		grep '^INIT ' $$file; \
 		echo "INIT mercury__`basename $$file .m`__init"; \
-	done > libmercury.init
+	done > $(STD_LIB_NAME).init
 
 #-----------------------------------------------------------------------------#
 
@@ -302,7 +305,7 @@
 	rm -f $(nos_subdir)*.no $(qls_subdir)*.ql
 
 realclean:
-	rm -f libmercury.a libmercury.so libmercury.init
+	rm -f lib$(STD_LIB_NAME).a lib$(STD_LIB_NAME).so $(STD_LIB_NAME).init
 	rm -f sicstus_saved_state sicstus_compile sp_builtin.pl
 	rm -f tags
 
@@ -351,26 +354,30 @@
 	done
 
 .PHONY: install_init
-install_init: libmercury.init
+install_init: $(STD_LIB_NAME).init
 	[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
-	cp `vpath_find libmercury.init` $(INSTALL_MODULE_DIR)
-	# "libmercury.init" used to be called "library.init".
-	# If there is still a version with the old name lying around,
-	# then delete it; otherwise the initialization would get done twice.
-	rm -f $(INSTALL_MODULE_DIR)/library.init
+	cp `vpath_find $(STD_LIB_NAME).init` $(INSTALL_MODULE_DIR)
+	# "$(STD_LIB_NAME).init" used to be called "library.init" or
+	# "libmercury.init". If there is still a version with an old name
+	# lying around, then delete it; otherwise the initialization
+	# would get done twice.
+	rm -f $(INSTALL_MODULE_DIR)/library.init \
+		$(INSTALL_MODULE_DIR)/libmercury.init
 
 .PHONY: install_library
-install_library: libmercury.a libmercury.$(EXT_FOR_SHARED_LIB)
+install_library: lib$(STD_LIB_NAME).a lib$(STD_LIB_NAME).$(EXT_FOR_SHARED_LIB)
 	[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
-	cp `vpath_find libmercury.a libmercury.$(EXT_FOR_SHARED_LIB)` \
+	cp `vpath_find lib$(STD_LIB_NAME).a \
+		lib$(STD_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
 		$(INSTALL_MERC_LIB_DIR)
 
-# library.split.a is a version of libmercury.a that has been compiled
+# library.split.a is a version of lib$(STD_LIB_NAME).a that has been compiled
 # with `--split-c-files'.
 .PHONY: install_split_library
 install_split_library: library.split.a
 	[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
-	cp `vpath_find library.split.a` $(INSTALL_MERC_LIB_DIR)/libmercury.a
+	cp `vpath_find library.split.a` \
+		$(INSTALL_MERC_LIB_DIR)/lib$(STD_LIB_NAME).a
 
 .PHONY: install_nuprolog
 install_nuprolog: install_library_nu install_interpreter_nu
Index: library/debugger_interface.m
===================================================================
RCS file: debugger_interface.m
diff -N debugger_interface.m
--- /tmp/cvs01849gaa	Mon Sep 28 16:54:11 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.42
diff -u -u -r1.42 library.m
--- library.m	1998/09/19 05:32:48	1.42
+++ library.m	1998/09/24 12:52:00
@@ -32,7 +32,6 @@
 :- import_module std_util, string, term, term_io, tree234, varset.
 :- import_module store, rbtree, parser, lexer, ops.
 :- import_module prolog.
-:- import_module debugger_interface.
 :- import_module integer, rational.
 
 % library__version must be implemented using pragma c_code,
cvs diff: Diffing lp_solve
cvs diff: Diffing lp_solve/lp_examples
cvs diff: Diffing profiler
Index: profiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/profiler/Mmakefile,v
retrieving revision 1.7
diff -u -u -r1.7 Mmakefile
--- Mmakefile	1998/03/20 02:58:20	1.7
+++ Mmakefile	1998/09/24 12:02:23
@@ -28,15 +28,15 @@
 MGNUC	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(SCRIPTS_DIR)/mgnuc
 MGNUCFLAGS =	$(EXTRA_MGNUCFLAGS) -I$(BOEHM_GC_DIR) $(EXTRA_CFLAGS)
 C2INIT =	\
-MERCURY_MOD_LIB_MODS="$(RUNTIME_DIR)/runtime.init $(LIBRARY_DIR)/libmercury.init" \
+MERCURY_MOD_LIB_MODS="$(RUNTIME_DIR)/$(RT_LIB_NAME).init $(LIBRARY_DIR)/$(STD_LIB_NAME).init" \
 		MERCURY_MKINIT=$(UTIL_DIR)/mkinit $(SCRIPTS_DIR)/c2init
 ML	=	MERCURY_C_LIB_DIR=. $(SCRIPTS_DIR)/ml
 MLFLAGS =	--mercury-libs none $(EXTRA_MLFLAGS)
-MLLIBS  =	$(EXTRA_MLLIBS) $(LIBRARY_DIR)/libmercury.a \
-		$(RUNTIME_DIR)/libmer.a ` \
+MLLIBS  =	$(EXTRA_MLLIBS) $(LIBRARY_DIR)/lib$(STD_LIB_NAME).a \
+		$(RUNTIME_DIR)/lib$(RT_LIB_NAME).a ` \
 		    case $(GRADE) in \
-			*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.a ;; \
-			*.gc*) echo $(BOEHM_GC_DIR)/libgc.a ;; \
+			*.gc*.prof*)	echo $(BOEHM_GC_DIR)/libgc_prof.a ;; \
+			*.gc*) 		echo $(BOEHM_GC_DIR)/libgc.a ;; \
 		    esac \
 		` -lm
 MSL	=	MERCURY_SP_LIB_DIR=$(LIBRARY_DIR) $(SCRIPTS_DIR)/msl
@@ -56,7 +56,8 @@
 # Add some additional dependencies, so that Mmake knows to remake the
 # profiler if one of the libraries changes.
 
-mercury_profile: $(RUNTIME_DIR)/libmer.a $(LIBRARY_DIR)/libmercury.a
+mercury_profile: $(RUNTIME_DIR)/lib$(RT_LIB_NAME).a
+mercury_profile: $(LIBRARY_DIR)/lib$(STD_LIB_NAME).a
 # Should also depend on $(BOEHM_GC_DIR)/libgc(_prof).a, but only
 # if in .gc(.prof) grade; GNU make does not support dynamic dependencies,
 # so just leave it out.
cvs diff: Diffing runtime
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.38
diff -u -u -r1.38 Mmakefile
--- Mmakefile	1998/09/15 07:19:11	1.38
+++ Mmakefile	1998/09/24 12:19:00
@@ -6,7 +6,7 @@
 
 # Mmake - Mmake file for the Mercury runtime library
 
-MAIN_TARGET=lib
+MAIN_TARGET=runtime
 
 MERCURY_DIR=..
 include $(MERCURY_DIR)/Mmake.common
@@ -69,22 +69,18 @@
 			mercury_tags.h		\
 			mercury_thread.h	\
 			mercury_timing.h	\
-			mercury_trace.h		\
 			mercury_trace_base.h	\
-			mercury_trace_external.h \
-			mercury_trace_internal.h \
 			mercury_trace_util.h	\
 			mercury_trail.h		\
 			mercury_types.h		\
 			mercury_type_info.h	\
 			mercury_wrapper.h	\
-			$(LIBMER_DLL_H)
+			$(LIB_DLL_H)
 
-# Note that `libmer_globals.h' cannot be part of $(HDR),
-# since it depends on libmer_def.a, and $(OBJ) : $(HDR) would create a
+# Note that $(LIB_GLOBALS_H) cannot be part of $(HDR), since it depends on
+# lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a, and $(OBJ) : $(HDR) would create a
 # circular dependency.
 
-
 MACHHDRS	= 	machdeps/no_regs.h	\
 			machdeps/i386_regs.h	\
 			machdeps/mips_regs.h	\
@@ -127,10 +123,7 @@
 			mercury_table_type_info.c \
 			mercury_thread.c	\
 			mercury_timing.c	\
-			mercury_trace.c		\
 			mercury_trace_base.c	\
-			mercury_trace_external.c \
-			mercury_trace_internal.c \
 			mercury_trace_util.c	\
 			mercury_trail.c 	\
 			mercury_type_info.c	\
@@ -158,19 +151,19 @@
 
 ifeq ($(USE_DLLS),yes)
 
-DLL_CFLAGS	= -Dlibmer_DEFINE_DLL
+DLL_CFLAGS	= -Dlib$(RT_LIB_NAME)_DEFINE_DLL
 
 # the following header files are created automatically by Makefile.DLLs
-LIBMER_DLL_H	 = libmer_dll.h
-LIBMER_GLOBALS_H = libmer_globals.h
+LIB_DLL_H     = lib$(RT_LIB_NAME)_dll.h
+LIB_GLOBALS_H = lib$(RT_LIB_NAME)_globals.h
 
 include $(MERCURY_DIR)/Makefile.DLLs
 
 else
 
 DLL_CFLAGS =
-LIBMER_DLL_H =
-LIBMER_GLOBALS_H =
+LIB_DLL_H =
+LIB_GLOBALS_H =
 DLL_DEF_LIB =
 
 endif
@@ -181,23 +174,24 @@
 
 #-----------------------------------------------------------------------------#
 
-.PHONY: lib
-lib: libmer.a libmer.$(EXT_FOR_SHARED_LIB) runtime.init \
-	$(LIBMER_DLL_H) $(LIBMER_GLOBALS_H)
-
-libmer$(DLL_DEF_LIB).a: $(OBJS)
-	rm -f libmer$(DLL_DEF_LIB).a
-	ar cr libmer$(DLL_DEF_LIB).a $(OBJS)
-	$(RANLIB) libmer$(DLL_DEF_LIB).a
+.PHONY: runtime
+runtime: lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB)
+runtime: $(RT_LIB_NAME).init
+runtime: $(LIB_DLL_H) $(LIB_GLOBALS_H)
+
+lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a: $(OBJS)
+	rm -f lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a
+	ar cr lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
+	$(RANLIB) lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a
 
-libmer.so: $(PIC_OBJS)
-	$(LINK_SHARED_OBJ) -o libmer.so $(PIC_OBJS)			\
+lib$(RT_LIB_NAME).so: $(PIC_OBJS)
+	$(LINK_SHARED_OBJ) -o lib$(RT_LIB_NAME).so $(PIC_OBJS)		\
 		$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_GC_LIB_DIR)	\
 		$(LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
 		$(SHARED_LIBS)
 
-runtime.init: $(CFILES)
-	cat `vpath_find $(CFILES)` | grep '^INIT ' > runtime.init
+$(RT_LIB_NAME).init: $(CFILES)
+	cat `vpath_find $(CFILES)` | grep '^INIT ' > $(RT_LIB_NAME).init
 
 mercury_conf.h.date: $(MERCURY_DIR)/config.status mercury_conf.h.in
 	CONFIG_FILES= CONFIG_HEADERS=mercury_conf.h $(MERCURY_DIR)/config.status
@@ -229,22 +223,27 @@
 install: install_headers install_init install_lib
 
 .PHONY: install_headers
-install_headers: $(HDRS) $(MACHHDRS) $(LIBMER_GLOBALS_H)
+install_headers: $(HDRS) $(MACHHDRS) $(LIB_GLOBALS_H)
 	-[ -d $(INSTALL_INC_DIR)/machdeps ] || \
 		mkdir -p $(INSTALL_INC_DIR)/machdeps
-	cp `vpath_find $(HDRS) $(LIBMER_GLOBALS_H)` $(INSTALL_INC_DIR)
+	cp `vpath_find $(HDRS) $(LIB_GLOBALS_H)` $(INSTALL_INC_DIR)
 	chmod u+w $(INSTALL_INC_DIR)/mercury_conf.h
 	cp `vpath_find $(MACHHDRS)` $(INSTALL_INC_DIR)/machdeps
 
 .PHONY: install_init
-install_init: runtime.init
+install_init: $(RT_LIB_NAME).init
 	-[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
-	cp `vpath_find runtime.init` $(INSTALL_MODULE_DIR)
+	cp `vpath_find $(RT_LIB_NAME).init` $(INSTALL_MODULE_DIR)
+	# "$(RT_LIB_NAME).init" used to be called "runtime.init".
+	# If there is still a version with an old name lying around,
+	# then delete it; otherwise the initialization would get done twice.
+	rm -f $(INSTALL_MODULE_DIR)/runtime.init
 
 .PHONY: install_lib
-install_lib: libmer.a libmer.$(EXT_FOR_SHARED_LIB)
+install_lib: lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB)
 	-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
-	cp `vpath_find libmer.a libmer.$(EXT_FOR_SHARED_LIB)` \
+	cp `vpath_find lib$(RT_LIB_NAME).a \
+		lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
 		$(INSTALL_MERC_LIB_DIR)
 
 #-----------------------------------------------------------------------------#
@@ -261,7 +260,7 @@
 	rm -f $(OBJS) $(PIC_OBJS) 
 
 realclean:
-	rm -f libmer.a libmer.so runtime.init
+	rm -f lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).so $(RT_LIB_NAME).init
 	rm -f mercury_conf.h mercury_conf.h.date
 
 #-----------------------------------------------------------------------------#
Index: runtime/mercury_init.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_init.h,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_init.h
--- mercury_init.h	1998/08/02 04:15:01	1.6
+++ mercury_init.h	1998/09/25 04:44:59
@@ -22,7 +22,7 @@
 */
 #include "mercury_conf.h" /* for USE_DLLS */
 #if USE_DLLS
-  #include "libmer_dll.h"
+  #include "libmer_rt_dll.h"
 #endif
 
 /*---------------------------------------------------------------------------*/
@@ -83,6 +83,7 @@
 				   mercury_runtime_main(),
 				   mercury_runtime_terminate(),
 				   etc. */
+#include "mercury_trace_base.h"	/* for MR_trace_port */
 
 #ifdef CONSERVATIVE_GC
   #include "gc.h"
@@ -118,6 +119,13 @@
 /* in library/std_util.m  */
 String	ML_type_name(Word);
 
+/* in runtime/mercury_trace_base.c */
+void	MR_trace_fake(const MR_Stack_Layout_Label *, MR_trace_port,
+		Word, Word, const char *, int);
+
+/* in trace/mercury_trace.c */
+void	MR_trace_real(const MR_Stack_Layout_Label *, MR_trace_port,
+		Word, Word, const char *, int);
 
 #endif /* not MERCURY_INIT_H */
 
Index: runtime/mercury_memory.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory.c,v
retrieving revision 1.14
diff -u -u -r1.14 mercury_memory.c
--- mercury_memory.c	1998/09/21 09:08:16	1.14
+++ mercury_memory.c	1998/09/24 12:14:19
@@ -85,7 +85,7 @@
 #endif
 
 #include "mercury_imp.h"
-#include "mercury_trace.h"
+#include "mercury_trace_base.h"
 #include "mercury_memory_handlers.h"
 
 /*---------------------------------------------------------------------------*/
Index: runtime/mercury_memory_handlers.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_handlers.c,v
retrieving revision 1.7
diff -u -u -r1.7 mercury_memory_handlers.c
--- mercury_memory_handlers.c	1998/08/24 08:24:46	1.7
+++ mercury_memory_handlers.c	1998/09/24 12:14:19
@@ -65,7 +65,7 @@
 
 #include "mercury_imp.h"
 #include "mercury_signal.h"
-#include "mercury_trace.h"
+#include "mercury_trace_base.h"
 #include "mercury_memory_zones.h"
 #include "mercury_memory_handlers.h"
 
Index: runtime/mercury_memory_zones.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_zones.c,v
retrieving revision 1.5
diff -u -u -r1.5 mercury_memory_zones.c
--- mercury_memory_zones.c	1998/07/22 07:52:57	1.5
+++ mercury_memory_zones.c	1998/09/24 12:14:20
@@ -44,8 +44,6 @@
   #include <sys/ucontext.h>
 #endif
 
-#include "mercury_trace.h"
-
 #ifdef MR_THREAD_SAFE
   #include "mercury_thread.h"
 #endif
Index: runtime/mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.12
diff -u -u -r1.12 mercury_misc.c
--- mercury_misc.c	1998/08/24 08:24:48	1.12
+++ mercury_misc.c	1998/09/24 12:14:20
@@ -7,7 +7,7 @@
 #include	"mercury_imp.h"
 #include	"mercury_dlist.h"
 #include	"mercury_regs.h"
-#include	"mercury_trace.h"
+#include	"mercury_trace_base.h"
 #include	"mercury_label.h"
 #include	"mercury_misc.h"
 
Index: runtime/mercury_trace.c
===================================================================
RCS file: mercury_trace.c
diff -N mercury_trace.c
--- /tmp/cvs01849paa	Mon Sep 28 16:54:43 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
Index: runtime/mercury_trace.h
===================================================================
RCS file: mercury_trace.h
diff -N mercury_trace.h
--- /tmp/cvs01849qaa	Mon Sep 28 16:54:45 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.1
diff -u -u -r1.1 mercury_trace_base.c
--- mercury_trace_base.c	1998/07/03 05:34:46	1.1
+++ mercury_trace_base.c	1998/09/25 04:53:43
@@ -14,10 +14,7 @@
 */
 
 #include "mercury_imp.h"
-#include "mercury_trace.h"
-#include "mercury_trace_util.h"
-#include "mercury_trace_internal.h"
-#include "mercury_trace_external.h"
+#include "mercury_trace_base.h"
 #include "mercury_engine.h"
 #include "mercury_wrapper.h"
 #include "mercury_misc.h"
@@ -88,6 +85,26 @@
 */
 
 Bool		MR_trace_from_full = 1;
+
+void
+MR_trace(const MR_Stack_Layout_Label *layout, MR_trace_port port,
+	Word seqno, Word depth, const char * path, int max_mr_num,
+	bool trace_this_event)
+{
+	if (MR_trace_enabled && trace_this_event) {
+		(*MR_trace_func_ptr)(layout, port, seqno, depth,
+			path, max_mr_num);
+	}
+}
+
+void
+MR_trace_fake(const MR_Stack_Layout_Label *layout, MR_trace_port port,
+	Word seqno, Word depth, const char * path, int max_mr_num)
+{
+	fatal_error("This executable is not set up for debugging.\n"
+		"Rebuild the <main>_init.c file, "
+		"and give the -t flag to c2init.\n");
+}
 
 void
 MR_trace_init(void)
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.1
diff -u -u -r1.1 mercury_trace_base.h
--- mercury_trace_base.h	1998/07/03 05:34:47	1.1
+++ mercury_trace_base.h	1998/09/25 06:48:48
@@ -11,9 +11,42 @@
 ** is compiled with execution tracing.
 */
 
-#ifndef MERCURY_TRACE_PERMANENT_H
-#define MERCURY_TRACE_PERMANENT_H
+#ifndef MERCURY_TRACE_BASE_H
+#define MERCURY_TRACE_BASE_H
 
+#include <stdio.h>
+
+/*
+** This enum should EXACTLY match the definition of the `trace_port_type' type
+** in library/debugger_interface.
+*/
+
+typedef	enum {
+	MR_PORT_CALL,
+	MR_PORT_EXIT,
+	MR_PORT_FAIL,
+	MR_PORT_THEN,
+	MR_PORT_ELSE,
+	MR_PORT_DISJ,
+	MR_PORT_SWITCH,
+	MR_PORT_PRAGMA_FIRST,
+	MR_PORT_PRAGMA_LATER
+} MR_trace_port;
+
+/*
+** MR_trace is called from Mercury modules compiled with tracing.
+** It performs an indirect call through MR_trace_func_ptr, which
+** will point either to MR_trace_real, which is defined in the trace
+** library, or to MR_trace_fake, defined here, which just prints an
+** error message and aborts.
+*/
+
+extern	void	MR_trace(const MR_Stack_Layout_Label *, MR_trace_port,
+			Word, Word, const char *, int, bool);
+
+extern	void	MR_trace_fake(const MR_Stack_Layout_Label *, MR_trace_port,
+			Word, Word, const char *, int);
+
 /*
 ** MR_trace_init() is called from mercury_runtime_init()
 ** when the debuggee programs begins, to perform any initialization
@@ -71,4 +104,4 @@
 extern	void	MR_trace_report(FILE *fp);
 extern	void	MR_trace_report_raw(int fd);
 
-#endif /* MERCURY_TRACE_PERMANENT_H */
+#endif /* MERCURY_TRACE_BASE_H */
Index: runtime/mercury_trace_external.c
===================================================================
RCS file: mercury_trace_external.c
diff -N mercury_trace_external.c
--- /tmp/cvs01849taa	Mon Sep 28 16:54:48 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
Index: runtime/mercury_trace_external.h
===================================================================
RCS file: mercury_trace_external.h
diff -N mercury_trace_external.h
--- /tmp/cvs01849uaa	Mon Sep 28 16:54:49 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
@@ -1,21 +0,0 @@
Index: runtime/mercury_trace_internal.c
===================================================================
RCS file: mercury_trace_internal.c
diff -N mercury_trace_internal.c
--- /tmp/cvs01849vaa	Mon Sep 28 16:54:50 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
Index: runtime/mercury_trace_internal.h
===================================================================
RCS file: mercury_trace_internal.h
diff -N mercury_trace_internal.h
--- /tmp/cvs01849waa	Mon Sep 28 16:54:52 1998
+++ /dev/null	Wed May 28 10:49:58 1997
<moved to browser>
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.25
diff -u -u -r1.25 mercury_wrapper.c
--- mercury_wrapper.c	1998/09/21 10:21:41	1.25
+++ mercury_wrapper.c	1998/09/25 06:15:25
@@ -37,7 +37,8 @@
 #include	"mercury_timing.h"
 #include	"mercury_init.h"
 #include	"mercury_dummy.h"
-#include	"mercury_trace.h"
+#include	"mercury_stack_layout.h"
+#include	"mercury_trace_base.h"
 
 /* global variables concerned with testing (i.e. not with the engine) */
 
@@ -146,6 +147,9 @@
 		Integer, Integer, Integer, Word, String, Word);
 		/* normally ML_DI_found_match (output_current/12) */
 void	(*MR_DI_read_request_from_socket)(Word, Word *, Integer *);
+
+void	(*MR_trace_func_ptr)(const MR_Stack_Layout_Label *, MR_trace_port,
+		Word, Word, const char *, int);
 
 #ifdef USE_GCC_NONLOCAL_GOTOS
 
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.12
diff -u -u -r1.12 mercury_wrapper.h
--- mercury_wrapper.h	1998/07/31 15:14:21	1.12
+++ mercury_wrapper.h	1998/09/25 04:53:11
@@ -5,15 +5,17 @@
 */
 
 /*
-** mercury_wrapper.h - defines the interface to wrapper.c.
-** See wrapper.c for documentation.
+** mercury_wrapper.h - defines the interface to mercury_wrapper.c.
+** See mercury_wrapper.c for documentation.
 */
 
 #ifndef	MERCURY_WRAPPER_H
 #define	MERCURY_WRAPPER_H
 
-#include <stddef.h>	/* for `size_t' */
-#include "mercury_std.h"	/* for `bool' */
+#include <stddef.h>			/* for `size_t' */
+#include "mercury_std.h"		/* for `bool' */
+#include "mercury_stack_layout.h"	/* for `MR_Stack_Layout_Label' */
+#include "mercury_trace_base.h"		/* for `MR_trace_port' */
 
 /*
 ** mercury_runtime_init() does some stuff to initialize the garbage collector
@@ -85,6 +87,8 @@
 String	(*MR_type_name)(Word);
 		/* normally ML_type_name (type_name/1) */ 
 
+void    (*MR_trace_func_ptr)(const MR_Stack_Layout_Label *, MR_trace_port,
+                Word, Word, const char *, int);
 
 extern	void		do_init_modules(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 scripts
Index: scripts/c2init.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/c2init.in,v
retrieving revision 1.16
diff -u -u -r1.16 c2init.in
--- c2init.in	1998/07/03 02:35:49	1.16
+++ c2init.in	1998/09/25 04:41:09
@@ -29,6 +29,9 @@
 		tracing to print (partial) stack traces, and to print the
 		values of variables in ancestors of the current call, even
 		in grades in which this not normally possible.
+	-t, --trace
+		Enable execution tracing in the generated executable.
+		Implies -i.
 	-l, --library
 		Don't generate a \`main()' function.
 		Instead, generate a function
@@ -60,43 +63,79 @@
 maxcalls=40
 defentry=mercury__main_2_0
 init_opt=""
+trace_opt=""
 library_opt=""
 extra_inits_opt=""
+
+# include the file `init_grade_options.sh-subr'
+ at INIT_GRADE_OPTIONS@
+
 while true; do
 	case "$1" in
 	-c|--max-calls)
 		maxcalls="$2"; shift; shift;;
+
 	-i|--include-initialization-code)
 		init_opt="-i"; shift;;
+
+	-t|--trace)
+		trace_opt="-t"; shift;;
+
 	-l|--library)
 		library_opt="-l"; shift;;
+
 	-l-|--no-library)
 		library_opt=""; shift;;
+
 	-w|--entry-point)
 		defentry="$2"; shift; shift;;
+
 	-x|--extra-inits)
 		extra_inits_opt="-x"; shift;;
+
 	-x-|--no-extra-inits)
 		extra_inits_opt=""; shift;;
+
 	-h|--help|"-?")
 		echo "$Help"
 		exit 0;;
+
+	# include the file `parse_grade_options.sh-subr'
+	@PARSE_GRADE_OPTIONS@
+
 	--)
 		shift; break;;
+
 	-*)
 		echo "`basename $0`: invalid option \`$1'" 1>&2;
 		echo "Try \`$0 --help' for help." 1>&2;
 		exit 1;;
+
 	*)
 		break;;
 	esac
 done
 
+case $require_tracing in
+	true)
+		trace_opt="-t"
+esac
+
+case $stack_trace in
+	true)
+		init_opt="-i"
+esac
+
+case "$trace_opt" in
+	-t)
+		init_opt="-i"
+esac
+
 case $# in
-	0) exec $MKINIT -c"$maxcalls" $init_opt $library_opt \
+	0) exec $MKINIT -c"$maxcalls" $init_opt $trace_opt $library_opt \
 		-w"$defentry" $extra_inits_opt $MERCURY_MOD_LIB_MODS
 	   ;;
-	*) exec $MKINIT -c"$maxcalls" $init_opt $library_opt \
+	*) exec $MKINIT -c"$maxcalls" $init_opt $trace_opt $library_opt \
 		-w"$defentry" $extra_inits_opt "$@" $MERCURY_MOD_LIB_MODS
 	   ;;
 esac
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.46
diff -u -u -r1.46 ml.in
--- ml.in	1998/07/27 01:05:17	1.46
+++ ml.in	1998/09/28 05:51:14
@@ -85,6 +85,13 @@
 SHLIB_RPATH_SEP=${MERCURY_SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"}
 SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS@"}
 
+# If you change these, you will also need to change Mmake.common.in
+# and tools/bootcheck.
+RT_LIB_NAME=mer_rt
+STD_LIB_NAME=mer_std
+TRACE_LIB_NAME=mer_trace
+BROWSER_LIB_NAME=mer_browser
+
 verbose=false
 case $FULLARCH in
 	*-win95|*-winnt|*-win32|*-cygwin32)
@@ -366,13 +373,16 @@
 
 case $mercury_libs in
 	shared)
-		LIBS=${MERCURY_LIBS="-lmercury -lmer $LIBGC $STDLIBS"}
+		LIBS=${MERCURY_LIBS="-l$TRACE_LIB_NAME -l$BROWSER_LIB_NAME -l$STD_LIB_NAME -l$RT_LIB_NAME $LIBGC $STDLIBS"}
 		merc_shlib_dirs="$merc_shlib_dirs $LIBDIR/$GRADE/$FULLARCH"
 		merc_shlib_dirs="$merc_shlib_dirs $LIBDIR/$FULLARCH"
 		;;
-	static) LIBS=${MERCURY_LIBS="\
-			$LIBDIR/$GRADE/$FULLARCH/libmercury.a \
-			$LIBDIR/$GRADE/$FULLARCH/libmer.a \
+	static)
+		LIBS=${MERCURY_LIBS="\
+			$LIBDIR/$GRADE/$FULLARCH/lib$TRACE_LIB_NAME.a \
+			$LIBDIR/$GRADE/$FULLARCH/lib$BROWSER_LIB_NAME.a \
+			$LIBDIR/$GRADE/$FULLARCH/lib$STD_LIB_NAME.a \
+			$LIBDIR/$GRADE/$FULLARCH/lib$RT_LIB_NAME.a \
 			$LIBGC_STATIC \
 			$STDLIBS"}
 		merc_shlib_dirs=""
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.9
diff -u -u -r1.9 Mmakefile
--- Mmakefile	1998/08/30 04:04:47	1.9
+++ Mmakefile	1998/09/28 06:34:42
@@ -18,7 +18,7 @@
 #	queens
 
 MCFLAGS = --trace all
-C2INITFLAGS = -i
+C2INITFLAGS = -t
 
 # Base grades `jump' and `fast' cannot be used with
 # stack layouts (which are required for tracing).
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
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/bootcheck
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.63
diff -u -u -r1.63 bootcheck
--- bootcheck	1998/09/11 01:06:42	1.63
+++ bootcheck	1998/09/28 06:19:49
@@ -74,6 +74,13 @@
 test_sicstus=false
 use_subdirs=${MMAKE_USE_SUBDIRS=no}
 
+# If you change these, you will also need to change script/ml.in
+# and Mmake.common.in.
+RT_LIB_NAME=mer_rt
+STD_LIB_NAME=mer_std
+TRACE_LIB_NAME=mer_trace
+BROWSER_LIB_NAME=mer_browser
+
 while [ $# -gt 0 ]; do
 	case "$1" in
 
@@ -251,7 +258,13 @@
 	ln -s $root/library/[m-z]*.m .
 	ln -s $root/library/*.nl .
 	cp $root/library/Mmake* .
-	ln -s $root/library/libmercury.init .
+	ln -s $root/library/$STD_LIB_NAME.init .
+	cd $root/stage2_sicstus
+	mkdir browser
+	cd browser
+	ln -s $root/browser/*.m .
+	cp $root/browser/Mmake* .
+	ln -s $root/browser/$BROWSER_LIB_NAME.init .
 	cd $root/stage2_sicstus
 	if "$copy_runtime"
 	then
@@ -266,8 +279,16 @@
 		cp $root/runtime/Mmake* .
 		ln -s $root/runtime/machdeps .
 		cd $root/stage2_sicstus
+		rm trace
+		mkdir trace
+		cd trace
+		ln -s $root/trace/*.h .
+		ln -s $root/trace/*.c .
+		cp $root/trace/Mmake* .
+		cd $root/stage2_sicstus
 	else
 		ln -s $root/runtime .
+		ln -s $root/trace .
 	fi
 	if "$copy_boehm_gc"
 	then
@@ -289,7 +310,7 @@
 	ln -s $root/doc .
 	ln -s $root/scripts .
 	ln -s $root/util .
-	if test "$copy_profiler" = "true"
+	if "$copy_profiler"
 	then
 		mkdir profiler
 		cd profiler
@@ -316,8 +337,8 @@
 
 	if
 		cd stage2_sicstus &&
-		mmake $mmake_opts depend_library depend_compiler \
-			depend_profiler &&
+		mmake $mmake_opts depend_library depend_browser \
+			depend_compiler depend_profiler &&
 		cd $root
 	then
 		echo "building of SICStus stage 2 dependencies successful"
@@ -344,6 +365,17 @@
 	cd $root
 
 	if
+		cd stage2_sicstus/browser &&
+		mmake $mmake_opts $jfactor cs
+	then
+		echo "building of SICStus stage 2 browser successful"
+	else
+		echo "building of SICStus stage 2 browser not successful"
+		exit 1
+	fi
+	cd $root
+
+	if
 		cd stage2_sicstus/compiler &&
 		mmake $mmake_opts $jfactor cs
 	then
@@ -362,7 +394,7 @@
 		exec > "$outfile"	# redirect stdout to $outfile
 	fi
 
-	for dir in library compiler; do
+	for dir in library browser compiler; do
 	    for file in stage2/$dir/${cs_subdir}*.c; do
 		diff -u $file \
 			stage2_sicstus/${cs_subdir}$dir/`basename $file` ||
@@ -388,7 +420,6 @@
 		/bin/rm -fr $root/stage2_sicstus/.[a-zA-Z]* < /dev/null
 		exit 0
 	fi
-
 fi
 
 if $do_bootcheck
@@ -399,6 +430,8 @@
 	else
 		cd $root/library;
 		mmake depend
+		cd $root/browser;
+		mmake depend
 		cd $root/compiler;
 		mmake depend
 		cd $root/profiler;
@@ -458,10 +491,19 @@
 	ln -s $root/library/[m-z]*.m .
 	ln -s $root/library/*.nl .
 	cp $root/library/Mmake* .
-	ln -s $root/library/libmercury.init .
+	ln -s $root/library/$STD_LIB_NAME.init .
+	cd $root/stage2
+	mkdir browser
+	cd browser
+	ln -s $root/browser/*.m .
+	cp $root/browser/Mmake* .
+	ln -s $root/browser/$BROWSER_LIB_NAME.init .
 	cd $root/stage2
-	if test "$copy_runtime" = "true"
+	if "$copy_runtime"
 	then
+		# Remove symbolic link to the stage 1 runtime if it's present,
+		# which it can be with the -2 option.
+		rm runtime
 		mkdir runtime
 		cd runtime
 		ln -s $root/runtime/*.h .
@@ -470,10 +512,18 @@
 		cp $root/runtime/Mmake* .
 		ln -s $root/runtime/machdeps .
 		cd $root/stage2
+		rm trace
+		mkdir trace
+		cd trace
+		ln -s $root/trace/*.h .
+		ln -s $root/trace/*.c .
+		cp $root/trace/Mmake* .
+		cd $root/stage2
 	else
 		ln -s $root/runtime .
+		ln -s $root/trace .
 	fi
-	if test "$copy_boehm_gc" = "true"
+	if "$copy_boehm_gc"
 	then
 		mkdir boehm_gc
 		cd boehm_gc
@@ -491,7 +541,7 @@
 	ln -s $root/doc .
 	ln -s $root/scripts .
 	ln -s $root/util .
-	if test "$copy_profiler" = "true"
+	if "$copy_profiler"
 	then
 		mkdir profiler
 		cd profiler
@@ -524,8 +574,8 @@
 		exit 1
 	fi
 
-	if (cd stage2 && mmake $mmake_opts depend_library depend_compiler \
-		depend_profiler)
+	if (cd stage2 && mmake $mmake_opts depend_library depend_browser \
+		depend_compiler depend_profiler)
 	then
 		echo "building of stage 2 dependencies successful"
 	else
@@ -548,6 +598,22 @@
 		exit 1
 	fi
 
+	if (cd stage2/browser && mmake $mmake_opts $jfactor RM_C=: library)
+	then
+		echo "building of stage 2 browser successful"
+	else
+		echo "building of stage 2 browser not successful"
+		exit 1
+	fi
+
+	if (cd stage2 && mmake $mmake_opts $jfactor trace)
+	then
+		echo "building of stage 2 trace successful"
+	else
+		echo "building of stage 2 trace not successful"
+		exit 1
+	fi
+
 	if (cd stage2/compiler && mmake $mmake_opts $jfactor RM_C=: mercury_compile)
 	then
 		echo "building of stage 2 compiler successful"
@@ -617,11 +683,18 @@
 	ln -s $root/library/[m-z]*.m .
 	ln -s $root/library/*.nl .
 	cp $root/library/Mmake* .
-	ln -s $root/library/libmercury.init .
+	ln -s $root/library/$STD_LIB_NAME.init .
 	cd $root/stage3
+	mkdir browser
+	cd browser
+	ln -s $root/browser/*.m .
+	cp $root/browser/Mmake* .
+	ln -s $root/browser/$BROWSER_LIB_NAME.init .
+	cd $root/stage3
 	ln -s $root/boehm_gc .
 	ln -s $root/doc .
 	ln -s $root/runtime .
+	ln -s $root/trace .
 	ln -s $root/scripts .
 	ln -s $root/util .
 	ln -s $root/profiler .
@@ -639,7 +712,7 @@
 	cd $root
 	set -x
 
-	if (cd stage3 && mmake $mmake_opts depend_library depend_compiler)
+	if (cd stage3 && mmake $mmake_opts depend_library depend_browser depend_compiler)
 	then
 		echo "building of stage 3 dependencies successful"
 	else
@@ -677,6 +750,14 @@
 		/bin/rm -f $root/stage2/compiler/[t-z]*.o < /dev/null
 	fi
 
+	if (cd stage3/browser && mmake $mmake_opts $jfactor cs)
+	then
+		echo "building of stage 3 browser successful"
+	else
+		echo "building of stage 3 browser not successful"
+		exit 1
+	fi
+
 	if (cd stage3/compiler && mmake $mmake_opts $jfactor cs)
 	then
 		echo "building of stage 3 compiler successful"
@@ -693,7 +774,7 @@
 		exec > "$outfile"	# redirect stdout to $outfile
 	fi
 
-	for dir in library compiler; do
+	for dir in library browser compiler; do
 		for file in stage2/$dir/${cs_subdir}*.c; do
 		    diff -u $file stage3/$dir/${cs_subdir}`basename $file` ||
 			diff_status=1
@@ -744,13 +825,17 @@
 		MERCURY_INT_DIR=$root/library
 		export MERCURY_INT_DIR
 
-		MERCURY_LIBS="$root/library/libmercury.a
-			$root/runtime/libmer.a
+		MERCURY_LIBS="
+			$root/trace/lib$TRACE_LIB_NAME.a
+			$root/browser/lib$BROWSER_LIB_NAME.a
+			$root/library/lib$STD_LIB_NAME.a
+			$root/runtime/lib$RT_LIB_NAME.a
 			$root/boehm_gc/libgc.a
 			-lm"
 		export MERCURY_LIBS
 
-		MERCURY_ALL_C_INCL_DIRS="-I$root/runtime
+		MERCURY_ALL_C_INCL_DIRS="-I$root/trace
+			-I$root/runtime
 			-I$root/boehm_gc
 			-I$root/boehm_gc/include"
 		export MERCURY_ALL_C_INCL_DIRS
@@ -758,8 +843,10 @@
 		MMAKE_DIR="$root/scripts"
 		export MMAKE_DIR
 
-		MERCURY_MOD_LIB_MODS="$root/runtime/runtime.init
-			$root/library/libmercury.init"
+		MERCURY_MOD_LIB_MODS="$root/trace/$TRACE_LIB_NAME.init
+			$root/browser/$BROWSER_LIB_NAME.init
+			$root/library/$STD_LIB_NAME.init
+			$root/runtime/$RT_LIB_NAME.init"
 		export MERCURY_MOD_LIB_MODS
 
 			# for mkinit, mmc, mgnuc, ml etc
@@ -769,13 +856,17 @@
 		MERCURY_INT_DIR=$root/stage2/library
 		export MERCURY_INT_DIR
 
-		MERCURY_LIBS="$root/stage2/library/libmercury.a
-			$root/stage2/runtime/libmer.a
+		MERCURY_LIBS="
+			$root/stage2/trace/lib$TRACE_LIB_NAME.a
+			$root/stage2/browser/lib$BROWSER_LIB_NAME.a
+			$root/stage2/library/lib$STD_LIB_NAME.a
+			$root/stage2/runtime/lib$RT_LIB_NAME.a
 			$root/stage2/boehm_gc/libgc.a
 			-lm"
 		export MERCURY_LIBS
 
-		MERCURY_ALL_C_INCL_DIRS="-I$root/stage2/runtime
+		MERCURY_ALL_C_INCL_DIRS="-I$root/stage2/trace
+			-I$root/stage2/runtime
 			-I$root/stage2/boehm_gc
 			-I$root/stage2/boehm_gc/include"
 		export MERCURY_ALL_C_INCL_DIRS
@@ -783,8 +874,10 @@
 		MMAKE_DIR="$root/stage2/scripts"
 		export MMAKE_DIR
 
-		MERCURY_MOD_LIB_MODS="$root/stage2/runtime/runtime.init
-			$root/stage2/library/libmercury.init"
+		MERCURY_MOD_LIB_MODS="$root/stage2/trace/$TRACE_LIB_NAME.init
+			$root/stage2/browser/$BROWSER_LIB_NAME.init
+			$root/stage2/library/$STD_LIB_NAME.init
+			$root/stage2/runtime/$RT_LIB_NAME.init"
 		export MERCURY_MOD_LIB_MODS
 
 			# for mkinit, mmc, mgnuc, ml etc
cvs diff: Diffing trace
Index: trace/Mmakefile
===================================================================
RCS file: Mmakefile
diff -N Mmakefile
--- /dev/null	Wed May 28 10:49:58 1997
+++ Mmakefile	Fri Sep 25 17:40:24 1998
@@ -0,0 +1,148 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 1998 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.
+#-----------------------------------------------------------------------------#
+
+# Mmakefile for the Mercury trace library, which contains the runtime
+# system components that are needed only if some procedures are traced.
+
+MAIN_TARGET=trace
+
+MERCURY_DIR=..
+include $(MERCURY_DIR)/Mmake.common
+
+#-----------------------------------------------------------------------------#
+
+CFLAGS		= -I$(MERCURY_DIR)/browser -I$(MERCURY_DIR)/library \
+		  -I$(MERCURY_DIR)/runtime -I$(MERCURY_DIR)/boehm_gc \
+		  -g $(DLL_CFLAGS) $(EXTRA_CFLAGS)
+MGNUC		= MERCURY_C_INCL_DIR=. $(SCRIPTS_DIR)/mgnuc
+MGNUCFLAGS	= --no-ansi $(EXTRA_MGNUCFLAGS) $(CFLAGS)
+MOD2C		= $(SCRIPTS_DIR)/mod2c
+
+#-----------------------------------------------------------------------------#
+
+# keep this list in alphabetical order, please
+HDRS		=	\
+			mercury_trace.h			\
+			mercury_trace_external.h 	\
+			mercury_trace_internal.h
+
+# keep this list in alphabetical order, please
+CFILES		= 	\
+			mercury_trace.c			\
+			mercury_trace_external.c 	\
+			mercury_trace_internal.c
+
+OBJS		= $(CFILES:.c=.o)
+PIC_OBJS	= $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS))
+
+LDFLAGS		= -L$(BROWSER_DIR) -L$(LIBRARY_DIR) \
+			-L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR)
+LDLIBS		= -l$(BROWSER_LIB_NAME) -l$(STD_LIB_NAME) -l$(RT_LIB_NAME) \
+		` case "$(GRADE)" in 					\
+		    *.gc*.prof*)	echo "-lgc_prof" ;;		\
+		    *.gc*)		echo "-lgc" ;;			\
+		  esac							\
+		`
+THREADLIBS	= \
+		` case "$(GRADE)" in					\
+		    *.par*) echo "-lpthread" ;;				\
+		  esac							\
+		`
+
+#-----------------------------------------------------------------------------#
+
+# Stuff for Windows DLLs
+
+ifeq ($(USE_DLLS),yes)
+
+DLL_CFLAGS	= -Dlib$(TRACE_LIB_NAME)_DEFINE_DLL
+
+# the following header files are created automatically by Makefile.DLLs
+LIBMER_DLL_H	 = lib$(TRACE_LIB_NAME)_dll.h
+LIBMER_GLOBALS_H = lib$(TRACE_LIB_NAME)_globals.h
+
+include $(MERCURY_DIR)/Makefile.DLLs
+
+else
+
+DLL_CFLAGS =
+LIBMER_DLL_H =
+LIBMER_GLOBALS_H =
+DLL_DEF_LIB =
+
+endif
+
+#-----------------------------------------------------------------------------#
+
+$(OBJS) $(PIC_OBJS): $(HDRS)
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: trace
+trace: lib$(TRACE_LIB_NAME).a lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB)
+trace: $(LIBMER_DLL_H) $(LIBMER_GLOBALS_H)
+
+lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a: $(OBJS)
+	rm -f lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a
+	ar cr lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
+	$(RANLIB) lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a
+
+lib$(TRACE_LIB_NAME).so: $(PIC_OBJS)
+	$(LINK_SHARED_OBJ) -o lib$(TRACE_LIB_NAME).so $(PIC_OBJS)	\
+		$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_GC_LIB_DIR)	\
+		$(LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
+		$(SHARED_LIBS)
+
+.PHONY: cs
+cs: $(CFILES)
+
+tags: $(CFILES) $(HDRS)
+	ctags $(CFILES) $(HDRS)
+
+.PHONY: check_headers
+check_headers:
+	for file in $(HDRS); do \
+		echo "$$file"; \
+		echo "#include \"$$file\"" > tmp.c; \
+		$(MGNUC) $(MGNUCFLAGS) -c tmp.c || exit 1; \
+	done
+	rm -f tmp.c
+
+#-----------------------------------------------------------------------------#
+
+# installation rules
+
+.PHONY: install
+install: install_headers install_lib
+
+.PHONY: install_headers
+install_headers: $(HDRS) $(LIBMER_GLOBALS_H)
+	cp `vpath_find $(HDRS) $(LIBMER_GLOBALS_H)` $(INSTALL_INC_DIR)
+
+.PHONY: install_lib
+install_lib: lib$(TRACE_LIB_NAME).a lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB)
+	-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
+	cp `vpath_find lib$(TRACE_LIB_NAME).a \
+		lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
+		$(INSTALL_MERC_LIB_DIR)
+
+#-----------------------------------------------------------------------------#
+
+# prevent Mmake from removing C files
+RM_C=:
+
+#-----------------------------------------------------------------------------#
+
+clean: clean_o
+
+.PHONY: clean_o
+clean_o:
+	rm -f $(OBJS) $(PIC_OBJS) 
+
+realclean:
+	rm -f lib$(TRACE_LIB_NAME).a lib$(TRACE_LIB_NAME).so
+
+#-----------------------------------------------------------------------------#
Index: trace/mercury_trace.c
===================================================================
RCS file: mercury_trace.c
diff -N mercury_trace.c
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_trace.c	Thu Sep 24 22:33:37 1998
<moved from runtime with some changes, the diff follows>
diff -u ~/mer/ws1/trace/mercury_trace.c ~/mer/ws2/runtime/mercury_trace.c
--- /mnt/munkora/home/staff/zs/mer/ws1/trace/mercury_trace.c	Thu Sep 24 22:33:37 1998
+++ /mnt/munkora/home/staff/zs/mer/ws2/runtime/mercury_trace.c	Fri Aug  7 12:09:50 1998
@@ -48,9 +48,13 @@
 */
 
 void
-MR_trace_real(const MR_Stack_Layout_Label *layout, MR_trace_port port,
-	Unsigned seqno, Unsigned depth, const char *path, int max_r_num)
+MR_trace(const MR_Stack_Layout_Label *layout, MR_trace_port port,
+	Unsigned seqno, Unsigned depth, const char *path, int max_r_num,
+	bool trace_this)
 {
+	if (! (MR_trace_enabled && trace_this))
+		return;
+
 	MR_trace_event_number++;
 
 	switch (MR_trace_ctrl.MR_trace_cmd) {
Index: trace/mercury_trace.h
===================================================================
RCS file: mercury_trace.h
diff -N mercury_trace.h
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_trace.h	Thu Sep 24 22:34:11 1998
<moved from runtime with some changes, the diff follows>
diff -u ~/mer/ws1/trace/mercury_trace.h ~/mer/ws2/runtime/mercury_trace.h
--- /mnt/munkora/home/staff/zs/mer/ws1/trace/mercury_trace.h	Thu Sep 24 22:34:11 1998
+++ /mnt/munkora/home/staff/zs/mer/ws2/runtime/mercury_trace.h	Mon Jul 20 20:26:34 1998
@@ -35,13 +35,30 @@
 #define	MR_trace_incr_depth()	(++MR_trace_call_depth)
 #define	MR_trace_reset_depth(d)	do { MR_trace_call_depth = (d); } while (0)
 
-extern	void	MR_trace_real(
+/*
+** This enum should EXACTLY match the definition of the `trace_port_type' type
+** in library/debugger_interface.
+*/
+typedef	enum {
+	MR_PORT_CALL,
+	MR_PORT_EXIT,
+	MR_PORT_FAIL,
+	MR_PORT_THEN,
+	MR_PORT_ELSE,
+	MR_PORT_DISJ,
+	MR_PORT_SWITCH,
+	MR_PORT_PRAGMA_FIRST,
+	MR_PORT_PRAGMA_LATER
+} MR_trace_port;
+
+extern	void	MR_trace(
 	const MR_Stack_Layout_Label *,	/* layout info for the event */
 	MR_trace_port,
 	Word,			/* call sequence number */
 	Word,			/* call depth */
 	const char *,		/* path to event goal within procedure */
-	int);			/* highest numbered rN register in use */
+	int,			/* highest numbered rN register in use */
+	bool);			/* is this event supposed to be traced */
 
 /* The interface between the debuggers and the tracing subsystem. */
 
Index: trace/mercury_trace_external.c
===================================================================
RCS file: mercury_trace_external.c
diff -N mercury_trace_external.c
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_trace_external.c	Thu Sep 24 20:19:22 1998
<moved from runtime with no changes>
Index: trace/mercury_trace_external.h
===================================================================
RCS file: mercury_trace_external.h
diff -N mercury_trace_external.h
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_trace_external.h	Thu Sep 24 20:19:23 1998
<moved from runtime with no changes>
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: mercury_trace_internal.c
diff -N mercury_trace_internal.c
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_trace_internal.c	Thu Sep 24 20:19:23 1998
<moved from runtime with no changes>
Index: trace/mercury_trace_internal.h
===================================================================
RCS file: mercury_trace_internal.h
diff -N mercury_trace_internal.h
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_trace_internal.h	Thu Sep 24 20:19:23 1998
<moved from runtime with no changes>
cvs diff: Diffing trial
cvs diff: Diffing util
Index: util/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/util/Mmakefile,v
retrieving revision 1.2
diff -u -u -r1.2 Mmakefile
--- Mmakefile	1997/11/24 14:55:43	1.2
+++ Mmakefile	1998/09/28 06:48:08
@@ -1,5 +1,5 @@
 #-----------------------------------------------------------------------------#
-# Copyright (C) 1995-1997 The University of Melbourne.
+# Copyright (C) 1995-1998 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.
 #-----------------------------------------------------------------------------#
@@ -16,14 +16,14 @@
 #-----------------------------------------------------------------------------#
 
 MGNUC   = MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(SCRIPTS_DIR)/mgnuc
-CFLAGS	= -I$(RUNTIME_DIR) $(EXTRA_CFLAGS)
+CFLAGS	= -I$(RUNTIME_DIR) $(EXTRA_CFLAGS) -O0
 # we need -I ../runtime for "mercury_getopt.h"
+# the -O0 is to get around a stupid compiler bug on cyclone
 
 PROGS=mkinit mdemangle
 
 #-----------------------------------------------------------------------------#
 
-all: $(PROGS)
+all:	$(PROGS)
 
 .c:
 	$(MGNUC) --grade $(GRADE) $(CFLAGS) -o $@ $<
Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.40
diff -u -u -r1.40 mkinit.c
--- mkinit.c	1998/08/11 06:23:29	1.40
+++ mkinit.c	1998/09/28 06:48:37
@@ -44,6 +44,7 @@
 static bool output_main_func = TRUE;
 static bool c_files_contain_extra_inits = FALSE;
 static bool need_initialization_code = FALSE;
+static bool need_tracing = FALSE;
 
 static int num_modules = 0;
 static int num_errors = 0;
@@ -146,6 +147,7 @@
 	"	MR_DI_found_match = ML_DI_found_match;\n"
 	"	MR_DI_read_request_from_socket = ML_DI_read_request_from_socket;\n"
 	"#endif\n"
+	"	MR_trace_func_ptr = %s;\n"
 	"#if defined(USE_GCC_NONLOCAL_GOTOS) && !defined(USE_ASM_LABELS)\n"
 	"	do_init_modules();\n"
 	"#endif\n"
@@ -260,7 +262,7 @@
 parse_options(int argc, char *argv[])
 {
 	int	c;
-	while ((c = getopt(argc, argv, "c:ilw:x")) != EOF) {
+	while ((c = getopt(argc, argv, "c:iltw:x")) != EOF) {
 		switch (c) {
 		case 'c':
 			if (sscanf(optarg, "%d", &maxcalls) != 1)
@@ -275,6 +277,11 @@
 			output_main_func = FALSE;
 			break;
 
+		case 't':
+			need_tracing = TRUE;
+			need_initialization_code = TRUE;
+			break;
+
 		case 'w':
 			entry_point = optarg;
 			break;
@@ -297,7 +304,7 @@
 usage(void)
 {
 	fprintf(stderr,
-		"Usage: mkinit [-c maxcalls] [-w entry] [-l] [-x] files...\n");
+		"Usage: mkinit [-c maxcalls] [-w entry] [-i] [-l] [-t] [-x] files...\n");
 	exit(1);
 }
 
@@ -367,7 +374,10 @@
 static void 
 output_main(void)
 {
-	printf(mercury_funcs, entry_point, entry_point);
+	const char *trace_func;
+
+	trace_func = need_tracing ? "MR_trace_real" : "MR_trace_fake";
+	printf(mercury_funcs, entry_point, trace_func, entry_point);
 	if (output_main_func) {
 		fputs(main_func, stdout);
 	}



More information about the developers mailing list