[m-rev.] for review: ssdb compiler scaffolding
Peter Ross
pro at missioncriticalit.com
Wed Oct 3 17:08:47 AEST 2007
Hi,
===================================================================
Estimated hours taken: 4
Branches: main
Initial checkin which is all the scaffolding needed to
support the new source to source mercury debugger (ssdb).
The main addition in this change is the ssdb directory,
which will contain the mer_ssdb library.
Mmake.workspace:
Mmakefile:
configure.in:
Handle the new ssdb directory.
compiler/options.m:
Add the --ssdb and --source-to-source-debug options.
compiler/mercury_compile.m:
Add the ssdb pass (it does nothing at the moment).
compiler/modules.m:
Implicitly import ssdb_builtin when compiling with --ssdb.
mdbcomp/prim_data.m:
Handle ssdb_builtin.
ssdb/Mercury.options:
ssdb/Mmakefile:
ssdb/SSDB_FLAGS.in:
Build system for ssdb directory.
ssdb/mer_ssdb.m:
ssdb/ssdb_builtin.m:
The operations which are needed by the source to source
debugger.
Index: Mmake.workspace
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.workspace,v
retrieving revision 1.26
diff -u -r1.26 Mmake.workspace
--- Mmake.workspace 24 Nov 2006 03:47:46 -0000 1.26
+++ Mmake.workspace 3 Oct 2007 05:17:01 -0000
@@ -51,6 +51,7 @@
TRACE_DIR = $(WORKSPACE)/trace
MDBCOMP_DIR = $(WORKSPACE)/mdbcomp
BROWSER_DIR = $(WORKSPACE)/browser
+SSDB_DIR = $(WORKSPACE)/ssdb
BOEHM_GC_DIR = $(WORKSPACE)/boehm_gc
MPS_GC_DIR = $(WORKSPACE)/mps_gc/code
COMPILER_DIR = $(WORKSPACE)/compiler
@@ -82,6 +83,7 @@
TRACE_LIB_NAME = mer_trace
EVENTSPEC_LIB_NAME = mer_eventspec
BROWSER_LIB_NAME = mer_browser
+SSDB_LIB_NAME = mer_ssdb
MDBCOMP_LIB_NAME = mer_mdbcomp
ANALYSIS_LIB_NAME = mer_analysis
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.124
diff -u -r1.124 Mmakefile
--- Mmakefile 12 Sep 2007 06:20:59 -0000 1.124
+++ Mmakefile 3 Oct 2007 05:17:01 -0000
@@ -32,6 +32,7 @@
trace \
mdbcomp \
browser \
+ ssdb \
analysis \
compiler \
doc \
@@ -62,6 +63,7 @@
EVENTSPEC_LIB_NAME = mer_eventspec
MDBCOMP_LIB_NAME = mer_mdbcomp
BROWSER_LIB_NAME = mer_browser
+SSDB_LIB_NAME = mer_ssdb
ANALYSIS_LIB_NAME = mer_analysis
#-----------------------------------------------------------------------------#
@@ -71,7 +73,7 @@
.PHONY: dep
dep: dep_library dep_mdbcomp dep_browser dep_analysis dep_compiler \
- dep_slice dep_profiler dep_deep_profiler
+ dep_slice dep_profiler dep_deep_profiler dep_ssdb
.PHONY: dep_library
dep_library: library/$(deps_subdir)$(STD_LIB_NAME).dep
@@ -105,6 +107,13 @@
browser/$(deps_subdir)declarative_test.dep:
+cd browser && $(SUBDIR_MMAKE) declarative_test.depend
+.PHONY: dep_ssdb
+dep_ssdb: \
+ ssdb/$(deps_subdir)$(BROWSER_LIB_NAME).dep
+
+ssdb/$(deps_subdir)$(SSDB_LIB_NAME).dep:
+ +cd ssdb && $(SUBDIR_MMAKE) $(SSDB_LIB_NAME).depend
+
.PHONY: dep_analysis
dep_analysis: analysis/$(deps_subdir)$(ANALYSIS_LIB_NAME).dep
@@ -158,7 +167,7 @@
# depend_library MUST be done before depend_compiler and depend_profiler
.PHONY: depend
-depend: depend_library depend_mdbcomp depend_browser \
+depend: depend_library depend_mdbcomp depend_browser depend_ssdb \
depend_analysis depend_compiler \
depend_slice depend_profiler depend_deep_profiler
@@ -174,6 +183,10 @@
depend_browser:
+cd browser && $(SUBDIR_MMAKE) depend
+.PHONY: depend_ssdb
+depend_ssdb:
+ +cd ssdb && $(SUBDIR_MMAKE) depend
+
.PHONY: depend_analysis
depend_analysis:
+cd analysis && $(SUBDIR_MMAKE) depend
@@ -232,9 +245,13 @@
browser: dep_browser scripts util boehm_gc runtime library mdbcomp
+cd browser && $(SUBDIR_MMAKE)
+.PHONY: ssdb
+ssdb: scripts boehm_gc runtime library mdbcomp browser
+ +cd ssdb && $(SUBDIR_MMAKE)
+
.PHONY: analysis
analysis: dep_analysis scripts util boehm_gc runtime library mdbcomp browser \
- trace
+ trace ssdb
+cd analysis && $(SUBDIR_MMAKE)
.PHONY: runtime
@@ -243,12 +260,12 @@
.PHONY: compiler
compiler: dep_compiler scripts util boehm_gc runtime library \
- mdbcomp browser trace analysis
+ mdbcomp browser trace ssdb analysis
+cd compiler && $(SUBDIR_MMAKE)
.PHONY: libmmc
libmmc: dep_compiler scripts util boehm_gc runtime library \
- mdbcomp browser trace analysis
+ mdbcomp browser trace ssdb analysis
+cd compiler && $(SUBDIR_MMAKE) libmmc
.PHONY: doc
@@ -257,24 +274,24 @@
.PHONY: slice
slice: dep_slice scripts util boehm_gc runtime library \
- mdbcomp browser trace
+ mdbcomp browser trace ssdb
+cd slice && $(SUBDIR_MMAKE)
.PHONY: profiler
profiler: dep_profiler scripts util boehm_gc runtime library \
- mdbcomp browser trace
+ mdbcomp browser trace ssdb
+cd profiler && $(SUBDIR_MMAKE)
.PHONY: deep_profiler
deep_profiler: dep_deep_profiler scripts util boehm_gc runtime library \
- mdbcomp browser trace
+ mdbcomp browser trace ssdb
+cd deep_profiler && $(SUBDIR_MMAKE)
#-----------------------------------------------------------------------------#
.PHONY: tags
tags: tags_compiler tags_library tags_mdbcomp tags_browser tags_analysis \
- tags_slice tags_profiler tags_deep_profiler
+ tags_slice tags_profiler tags_deep_profiler tags_ssdb
.PHONY: tags_compiler
tags_compiler:
@@ -308,12 +325,16 @@
tags_deep_profiler:
+cd deep_profiler && $(SUBDIR_MMAKE) tags
+.PHONY: tags_ssdb
+tags_ssdb:
+ +cd ssdb && $(SUBDIR_MMAKE) tags
+
#-----------------------------------------------------------------------------#
# Remove from each of the listed directories mmc-generated files that don't
# belong there.
cleanint:
- for dir in library mdbcomp browser analysis compiler \
+ for dir in library mdbcomp browser ssdb analysis compiler \
slice profiler deep_profiler; \
do \
echo Looking for inappropriate files in the $$dir directory: ; \
@@ -388,6 +409,9 @@
+cd browser && $(SUBDIR_MMAKE) depend
+cd browser && $(SUBDIR_MMAKE) all-ints cs \
$(BROWSER_LIB_NAME).init tags
+ +cd ssdb && $(SUBDIR_MMAKE) depend
+ +cd ssdb && $(SUBDIR_MMAKE) all-ints cs \
+ $(SSDB_LIB_NAME).init tags
+cd trace && $(SUBDIR_MMAKE) cs
+cd analysis && $(SUBDIR_MMAKE) depend
+cd analysis && $(SUBDIR_MMAKE) all-ints cs tags
@@ -494,7 +518,7 @@
install_main: all \
install_scripts install_util install_runtime install_boehm_gc \
install_library install_mdbcomp install_browser install_trace \
- install_compiler install_slice install_profiler \
+ install_compiler install_slice install_profiler install_ssdb \
install_deep_profiler install_doc install_config
.PHONY: install_scripts
@@ -536,6 +560,10 @@
install_browser: dep_browser browser
+cd browser && $(SUBDIR_MMAKE) install
+.PHONY: install_ssdb
+install_ssdb: dep_ssdb ssdb
+ +cd ssdb && $(SUBDIR_MMAKE) install
+
.PHONY: install_compiler
install_compiler: dep_compiler compiler
+cd compiler && $(SUBDIR_MMAKE) install
@@ -597,6 +625,11 @@
depend && \
$(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS \
install_library ) && \
+ ( cd tmp_dir/ssdb && \
+ $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS \
+ depend && \
+ $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS \
+ install_library ) && \
( cd tmp_dir/trace && \
$(SUBDIR_MMAKE) MC=mmc GRADE=$$grade WORKSPACE=$$TWS \
install_lib ) && \
@@ -633,6 +666,10 @@
touch analysis/*.date*
chmod +w analysis/*.dep
touch analysis/*.dep
+ touch ssdb/*.date*
+ touch ssdb/*.optdate
+ chmod +w ssdb/*.dep
+ touch ssdb/*.dep
touch compiler/*.date*
chmod +w compiler/*.dep
touch compiler/*.dep
@@ -652,6 +689,7 @@
touch library/*.c
touch mdbcomp/*.c
touch browser/*.c
+ touch ssdb/*.c
touch trace/*.c
touch compiler/*.c
touch slice/*.c
@@ -685,7 +723,7 @@
.PHONY: clean_subdirs
clean_subdirs:
rm -rf runtime/tmp_dir library/tmp_dir mdbcomp/tmp_dir \
- browser/tmp_dir trace/tmp_dir
+ browser/tmp_dir ssdb/tmp_dir trace/tmp_dir
+for dir in $(SUBDIRS); do \
if [ "$$dir" = scripts ]; then continue; fi; \
(cd $$dir; $(SUBDIR_MMAKE) clean) \
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.500
diff -u -r1.500 configure.in
--- configure.in 12 Sep 2007 06:20:59 -0000 1.500
+++ configure.in 3 Oct 2007 05:17:01 -0000
@@ -4602,6 +4602,7 @@
library/LIB_FLAGS
mdbcomp/MDBCOMP_FLAGS
browser/MDB_FLAGS
+ssdb/SSDB_FLAGS
analysis/ANALYSIS_FLAGS
slice/SLICE_FLAGS
profiler/PROF_FLAGS
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.449
diff -u -r1.449 mercury_compile.m
--- compiler/mercury_compile.m 22 Aug 2007 07:14:34 -0000 1.449
+++ compiler/mercury_compile.m 3 Oct 2007 05:17:04 -0000
@@ -2563,6 +2563,9 @@
maybe_termination2(Verbose, Stats, !HLDS, !IO),
maybe_dump_hlds(!.HLDS, 121, "termination2", !DumpInfo, !IO),
+ maybe_ssdb(Verbose, Stats, !HLDS, !IO),
+ maybe_dump_hlds(!.HLDS, 123, "ssdb", !DumpInfo, !IO),
+
maybe_type_ctor_infos(Verbose, Stats, !HLDS, !IO),
maybe_dump_hlds(!.HLDS, 125, "type_ctor_infos", !DumpInfo, !IO),
@@ -3174,6 +3177,26 @@
;
true
).
+
+:- pred maybe_ssdb(bool::in, bool::in,
+ module_info::in, module_info::out, io::di, io::uo) is det.
+
+maybe_ssdb(Verbose, Stats, !HLDS, !IO) :-
+ globals.io_lookup_bool_option(source_to_source_debug, SSDB, !IO),
+ (
+ SSDB = yes,
+ maybe_write_string(Verbose,
+ "% Apply debugging source to source transformation ...\n", !IO),
+ /* XXX for the moment we do nothing.
+ process_all_nonimported_procs(
+ update_module_io(ssdebug.process_proc), !HLDS, !IO),
+ */
+ maybe_write_string(Verbose, "% done.\n", !IO),
+ maybe_report_stats(Stats, !IO)
+ ;
+ SSDB = no
+ ).
+
:- pred maybe_analyse_trail_usage(bool::in, bool::in,
module_info::in, module_info::out, io::di, io::uo) is det.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.440
diff -u -r1.440 modules.m
--- compiler/modules.m 7 Sep 2007 15:08:17 -0000 1.440
+++ compiler/modules.m 3 Oct 2007 05:17:05 -0000
@@ -2974,6 +2974,13 @@
!:UseDeps = [MercuryRegionBuiltin | !.UseDeps]
;
UseRegions = no
+ ),
+ globals.lookup_bool_option(Globals, source_to_source_debug, SSDB),
+ (
+ SSDB = yes,
+ !:UseDeps = [mercury_ssdb_builtin_module | !.UseDeps]
+ ;
+ SSDB = no
).
:- pred contains_tabling_pragma(item_list::in) is semidet.
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.585
diff -u -r1.585 options.m
--- compiler/options.m 28 Sep 2007 04:57:52 -0000 1.585
+++ compiler/options.m 3 Oct 2007 05:17:06 -0000
@@ -312,6 +312,7 @@
; extend_stacks_when_needed
; stack_segments
; use_regions
+ ; source_to_source_debug
% Data representation compilation model options
; tags
@@ -1119,6 +1120,7 @@
minimal_model_debug - bool(no),
single_prec_float - bool(no),
type_layout - bool(yes),
+ source_to_source_debug - bool(no),
% Data representation compilation model options
pic_reg - bool(no),
@@ -1903,6 +1905,8 @@
long_option("extend-stacks-when-needed", extend_stacks_when_needed).
long_option("stack-segments", stack_segments).
long_option("use-regions", use_regions).
+long_option("ssdb", source_to_source_debug).
+long_option("source-to-source-debug", source_to_source_debug).
% Data representation options
long_option("use-minimal-model-stack_copy", use_minimal_model_stack_copy).
long_option("use-minimal-model-own-stacks", use_minimal_model_own_stacks).
Index: mdbcomp/prim_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/mdbcomp/prim_data.m,v
retrieving revision 1.24
diff -u -r1.24 prim_data.m
--- mdbcomp/prim_data.m 12 Sep 2007 06:21:14 -0000 1.24
+++ mdbcomp/prim_data.m 3 Oct 2007 05:17:07 -0000
@@ -231,6 +231,11 @@
%
:- func mercury_par_builtin_module = sym_name.
+ % Returns the name of the module containing the builtins for the
+ % source-to-source debugger.
+ %
+:- func mercury_ssdb_builtin_module = sym_name.
+
% Returns the sym_name of the module with the given name in the
% Mercury standard library.
%
@@ -320,7 +325,8 @@
mercury_table_builtin_module,
mercury_profiling_builtin_module,
mercury_term_size_prof_builtin_module,
- mercury_par_builtin_module].
+ mercury_par_builtin_module,
+ mercury_ssdb_builtin_module].
% We may eventually want to put the standard library into a package "std":
% mercury_public_builtin_module = qualified(unqualified("std"), "builtin").
@@ -334,6 +340,7 @@
mercury_profiling_builtin_module = unqualified("profiling_builtin").
mercury_term_size_prof_builtin_module = unqualified("term_size_prof_builtin").
mercury_par_builtin_module = unqualified("par_builtin").
+mercury_ssdb_builtin_module = unqualified("ssdb_builtin").
mercury_std_lib_module_name(Name) = Name.
is_std_lib_module_name(SymName, Name) :-
@@ -348,6 +355,7 @@
; Module = mercury_profiling_builtin_module
; Module = mercury_term_size_prof_builtin_module
; Module = mercury_par_builtin_module
+ ; Module = mercury_ssdb_builtin_module
).
non_traced_mercury_builtin_module(Module) :-
@@ -355,4 +363,5 @@
; Module = mercury_profiling_builtin_module
; Module = mercury_term_size_prof_builtin_module
; Module = mercury_par_builtin_module
+ ; Module = mercury_ssdb_builtin_module
).
Index: ssdb/Mercury.options
===================================================================
RCS file: ssdb/Mercury.options
diff -N ssdb/Mercury.options
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ssdb/Mercury.options 3 Oct 2007 05:17:07 -0000
@@ -0,0 +1,17 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 2007 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.
+#-----------------------------------------------------------------------------#
+# Mercury.options - module-specific flags for Mmake and `mmc --make'.
+#-----------------------------------------------------------------------------#
+
+MCFLAGS-mer_ssdb = --no-warn-nothing-exported --no-warn-unused-imports
+
+# XXX This line is needed so that `mmake --use-mmc-make libmer_ssdb'
+# passes `-lmer_mdbcomp' to `mmc --make' in the MLLIBS variable.
+EXTRA_LIBRARIES-libmer_ssdb = mer_mdbcomp
+
+# Whereas these lines are needed for plain `mmake'.
+EXTRA_LIBRARIES-libmer_ssdb.so = mer_mdbcomp
+EXTRA_LIBRARIES-libmer_ssdb.dylib = mer_mdbcomp
Index: ssdb/Mmakefile
===================================================================
RCS file: ssdb/Mmakefile
diff -N ssdb/Mmakefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ssdb/Mmakefile 3 Oct 2007 05:17:07 -0000
@@ -0,0 +1,304 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 2007 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.
+#-----------------------------------------------------------------------------#
+
+# ssdb/Mmakefile - this is the Mmakefile for building the Mercury
+# ssdb library, which also includes other functionality needed
+# by the source to source Mercury debugger.
+
+# 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.
+
+# Specify which files to check for namespace cleanliness, and which name
+# prefixes are allowed.
+
+CHECK_HDRS =
+CHECK_MHDRS = $(mer_ssdb.mhs)
+CHECK_OBJS = $(mer_ssdb.os)
+ALLOW_LIB_PREFIX=yes
+ALLOW_BROWSER_PREFIX=yes
+ALLOW_MDBCOMP_PREFIX=yes
+
+MERCURY_DIR=..
+LINK_STDLIB_ONLY=yes
+include $(MERCURY_DIR)/Mmake.common
+-include Mmake.ssdb.params
+
+# Override the default rule in `mmake --use-mmc-make' that asks `mmc' to
+# create a missing optional params file.
+Mmake.ssdb.params:
+
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include Mercury.options
+
+MAIN_TARGET=main
+
+MERCURY_MAIN_LIB_MODULES=$(SSDB_LIB_NAME)
+MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES)
+
+VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR) $(BROWSER_DIR)
+
+DEPENDS = $(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
+INTS_TARGETS = $(patsubst %,%.ints,$(MERCURY_MAIN_MODULES))
+INT3S_TARGETS = $(patsubst %,%.int3s,$(MERCURY_MAIN_MODULES))
+LIBS = $(patsubst %,lib%,$(MERCURY_MAIN_LIB_MODULES))
+CHECKS = $(patsubst %,%.check,$(MERCURY_MAIN_LIB_MODULES))
+
+#-----------------------------------------------------------------------------#
+
+# 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, or create Mmake.ssdb.params.
+
+CFLAGS += $(DLL_CFLAGS)
+ifeq ($(INSTALLABLE_PREFIX),yes)
+MLFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
+ -R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
+MCFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
+ -R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
+endif
+MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
+ $(READLINE_LIBRARIES)
+
+MCFLAGS += --flags SSDB_FLAGS $(CONFIG_OVERRIDE)
+
+#-----------------------------------------------------------------------------#
+
+# Set the install name for Darwin shared libraries. We disable the
+# --shlib-linker-use-install-name mmc option so that the -install_name linker
+# option is not passed in the .dep files. We do this to avoid a problem when
+# building from the C source distribution: if the C source distribution is
+# generated on a non-Darwin system then the -install_name option is not passed
+# in the .dep files, so it must be passed here, however if a C source
+# distribution is generated on a Darwin system then by default the
+# -install_name option will be passed in the .dep files which will cause it to
+# be passed twice (here and in the .dep files) which is not allowed by the
+# linker, so we disable the mmc option which causes the -install_name option
+# to be passed in the .dep files.
+
+LD_LIBFLAGS-libmer_ssdb.dylib = -install_name \
+ $(FINAL_INSTALL_MERC_LIB_DIR)/libmer_ssdb.dylib
+
+#-----------------------------------------------------------------------------#
+
+JAVACFLAGS = -classpath $(LIBRARY_DIR)
+
+MTAGS = $(SCRIPTS_DIR)/mtags
+
+LN = ln
+
+#-----------------------------------------------------------------------------#
+
+# The IL, Java, Erlang implementations of the standard library are not yet
+# complete, so we need to pass `--allow-stubs' to get them to compile.
+# Since the standard library is compiled with `--halt-at-warn',
+# we also need `--no-warn-stubs'.
+ifneq ("$(filter il% java% erlang%,$(GRADE))","")
+MCFLAGS += --allow-stubs --no-warn-stubs
+endif
+
+#-----------------------------------------------------------------------------#
+
+# Stuff for Windows DLLS using gnu-win32
+
+ifeq ($(USE_DLLS),yes)
+
+# XXX what do we need here for MDBCOMP_LIB_NAME?
+DLL_CFLAGS = -Dlib$(SSDB_LIB_NAME)_DEFINE_DLL
+
+include $(MERCURY_DIR)/Makefile.DLLs
+
+else
+
+DLL_CFLAGS =
+DLL_DEF_LIB =
+
+endif
+
+#-----------------------------------------------------------------------------#
+
+# targets
+
+.PHONY: main
+main: library $(TAGS_FILE_EXISTS)
+
+.PHONY: all
+all: library $(TAGS_FILE_EXISTS) browse_test declarative_test
+
+.PHONY: library
+library: $(LIBS)
+
+.PHONY: depend
+depend: SSDB_FLAGS $(DEPENDS)
+$(DEPENDS): Mercury.modules
+
+.NOTPARALLEL:
+
+# $(SSDB_LIB_NAME).dep $(SSDB_LIB_NAME).depend:
+# $(MCD) $(ALL_GRADEFLAGS) $(ALL_MCDFLAGS) $*
+
+# The need for these dependencies should be obviated by the fact that the
+# mdbcomp directory is brought up-to-date first.
+
+# lib$(SSDB_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
+# lib$(SSDB_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
+# lib$(SSDB_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
+# lib$(SSDB_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
+# lib$(SSDB_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
+# lib$(SSDB_LIB_NAME).cs: lib$(MDBCOMP_LIB_NAME).cs
+# lib$(SSDB_LIB_NAME).ss: lib$(MDBCOMP_LIB_NAME).ss
+# lib$(SSDB_LIB_NAME).ils: lib$(MDBCOMP_LIB_NAME).ils
+# lib$(SSDB_LIB_NAME).javas: lib$(MDBCOMP_LIB_NAME).javas
+# lib$(SSDB_LIB_NAME).check: lib$(MDBCOMP_LIB_NAME).check
+# $($(SSDB_LIB_NAME).ints): $($(MDBCOMP_LIB_NAME).ints)
+# $($(SSDB_LIB_NAME).cs): $($(MDBCOMP_LIB_NAME).cs)
+# $($(SSDB_LIB_NAME).ss): $($(MDBCOMP_LIB_NAME).ss)
+# $($(SSDB_LIB_NAME).ils): $($(MDBCOMP_LIB_NAME).ils)
+# $($(SSDB_LIB_NAME).javas): $($(MDBCOMP_LIB_NAME).java_dates)
+# $($(SSDB_LIB_NAME).c_dates): $($(MDBCOMP_LIB_NAME).c_dates)
+# $($(SSDB_LIB_NAME).s_dates): $($(MDBCOMP_LIB_NAME).s_dates)
+# $($(SSDB_LIB_NAME).il_dates): $($(MDBCOMP_LIB_NAME).il_dates)
+# $($(SSDB_LIB_NAME).java_dates): $($(MDBCOMP_LIB_NAME).java_dates)
+
+# This directory contains source files for which the module
+# name doesn't match the file name, so smart recompilation
+# won't work without the Mercury.modules file.
+.PHONY: Mercury.modules
+Mercury.modules: SSDB_FLAGS
+ $(MC) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) -f *.m
+
+.PHONY: check
+check: $(CHECKS)
+
+.PHONY: all-ints
+all-ints: ints int3s
+
+.PHONY: ints
+ints: $(INTS_TARGETS)
+
+.PHONY: int3s
+int3s: $(INT3S_TARGETS)
+
+#-----------------------------------------------------------------------------#
+
+tags: $(MTAGS) $($(SSDB_LIB_NAME).ms)
+ $(MTAGS) $($(SSDB_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m
+
+.PHONY: tags_file_exists
+tags_file_exists:
+ @if test ! -f tags; then echo making tags; \
+ $(MTAGS) $($(SSDB_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m ; fi
+
+$(SSDB_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
+ $($(SSDB_LIB_NAME).ms)
+ awk -f $(COMPILER_DIR)/source_stats.awk \
+ `vpath_find $($(SSDB_LIB_NAME).ms)` > $@
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: dates
+dates:
+ touch $($(SSDB_LIB_NAME).dates)
+
+#-----------------------------------------------------------------------------#
+
+#
+# Some Java compilers require the Java source files to be put in directories
+# which match their package names. But the Mercury compiler generates them
+# with the package name prefixed to the file name with a ".", not a "/".
+# So we copy the Java source files to where the Java compiler expects them
+# to be.
+#
+# XXX This is a hack. We ought to change the Mercury compiler so that it
+# generates the Java files with the right names in the first place.
+#
+
+mdb/%.java: mdb.%.java
+ [ -d mdb ] || mkdir mdb
+ cp $< $@
+
+RENAMED_JAVAS = $($(SSDB_LIB_NAME).javas:mdb.%.java=mdb/%.java)
+
+RENAMED_CLASSES = $($(SSDB_LIB_NAME).classes:mdb.%.class=mdb/%.class)
+
+.PHONY: javas
+javas: $(RENAMED_JAVAS)
+
+.PHONY: classes
+classes: $(RENAMED_JAVAS)
+ $(JAVAC) $(ALL_JAVACFLAGS) -d $(classes_subdir) $(RENAMED_JAVAS)
+
+#-----------------------------------------------------------------------------#
+
+.PHONY: os cs ss ils
+ifneq ($(MMAKE_USE_MMC_MAKE),yes)
+os: $($(SSDB_LIB_NAME).os)
+cs: $($(SSDB_LIB_NAME).cs)
+ss: $($(SSDB_LIB_NAME).ss)
+ils: $($(SSDB_LIB_NAME).ils)
+else
+os: $(SSDB_LIB_NAME).os
+cs: $(SSDB_LIB_NAME).cs
+ss: $(SSDB_LIB_NAME).ss
+ils: $(SSDB_LIB_NAME).ils
+endif
+
+#-----------------------------------------------------------------------------#
+
+# Ensure we recompile mdb__version if VERSION is changed.
+$(os_subdir)mdb.o \
+$(os_subdir)mdb.pic_o \
+ : $(RUNTIME_DIR)/mercury_conf.h
+
+#-----------------------------------------------------------------------------#
+
+realclean_local:
+ rm -f Mercury.modules tags SSDB_FLAGS SSDB_FLAGS.date
+
+#-----------------------------------------------------------------------------#
+
+# Installation targets
+
+.PHONY: install
+install: install_library
+
+.PHONY: install_dirs
+install_dirs:
+ [ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
+ [ -d $(INSTALL_GRADE_MODULE_DIR) ] || \
+ mkdir -p $(INSTALL_GRADE_MODULE_DIR)
+ [ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
+
+ifneq ("$(filter il% java% erlang%,$(GRADE))","")
+
+# there is no ssdb (YET!) in the .NET, Java, Erlang backends
+
+.PHONY: install_init
+install_init:
+
+.PHONY: install_library
+install_library:
+
+else
+
+.PHONY: install_init
+install_init: $(SSDB_LIB_NAME).init install_dirs
+ cp `vpath_find $(SSDB_LIB_NAME).init` $(INSTALL_GRADE_MODULE_DIR)
+
+.PHONY: install_library
+install_library: lib$(SSDB_LIB_NAME) \
+ install_init \
+ install_dirs
+ cp `vpath_find lib$(SSDB_LIB_NAME).$A \
+ lib$(SSDB_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
+ $(INSTALL_MERC_LIB_DIR)
+ $(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(SSDB_LIB_NAME).$A
+
+endif
Index: ssdb/SSDB_FLAGS.in
===================================================================
RCS file: ssdb/SSDB_FLAGS.in
diff -N ssdb/SSDB_FLAGS.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ssdb/SSDB_FLAGS.in 3 Oct 2007 05:17:07 -0000
@@ -0,0 +1,24 @@
+ at BOOTSTRAP_MC_ARGS@
+--no-infer-all
+--halt-at-warn
+--no-warn-inferred-erroneous
+--no-mercury-stdlib-dir
+--no-shlib-linker-use-install-name
+--force-disable-tracing
+-I../library
+-I../mdbcomp
+-I../browser
+--c-include-directory ../boehm_gc
+--c-include-directory ../boehm_gc/include
+--c-include-directory ../runtime
+--c-include-directory ../library
+--c-include-directory ../library/Mercury/mihs
+--c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mihs
+-L../boehm_gc
+-L../runtime
+-L../library
+-L../trace
+-L../mdbcomp
+-L../browser
+--config-file ../scripts/Mercury.config.bootstrap
Index: ssdb/mer_ssdb.m
===================================================================
RCS file: ssdb/mer_ssdb.m
diff -N ssdb/mer_ssdb.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ssdb/mer_ssdb.m 3 Oct 2007 05:17:07 -0000
@@ -0,0 +1,18 @@
+%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2007 The University of Melbourne.
+% This file may only be copied under the terms of the GNU General
+% Public License - see the file COPYING in the Mercury distribution.
+%-----------------------------------------------------------------------------%
+% File: mer_ssdb.m
+% Main author: petdr
+%
+% This file is only present so that the ssdb library is
+% generated with the correct name.
+%-----------------------------------------------------------------------------%
+:- module mer_ssdb.
+
+:- implementation.
+
+:- import_module ssdb_builtin.
Index: ssdb/ssdb_builtin.m
===================================================================
RCS file: ssdb/ssdb_builtin.m
diff -N ssdb/ssdb_builtin.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ssdb/ssdb_builtin.m 3 Oct 2007 05:17:07 -0000
@@ -0,0 +1,64 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2007 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: ssdb_builtin.m.
+% Author: oannet.
+%
+% This module is automatically imported into every module that is compiled
+% using --source-to-source-debug.
+%
+% It provides the primitives which are needed by this source-to-source
+% transformation to allow debugging.
+%
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%
+
+:- module ssdb_builtin.
+:- interface.
+
+
+:- type ssdb_event_type
+ ---> ssdb_call
+ ; ssdb_exit
+ ; ssdb_redo
+ ; ssdb_fail
+ .
+
+ %
+ % This routine is called at each event that occurs
+ %
+:- impure pred handle_event(ssdb_event_type::in) is det.
+
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module io.
+
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module string.
+
+%----------------------------------------------------------------------------%
+
+ %
+ % For the moment we just write the event out.
+ % Later this will be extended.
+ %
+handle_event(Event) :-
+ promise_impure (
+ trace [io(!IO)] (
+ io.write(Event, !IO),
+ io.nl(!IO)
+ )
+ ).
+
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list