Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introduce two new directories, trace and browser, containing libraries

Estimated hours taken: 10

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:

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

To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list.  Any such calls must be made into
indirect calls via function pointers.

In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library.  This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr.  This global variable
is initialized by the auto-generated *_init.c file.

To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag.  Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.

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.

compiler/mercury_compile.m:
	If we are doing tracing, then pass -t instead of -i to c2init.

compiler/modules.m:
	When generating the .dep file, get the grade flags passed to c2init.

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_handlers.c:
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 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 (!!!).
  • Loading branch information...
commit 8ddce575d4bba36f65205bd5e88fb8ce74a20ade 1 parent b4c5952
Zoltan Somogyi authored
Showing with 1,152 additions and 216 deletions.
  1. +7 −5 Makefile.DLLs
  2. +15 −0 Mmake.common.in
  3. +82 −19 Mmakefile
  4. +188 −0 browser/Mmakefile
  5. +31 −0 browser/browser_library.m
  6. 0  {library → browser}/debugger_interface.m
  7. +281 −0 browser/help.m
  8. +16 −10 compiler/Mmakefile
  9. +1 −1  compiler/mercury_compile.m
  10. +2 −2 compiler/modules.m
  11. +1 −6 doc/Mmakefile
  12. +50 −43 library/Mmakefile
  13. +0 −1  library/library.m
  14. +7 −6 profiler/Mmakefile
  15. +33 −34 runtime/Mmakefile
  16. +9 −1 runtime/mercury_init.h
  17. +1 −1  runtime/mercury_memory.c
  18. +1 −1  runtime/mercury_memory_handlers.c
  19. +0 −2  runtime/mercury_memory_zones.c
  20. +1 −1  runtime/mercury_misc.c
  21. +25 −4 runtime/mercury_trace_base.c
  22. +36 −3 runtime/mercury_trace_base.h
  23. +5 −1 runtime/mercury_wrapper.c
  24. +8 −4 runtime/mercury_wrapper.h
  25. +50 −10 scripts/c2init.in
  26. +14 −4 scripts/ml.in
  27. +1 −1  tests/debugger/Mmakefile
  28. +118 −25 tools/bootcheck
  29. +148 −0 trace/Mmakefile
  30. +2 −6 {runtime → trace}/mercury_trace.c
  31. +2 −19 {runtime → trace}/mercury_trace.h
  32. 0  {runtime → trace}/mercury_trace_external.c
  33. 0  {runtime → trace}/mercury_trace_external.h
  34. 0  {runtime → trace}/mercury_trace_internal.c
  35. 0  {runtime → trace}/mercury_trace_internal.h
  36. +4 −3 util/Mmakefile
  37. +13 −3 util/mkinit.c
View
12 Makefile.DLLs
@@ -1,5 +1,5 @@
#-----------------------------------------------------------------------------#
-# Copyright (C) 1997 The University of Melbourne.
+# Copyright (C) 1997-1998 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
@@ -109,11 +109,13 @@ CYGWIN32_LIBS = $(shell echo \
# 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"
View
15 Mmake.common.in
@@ -164,10 +164,25 @@ INSTALL_SP_ARCH_DIR = $(INSTALL_LIBDIR)/sicstus/$(FULLARCH)
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" (or ".dll") suffix around these names; the initialization files
+# have just a ".init" suffix. (The trace library does not have a .init file,
+# since it contains no Mercury code.)
+#
+# 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
View
101 Mmakefile
@@ -13,7 +13,17 @@ include Mmake.common
#-----------------------------------------------------------------------------#
-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 @@ POSTINSTALL_HACK =
# `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 @@ dep_library: library/$(deps_subdir)library.dep
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 @@ profiler/$(deps_subdir)mercury_profile.dep: library/$(deps_subdir)library.dep
.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:
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 @@ depend_profiler:
.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 @@ boehm_gc: scripts
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_compiler:
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 @@ INSTALL: .INSTALL.in VERSION
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 @@ install: install_main install_grades
.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_util: util
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_boehm_gc: boehm_gc
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 @@ install_profiler: profiler
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 @@ install_grades: scripts dep_library
$(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 @@ install_grades: scripts dep_library
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_files:
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_files:
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 @@ clean: clean_subdirs
.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) \
View
188 browser/Mmakefile
@@ -0,0 +1,188 @@
+#-----------------------------------------------------------------------------#
+# 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
+
+# Ensure we recompile browser_library__version if VERSION is changed.
+$(os_subdir)browser_library.o \
+$(os_subdir)browser_library.pic_o \
+ : $(RUNTIME_DIR)/mercury_conf.h
+
+#-----------------------------------------------------------------------------#
+
+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)
View
31 browser/browser_library.m
@@ -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.
+
+% See 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;
+").
+
+%---------------------------------------------------------------------------%
View
0  library/debugger_interface.m → browser/debugger_interface.m
File renamed without changes
View
281 browser/help.m
@@ -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).
+
+%-----------------------------------------------------------------------------%
View
26 compiler/Mmakefile
@@ -26,23 +26,26 @@ MCOI = MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) \
--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="$(BROWSER_DIR)/$(BROWSER_LIB_NAME).init $(LIBRARY_DIR)/$(STD_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 @@ debug: mercury_compile mercury_compile.sicstus.debug
# 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.
View
2  compiler/mercury_compile.m
@@ -2370,7 +2370,7 @@
join_module_list(Modules, ".m", ["> ", InitCFileName], MkInitCmd0),
globals__io_get_trace_level(TraceLevel),
{ trace_level_trace_interface(TraceLevel, yes) ->
- CmdPrefix = "c2init -i "
+ CmdPrefix = "c2init -t "
;
CmdPrefix = "c2init "
},
View
4 compiler/modules.m
@@ -2424,8 +2424,8 @@
io__write_strings(DepStream, [
InitCFileName, " : ", DepFileName, "\n",
- "\t$(C2INIT) $(ALL_C2INITFLAGS) $(", MakeVarName, ".cs) > ",
- InitCFileName, "\n\n"
+ "\t$(C2INIT) $(ALL_GRADEFLAGS) $(ALL_C2INITFLAGS) $(",
+ MakeVarName, ".cs) > ", InitCFileName, "\n\n"
]),
module_name_to_file_name(SourceModuleName, ".nu", yes, NU_ExeFileName),
View
7 doc/Mmakefile
@@ -95,17 +95,14 @@ mercury_library.info: library.texi
# 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-menu.texi: $(LIBRARY_DIR)/*.m
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) \
;; \
*) \
View
93 library/Mmakefile
@@ -63,37 +63,39 @@ CHECK_TERM_OPTS =
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 @@ MTAGS = $(SCRIPTS_DIR)/mtags
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 @@ NU_OVERRIDING_LIBRARY_QLS = $(NU_OVERRIDING_LIBRARY_NLS:%.nl=$(qls_subdir)%.ql)
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 @@ cs: $(library.cs)
#-----------------------------------------------------------------------------#
-.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
-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
+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
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 @@ clean:
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 @@ install_ints: $(library.ints) $(library.int3s) \
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
View
1  library/library.m
@@ -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,
View
13 profiler/Mmakefile
@@ -28,15 +28,15 @@ MCS = MERCURY_C_INCL_DIR=$(RUNTIME_DIR) \
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 @@ all : mercury_profile
# 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.
View
67 runtime/Mmakefile
@@ -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 @@ HDRS = \
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 @@ CFILES = \
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 @@ THREADLIBS = \
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 @@ $(OBJS) $(PIC_OBJS): $(HDRS) $(MACHHDRS)
#-----------------------------------------------------------------------------#
-.PHONY: lib
-lib: libmer.a libmer.$(EXT_FOR_SHARED_LIB) runtime.init \
- $(LIBMER_DLL_H) $(LIBMER_GLOBALS_H)
+.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)
-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
+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 @@ check_headers:
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 @@ clean_o:
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
#-----------------------------------------------------------------------------#
View
10 runtime/mercury_init.h
@@ -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 @@ extern int mercury_terminate(void);
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 @@ void ML_DI_read_request_from_socket(Word, Word *, Integer *);
/* 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 */
View
2  runtime/mercury_memory.c
@@ -85,7 +85,7 @@
#endif
#include "mercury_imp.h"
-#include "mercury_trace.h"
+#include "mercury_trace_base.h"
#include "mercury_memory_handlers.h"
/*---------------------------------------------------------------------------*/
View
2  runtime/mercury_memory_handlers.c
@@ -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"
View
2  runtime/mercury_memory_zones.c
@@ -44,8 +44,6 @@
#include <sys/ucontext.h>
#endif
-#include "mercury_trace.h"
-
#ifdef MR_THREAD_SAFE
#include "mercury_thread.h"
#endif
View
2  runtime/mercury_misc.c
@@ -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"
View
29 runtime/mercury_trace_base.c
@@ -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"
@@ -90,6 +87,30 @@ Unsigned MR_trace_event_number = 0;
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 when you do so.\n"
+ "If you are using mmake, you can do this by including "
+ "-t in C2INIT_FLAGS.\n");
+ /* XXX refer to the debugging chapter in the user guide */
+ /* when it is written */
+}
+
+void
MR_trace_init(void)
{
#ifdef MR_USE_EXTERNAL_DEBUGGER
View
39 runtime/mercury_trace_base.h
@@ -11,8 +11,41 @@
** 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()
@@ -71,4 +104,4 @@ extern Bool MR_trace_from_full;
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 */
View
6 runtime/mercury_wrapper.c
@@ -37,7 +37,8 @@ ENDINIT
#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) */
@@ -147,6 +148,9 @@ bool (*MR_DI_found_match)(Integer, Integer, Integer, Word, String, String,
/* 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
#define SAFETY_BUFFER_SIZE 1024 /* size of stack safety buffer */
View
12 runtime/mercury_wrapper.h
@@ -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 @@ void (*MR_DI_read_request_from_socket)(Word, Word *, Integer *);
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);
View
60 scripts/c2init.in
@@ -29,6 +29,9 @@ Options:
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,80 @@ MKINIT=${MERCURY_MKINIT=mkinit}
maxcalls=40
defentry=mercury__main_2_0
init_opt=""
+trace_opt=""
library_opt=""
extra_inits_opt=""
+
+# include the file `init_grade_options.sh-subr'
+@INIT_GRADE_OPTIONS@
+
while true; do
case "$1" in
-c|--max-calls)
- maxcalls="$2"; shift; shift;;
+ maxcalls="$2"; shift;;
+
-i|--include-initialization-code)
- init_opt="-i"; shift;;
+ init_opt="-i";;
+
+ -t|--trace)
+ trace_opt="-t";;
+
-l|--library)
- library_opt="-l"; shift;;
+ library_opt="-l";;
+
-l-|--no-library)
- library_opt=""; shift;;
+ library_opt="";;
+
-w|--entry-point)
- defentry="$2"; shift; shift;;
+ defentry="$2"; shift;;
+
-x|--extra-inits)
- extra_inits_opt="-x"; shift;;
+ extra_inits_opt="-x";;
+
-x-|--no-extra-inits)
- extra_inits_opt=""; shift;;
+ extra_inits_opt="";;
+
-h|--help|"-?")
echo "$Help"
exit 0;;
+
+ # include the file `parse_grade_options.sh-subr'
+ @PARSE_GRADE_OPTIONS@
+
--)
- shift; break;;
+ break;;
+
-*)
echo "`basename $0`: invalid option \`$1'" 1>&2;
echo "Try \`$0 --help' for help." 1>&2;
exit 1;;
+
*)
break;;
esac
+ shift
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
View
18 scripts/ml.in
@@ -85,6 +85,13 @@ SHLIB_RPATH_OPT=${MERCURY_SHLIB_RPATH_OPT="@SHLIB_RPATH_OPT@"}
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 @@ LIBDIR_OPTS="$user_libdir_opts $merc_libdir_opts"
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=""
View
2  tests/debugger/Mmakefile
@@ -18,7 +18,7 @@ DEBUGGER_PROGS= \
# queens
MCFLAGS = --trace all
-C2INITFLAGS = -i
+C2INITFLAGS = -t
# Base grades `jump' and `fast' cannot be used with
# stack layouts (which are required for tracing).
View
143 tools/bootcheck
@@ -74,6 +74,13 @@ keep_stage_2_sicstus=false
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 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
/bin/rm -fr $root/stage2_sicstus/.[a-zA-Z]* < /dev/null
exit 0
fi
-
fi
if $do_bootcheck
@@ -399,6 +430,8 @@ then
else
cd $root/library;
mmake depend
+ cd $root/browser;
+ mmake depend
cd $root/compiler;
mmake depend
cd $root/profiler;
@@ -458,10 +491,19 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
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 @@ then
/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 @@ then
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 @@ then
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 @@ then
MMAKE_DIR="$root/scripts"
export MMAKE_DIR
- MERCURY_MOD_LIB_MODS="$root/runtime/runtime.init
- $root/library/libmercury.init"
+ MERCURY_MOD_LIB_MODS="
+ $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 @@ then
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 @@ then
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/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
View
148 trace/Mmakefile
@@ -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
+LIB_DLL_H = lib$(TRACE_LIB_NAME)_dll.h
+LIB_GLOBALS_H = lib$(TRACE_LIB_NAME)_globals.h
+
+include $(MERCURY_DIR)/Makefile.DLLs
+
+else
+
+DLL_CFLAGS =
+LIB_DLL_H =
+LIB_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: $(LIB_DLL_H) $(LIB_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) $(LIB_GLOBALS_H)
+ cp `vpath_find $(HDRS) $(LIB_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
+
+#-----------------------------------------------------------------------------#
View
8 runtime/mercury_trace.c → trace/mercury_trace.c
@@ -48,13 +48,9 @@ static void MR_trace_event_report(const MR_Stack_Layout_Label *layout,
*/
void
-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)
+MR_trace_real(const MR_Stack_Layout_Label *layout, MR_trace_port port,