Split the existing browser library into two libraries, by making the

Estimated hours taken: 10
Branches: main

Split the existing browser library into two libraries, by making the
program_representation module into its own library. This is useful because
the compiler refers to program_representation.m, whose code thus needs to be
linked into compiler executables even if the compiler isn't compiled with
debugging enabled. By creating a new library for this module, we avoid any
chance of the linker dragging in the rest of the modules in the browser
library. (This is a problem with an upcoming diff.).

The name of the new library is "mdbcomp", because the intention is that it
contain code that is shared between the debugger and the compiler. This means
mostly the definitions of data structures that the compiler generates for the
debugger, and the predicates that operate on them.

Mmake.common.in:
	Allow MDB_COMP_ as a prefix for symbol names in the browser directory.

Mmake.workspace:
	Add a make variable holding for the name of the new library, and
	add the name to the relevant lists of libraries.

	Avoid duplicating the lists of filenames that need to be updated
	when adding new libraries or changing their names.

Mmakefile:
	Use make variables to refer to library names.

browser/mdbcomp.m:
browser/mer_mdbcomp.m:
	Add these files as the top modules of the new library.

browser/program_representation.m:
	Make program_representation.m a submodule of mdbcomp, not mdb.

browser/program_representation.m:
browser/browser_info.m:
	Move a predicate from program_representation.m to browser_info.m
	to avoid the mdbcomp library depend on the browser library, since
	this would negate the point of the exercise.

browser/mdb.m:
	Delete program_representation.m from the list of submodules.

browser/Mmakefile:
	Update this file to handle the new module.

browser/Mercury.options:
	Mention the new module.

browser/*.m:
	Update the lists of imported modules. Import only one browser module
	per line.

compiler/notes/overall_design.html:
	Document the new library.

compiler/compile_target_code.m:
	Add the mdbcomp library to the list of libraries we need to link with.

compiler/prog_rep.m:
trace/mercury_trace_internal.c:
	Import program_representation.m by its new name.

scripts/c2init.in:
	Centralize knowledge about which files need to be updated when the list
	of libraries changes here.

scripts/c2init.in:
scripts/ml.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/linear:
tools/lml:
	Update the list of libraries programs are linked with.
This commit is contained in:
Zoltan Somogyi
2003-10-27 06:00:50 +00:00
parent 7ca7d11e24
commit ecdc285bc7
26 changed files with 291 additions and 128 deletions

View File

@@ -261,7 +261,7 @@ OBJ_CHECKS = $(CHECK_OBJS:%=%.obj_check)
# (the `runtime' and `trace' directories)
# `ML_' for stuff in the Mercury standard library
# (the `library' directory)
# `MDB_' for stuff in the browser
# `MDB_' and `MDBCOMP_'for stuff in the browser
# (the `browser' directory)
# `GC_' for stuff in the Boehm et al conservative garbage collector
# (the `boehm_gc' directory)
@@ -293,9 +293,9 @@ endif
ifeq ("$(ALLOW_BROWSER_PREFIX)","yes")
BROWSER_MACRO_PREFIX_EXPRS = \
-e '^MDB_'
-e '^MDB_' -e '^MDBCOMP_'
BROWSER_OBJ_PREFIX_EXPRS = \
-e '^MDB_' -e '^mdb_'
-e '^MDB_' -e '^MDBCOMP_' -e '^mdb_' -e '^mdbcomp_'
else
BROWSER_MACRO_PREFIX_EXPRS =
BROWSER_OBJ_PREFIX_EXPRS =

View File

@@ -73,13 +73,13 @@ MPS_GC_OBJ_DIR=$(MPS_GC_DIR)/$(MPS_PFM)/$(MPS_VARIETY)
# 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
# compiler/compile_target_code.m, scripts/ml.in, scripts/c2init.in,
# tools/bootcheck, tools/binary, tools/binary_step and tools/linear.
# If you change these, you will also need to change the files indicated
# in scripts/c2init.in.
RT_LIB_NAME = mer_rt
STD_LIB_NAME = mer_std
TRACE_LIB_NAME = mer_trace
BROWSER_LIB_NAME = mer_browser
MDBCOMP_LIB_NAME = mer_mdbcomp
ANALYSIS_LIB_NAME = mer_analysis
# This specifies the path to the so_locations file (or its equivalent),
@@ -110,7 +110,8 @@ endif
MCFLAGS += --no-mercury-stdlib-dir -I$(LIBRARY_DIR)
MGNUCFLAGS += --no-mercury-stdlib-dir
C2INITFLAGS += --trace-init-file $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init
C2INITFLAGS += --trace-init-file $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init \
--trace-init-file $(BROWSER_DIR)/$(MDBCOMP_LIB_NAME).init
C2INITARGS += $(LIBRARY_DIR)/$(STD_LIB_NAME).init \
$(RUNTIME_DIR)/$(RT_LIB_NAME).init
MLFLAGS += --no-mercury-stdlib-dir
@@ -180,7 +181,8 @@ ifneq ($(LINK_RUNTIME_ONLY),yes)
STATIC_STD_LIBS = $(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A
ifneq ($(LINK_STDLIB_ONLY),yes)
STATIC_TRACE_LIBS = $(TRACE_DIR)/lib$(TRACE_LIB_NAME).$A \
$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A
$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A \
$(BROWSER_DIR)/lib$(MDBCOMP_LIB_NAME).$A
endif
endif
endif
@@ -197,7 +199,8 @@ LINK_RT_LIB_OPTS = -l$(RT_LIB_NAME)
ifneq ($(LINK_RUNTIME_ONLY),yes)
LINK_STD_LIB_OPTS = -l$(STD_LIB_NAME)
ifneq ($(LINK_STDLIB_ONLY),yes)
LINK_TRACE_LIB_OPTS = -l$(TRACE_LIB_NAME) -l$(BROWSER_LIB_NAME)
LINK_TRACE_LIB_OPTS = -l$(TRACE_LIB_NAME) -l$(BROWSER_LIB_NAME) \
-l$(MDBCOMP_LIB_NAME)
endif
endif
endif

View File

@@ -51,6 +51,15 @@ SUBSUBDIR_MMAKE = PATH=../../scripts:../../util:$$PATH \
GENERATED_DOCS = README INSTALL WORK_IN_PROGRESS TODO
# If you change these, you will also need to change the files indicated
# in scripts/c2init.in.
RT_LIB_NAME = mer_rt
STD_LIB_NAME = mer_std
TRACE_LIB_NAME = mer_trace
BROWSER_LIB_NAME = mer_browser
MDBCOMP_LIB_NAME = mer_mdbcomp
ANALYSIS_LIB_NAME = mer_analysis
#-----------------------------------------------------------------------------#
# `mmake dep' ensures that the .dep files exist;
@@ -61,33 +70,39 @@ dep: dep_library dep_browser dep_analysis dep_compiler \
dep_profiler dep_deep_profiler
.PHONY: dep_library
dep_library: library/$(deps_subdir)mer_std.dep
dep_library: library/$(deps_subdir)$(STD_LIB_NAME).dep
library/$(deps_subdir)mer_std.dep:
library/$(deps_subdir)$(STD_LIB_NAME).dep:
+cd library && $(SUBDIR_MMAKE) depend
.PHONY: dep_browser
dep_browser: browser/$(deps_subdir)mer_browser.dep
dep_browser: \
browser/$(deps_subdir)$(BROWSER_LIB_NAME).dep \
browser/$(deps_subdir)$(MDBCOMP_LIB_NAME).dep
browser/$(deps_subdir)mer_browser.dep:
+cd browser && $(SUBDIR_MMAKE) depend
browser/$(deps_subdir)$(BROWSER_LIB_NAME).dep:
+cd browser && $(SUBDIR_MMAKE) $(BROWSER_LIB_NAME).depend
browser/$(deps_subdir)$(MDBCOMP_LIB_NAME).dep:
+cd browser && $(SUBDIR_MMAKE) $(MDBCOMP_LIB_NAME).depend
.PHONY: dep_analysis
dep_analysis: analysis/$(deps_subdir)mer_analysis.dep
dep_analysis: analysis/$(deps_subdir)$(ANALYSIS_LIB_NAME).dep
analysis/$(deps_subdir)mer_analysis.dep:
analysis/$(deps_subdir)$(ANALYSIS_LIB_NAME).dep:
+cd analysis && $(SUBDIR_MMAKE) depend
.PHONY: dep_compiler
dep_compiler: compiler/$(deps_subdir)top_level.dep
compiler/$(deps_subdir)top_level.dep: library/$(deps_subdir)mer_std.dep
compiler/$(deps_subdir)top_level.dep: library/$(deps_subdir)$(STD_LIB_NAME).dep
+cd compiler && $(SUBDIR_MMAKE) depend
.PHONY: dep_profiler
dep_profiler: profiler/$(deps_subdir)mercury_profile.dep
profiler/$(deps_subdir)mercury_profile.dep: library/$(deps_subdir)mer_std.dep
profiler/$(deps_subdir)mercury_profile.dep: \
library/$(deps_subdir)$(STD_LIB_NAME).dep
+cd profiler && $(SUBDIR_MMAKE) depend
.PHONY: dep_deep_profiler
@@ -98,10 +113,12 @@ else
dep_deep_profiler:
endif
deep_profiler/$(deps_subdir)mdprof_cgi.dep: library/$(deps_subdir)mer_std.dep
deep_profiler/$(deps_subdir)mdprof_cgi.dep: \
library/$(deps_subdir)$(STD_LIB_NAME).dep
+cd deep_profiler && $(SUBDIR_MMAKE) mdprof_cgi.depend
deep_profiler/$(deps_subdir)mdprof_test.dep: library/$(deps_subdir)mer_std.dep
deep_profiler/$(deps_subdir)mdprof_test.dep: \
library/$(deps_subdir)$(STD_LIB_NAME).dep
+cd deep_profiler && $(SUBDIR_MMAKE) mdprof_test.depend
# depend_library MUST be done before depend_compiler and depend_profiler
@@ -298,7 +315,8 @@ tar: $(GENERATED_DOCS)
+cd library && $(SUBDIR_MMAKE) depend
+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 browser && $(SUBDIR_MMAKE) all-ints cs \
$(BROWSER_LIB_NAME).init $(MDBCOMP_LIB_NAME).init tags
+cd trace && $(SUBDIR_MMAKE) cs
+cd analysis && $(SUBDIR_MMAKE) depend
+cd analysis && $(SUBDIR_MMAKE) all-ints cs tags

View File

@@ -1,5 +1,5 @@
#-----------------------------------------------------------------------------#
# Copyright (C) 2002 University of Melbourne.
# Copyright (C) 2002-2003 University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
@@ -7,3 +7,4 @@
#-----------------------------------------------------------------------------#
MCFLAGS-mer_browser = --no-warn-nothing-exported
MCFLAGS-mer_mdbcomp = --no-warn-nothing-exported

View File

@@ -34,7 +34,16 @@ include $(MERCURY_DIR)/Mmake.common
include Mercury.options
MAIN_TARGET=library
MERCURY_MAIN_MODULES=$(BROWSER_LIB_NAME) browse_test declarative_test
MERCURY_MAIN_LIB_MODULES=$(BROWSER_LIB_NAME) $(MDBCOMP_LIB_NAME)
MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES) browse_test declarative_test
DEPENDS = $(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
INTS = $(patsubst %,%.int,$(MERCURY_MAIN_MODULES))
INT3S = $(patsubst %,%.int3,$(MERCURY_MAIN_MODULES))
LIBS = $(patsubst %,lib%,$(MERCURY_MAIN_LIB_MODULES))
CHECKS = $(patsubst %,%.check,$(MERCURY_MAIN_LIB_MODULES))
#-----------------------------------------------------------------------------#
@@ -60,6 +69,7 @@ LN = ln
ifeq ($(USE_DLLS),yes)
# XXX what do we need here for MDCOMP_LIB_NAME?
DLL_CFLAGS = -Dlib$(BROWSER_LIB_NAME)_DEFINE_DLL
include $(MERCURY_DIR)/Makefile.DLLs
@@ -75,13 +85,15 @@ endif
# targets
.PHONY: all
all : library browse_test declarative_test
.PHONY: library
library: $(LIBS)
.PHONY: all
all: library browse_test declarative_test
DEPENDS = $(BROWSER_LIB_NAME).depend browse_test.depend declarative_test.depend
.PHONY: depend
depend : $(DEPENDS)
$(DEPENDS) : Mercury.modules
depend: $(DEPENDS)
$(DEPENDS): Mercury.modules
# This directory contains source files for which the module
# name doesn't match the file name, so smart recompilation
@@ -91,65 +103,66 @@ Mercury.modules:
$(MC) $(ALL_MCFLAGS) -f *.m
.PHONY: check
check : $(BROWSER_LIB_NAME).check
check: $(CHECKS)
.PHONY: all-ints
all-ints: ints int3s
.PHONY: ints
ints : $(BROWSER_LIB_NAME).ints \
browse_test.ints declarative_test.ints
ints: $(INTS)
.PHONY: int3s
int3s : $(BROWSER_LIB_NAME).int3s
int3s: $(INT3S)
#-----------------------------------------------------------------------------#
tags : $(MTAGS) $($(BROWSER_LIB_NAME).ms)
$(MTAGS) $($(BROWSER_LIB_NAME).ms) ../library/*.m
tags: $(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms)
$(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms) \
../library/*.m
$(BROWSER_LIB_NAME).stats : $(COMPILER_DIR)/source_stats.awk \
$($(BROWSER_LIB_NAME).ms)
$(BROWSER_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
$($(BROWSER_LIB_NAME).ms)
awk -f $(COMPILER_DIR)/source_stats.awk \
`vpath_find $($(BROWSER_LIB_NAME).ms)` > $@
$(MDCOMP_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
$($(MDCOMP_LIB_NAME).ms)
awk -f $(COMPILER_DIR)/source_stats.awk \
`vpath_find $($(MDCOMP_LIB_NAME).ms)` > $@
#-----------------------------------------------------------------------------#
.PHONY: dates
dates :
touch $($(BROWSER_LIB_NAME).dates)
dates:
touch $($(BROWSER_LIB_NAME).dates) $($(MDBCOMP_LIB_NAME).dates)
#-----------------------------------------------------------------------------#
.PHONY: os cs ss ils
ifeq ($(MMAKE_USE_MMC_MAKE),no)
os: $($(BROWSER_LIB_NAME).os)
cs: $($(BROWSER_LIB_NAME).cs)
ss: $($(BROWSER_LIB_NAME).ss)
ils: $($(BROWSER_LIB_NAME).ils)
os: $($(BROWSER_LIB_NAME).os) $($(MDBCOMP_LIB_NAME).os)
cs: $($(BROWSER_LIB_NAME).cs) $($(MDBCOMP_LIB_NAME).cs)
ss: $($(BROWSER_LIB_NAME).ss) $($(MDBCOMP_LIB_NAME).ss)
ils: $($(BROWSER_LIB_NAME).ils) $($(MDBCOMP_LIB_NAME).ils)
else
os: $(BROWSER_LIB_NAME).os
cs: $(BROWSER_LIB_NAME).cs
ss: $(BROWSER_LIB_NAME).ss
ils: $(BROWSER_LIB_NAME).ils
os: $(BROWSER_LIB_NAME).os $(MDBCOMP_LIB_NAME).os
cs: $(BROWSER_LIB_NAME).cs $(MDBCOMP_LIB_NAME).cs
ss: $(BROWSER_LIB_NAME).ss $(MDBCOMP_LIB_NAME).ss
ils: $(BROWSER_LIB_NAME).ils $(MDBCOMP_LIB_NAME).ils
endif
#-----------------------------------------------------------------------------#
.PHONY: library
library: lib$(BROWSER_LIB_NAME)
# Ensure we recompile mdb__version if VERSION is changed.
$(os_subdir)mdb.o \
$(os_subdir)mdb.pic_o \
$(os_subdir)mdbcomp.o \
$(os_subdir)mdbcomp.pic_o \
: $(RUNTIME_DIR)/mercury_conf.h
#-----------------------------------------------------------------------------#
# In the past we generated libmdb.* and then linked
# libmer_browser.* to the files.
realclean_local:
rm -rf libmdb.so libmdb.a mdb.init
rm -f Mercury.modules tags
#-----------------------------------------------------------------------------#
@@ -177,18 +190,24 @@ install_library:
else
.PHONY: install_init
install_init: $(BROWSER_LIB_NAME).init install_dirs
install_init: $(BROWSER_LIB_NAME).init $(MDBCOMP_LIB_NAME).init install_dirs
cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
cp `vpath_find $(MDBCOMP_LIB_NAME).init` $(INSTALL_MODULE_DIR)
.PHONY: install_library
install_library: lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) install_dirs
install_library: \
lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
lib$(MDBCOMP_LIB_NAME).$A \
lib$(MDBCOMP_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
install_dirs
cp `vpath_find lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
cp `vpath_find lib$(MDBCOMP_LIB_NAME).$A \
lib$(MDBCOMP_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(BROWSER_LIB_NAME).$A
$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(MDBCOMP_LIB_NAME).$A
endif

View File

@@ -13,6 +13,10 @@
:- module mdb__browser_info.
:- interface.
:- import_module mdbcomp.
:- import_module mdbcomp__program_representation.
:- import_module bool, list, std_util, io.
:- type browser_term
@@ -122,6 +126,8 @@
:- func browser_info__get_num_printed_io_actions(browser_persistent_state)
= int.
:- pred convert_dirs_to_term_path(list(dir)::in, term_path::out) is det.
%---------------------------------------------------------------------------%
% An abstract data type that holds persistent browser settings.
@@ -600,3 +606,13 @@ pretty_value(BrowserDb, Univ0) = Value :-
Value = univ_value(Univ).
%---------------------------------------------------------------------------%
convert_dirs_to_term_path([], []).
convert_dirs_to_term_path([child_num(N) | Dirs], [N | TermPath]) :-
convert_dirs_to_term_path(Dirs, TermPath).
convert_dirs_to_term_path([child_name(_) | _], _) :-
error("convert_dirs_to_term_path: not in canonical form").
convert_dirs_to_term_path([parent | _], _) :-
error("convert_dirs_to_term_path: not in canonical form").
%---------------------------------------------------------------------------%

View File

@@ -11,9 +11,13 @@
%
:- module mdb__declarative_analyser.
:- interface.
:- import_module mdb__declarative_debugger, mdb__program_representation.
:- import_module mdb__declarative_debugger.
:- import_module mdb__io_action.
:- import_module mdbcomp__program_representation.
:- import_module list, std_util.
% This typeclass defines how EDTs may be accessed by this module.

View File

@@ -35,9 +35,13 @@
%-----------------------------------------------------------------------------%
:- module mdb__declarative_debugger.
:- interface.
:- import_module mdb__declarative_execution, mdb__program_representation.
:- import_module mdb__declarative_execution.
:- import_module mdb__io_action.
:- import_module mdbcomp__program_representation.
:- import_module io, bool, list, std_util, string.
% This type represents the possible truth values for nodes
@@ -240,8 +244,11 @@
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module mdb__declarative_analyser, mdb__declarative_oracle.
:- import_module mdb__declarative_analyser.
:- import_module mdb__declarative_oracle.
:- import_module mdb__declarative_tree.
:- import_module exception, int, map.
unravel_decl_atom(DeclAtom, TraceAtom, IoActions) :-

View File

@@ -1,5 +1,5 @@
%-----------------------------------------------------------------------------%
% Copyright (C) 1999-2002 The University of Melbourne.
% Copyright (C) 1999-2003 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.
%-----------------------------------------------------------------------------%
@@ -15,8 +15,12 @@
% to produce a bug diagnosis.
:- module mdb__declarative_execution.
:- interface.
:- import_module mdb__program_representation, mdb__util.
:- import_module mdb__util.
:- import_module mdbcomp__program_representation.
:- import_module list, std_util, string, io, bool.
% This type represents a port in the annotated trace.

View File

@@ -11,8 +11,11 @@
%-----------------------------------------------------------------------------%
:- module mdb__declarative_tree.
:- interface.
:- import_module mdb__declarative_analyser, mdb__declarative_execution.
:- import_module mdb__declarative_analyser.
:- import_module mdb__declarative_execution.
% The type of nodes in our implementation of EDTs. The parameter
% is meant to be the type of references to trace nodes. In
@@ -37,8 +40,11 @@
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module mdb__declarative_debugger, mdb__io_action.
:- import_module mdb__program_representation.
:- import_module mdb__declarative_debugger.
:- import_module mdb__io_action.
:- import_module mdbcomp__program_representation.
:- import_module assoc_list, bool, exception, int, list, map, std_util.
:- instance mercury_edt(wrap(S), edt_node(R)) <= annotated_trace(S, R)

View File

@@ -13,8 +13,11 @@
%
:- module mdb__declarative_user.
:- interface.
:- import_module mdb__declarative_debugger.
:- import_module list, io.
:- type user_question(T)
@@ -50,8 +53,14 @@
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module mdb__browser_info, mdb__browse, mdb__io_action, mdb__util.
:- import_module mdb__declarative_execution, mdb__program_representation.
:- import_module mdb__browser_info.
:- import_module mdb__browse.
:- import_module mdb__io_action.
:- import_module mdb__util.
:- import_module mdb__declarative_execution.
:- import_module mdbcomp__program_representation.
:- import_module std_util, char, string, bool, int, deconstruct.
:- type user_state

View File

@@ -8,6 +8,8 @@
:- interface.
:- import_module mdbcomp.
:- pred mdb__version(string::out) is det.
% These interface modules are used directly by the test programs
@@ -21,7 +23,6 @@
:- include_module help.
:- include_module interactive_query.
:- include_module io_action.
:- include_module program_representation.
:- implementation.

45
browser/mdbcomp.m Normal file
View File

@@ -0,0 +1,45 @@
%---------------------------------------------------------------------------%
% Copyright (C) 2003 The University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
%---------------------------------------------------------------------------%
%
% This is the top module of a library that contains information shared
% between the debugger and the compiler. This means mostly the definitions
% of data structures that the compiler generates for the debugger, and
% the predicates that operate on them.
%
% The compiler links in this library in all grades, but links in the mdb
% library (which also in this directory) only when debugging is enabled.
% Therefore the modules of the mdbcomp library should avoid importing any
% module of the mdb library.
:- module mdbcomp.
:- interface.
:- pred mdbcomp__version(string::out) is det.
:- include_module program_representation.
:- implementation.
% See library/library.m for why we implement this predicate this way.
:- pragma foreign_proc("C",
mdbcomp__version(Version::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
MR_ConstString version_string;
version_string = MR_VERSION "", configured for "" MR_FULLARCH;
/*
** Cast away const needed here, because Mercury declares Version
** with type MR_String rather than MR_ConstString.
*/
Version = (MR_String) (MR_Word) version_string;
").
mdbcomp__version("unknown version").
%---------------------------------------------------------------------------%

16
browser/mer_mdbcomp.m Normal file
View File

@@ -0,0 +1,16 @@
%-----------------------------------------------------------------------------%
% Copyright (C) 2003 University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
% File: mer_mdbcomp.m
%
% This file is only present so that the mdbcomp library is
% generated with the correct name.
%-----------------------------------------------------------------------------%
:- module mer_mdbcomp.
:- implementation.
:- import_module mdbcomp.

View File

@@ -29,11 +29,10 @@
%-----------------------------------------------------------------------------%
:- module mdb__program_representation.
:- module mdbcomp__program_representation.
:- interface.
:- import_module mdb__browser_info.
:- import_module char, list, std_util.
% A representation of the goal we execute. These need to be
@@ -202,9 +201,6 @@
:- type term_path == list(int).
:- pred convert_dirs_to_term_path(list(dir), term_path).
:- mode convert_dirs_to_term_path(in, out) is det.
% Returns type_of(_ `with_type` proc_rep), for use in C code.
:- func proc_rep_type = type_desc.
@@ -244,14 +240,6 @@ call_is_primitive(ModuleName, PredName) :-
ModuleName = "term_size_prof_builtin"
).
convert_dirs_to_term_path([], []).
convert_dirs_to_term_path([child_num(N) | Dirs], [N | TermPath]) :-
convert_dirs_to_term_path(Dirs, TermPath).
convert_dirs_to_term_path([child_name(_) | _], _) :-
error("convert_dirs_to_term_path: not in canonical form").
convert_dirs_to_term_path([parent | _], _) :-
error("convert_dirs_to_term_path: not in canonical form").
:- pragma export(proc_rep_type = out, "ML_proc_rep_type").
proc_rep_type = type_of(_ `with_type` proc_rep).

View File

@@ -947,7 +947,8 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName,
StdLibDir/"modules"/"mer_std.init" |
InitFileNamesList0] },
{ TraceInitFileNamesList =
[StdLibDir/"modules"/"mer_browser.init" |
[StdLibDir/"modules"/"mer_browser.init",
StdLibDir/"modules"/"mer_mdbcomp.init" |
TraceInitFileNamesList0] }
;
{ MaybeStdLibDir = no },
@@ -1354,29 +1355,33 @@ get_mercury_std_libs(TargetType, StdLibDir, StdLibs) -->
("libmer_trace" ++ LibExt)) ++
" " ++
quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
("libmer_browser" ++ LibExt)) },
("libmer_browser" ++ LibExt)) ++
" " ++
quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
("libmer_mdbcomp" ++ LibExt)) },
make_link_lib(TargetType, "mer_trace", TraceLib),
make_link_lib(TargetType, "mer_browser", BrowserLib),
make_link_lib(TargetType, "mer_mdbcomp", MdbCompLib),
{ SharedTraceLibs = string__join_list(" ",
[TraceLib, BrowserLib]) }
[TraceLib, BrowserLib, MdbCompLib]) }
),
globals__io_lookup_string_option(mercury_linkage, MercuryLinkage),
( { MercuryLinkage = "static" } ->
{ StdLibs = string__join_list(" ",
[StaticTraceLibs,
quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
("libmer_std" ++ LibExt)),
quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
("libmer_rt" ++ LibExt)),
StaticGCLibs]) }
{ StdLibs = string__join_list(" ",
[StaticTraceLibs,
quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
("libmer_std" ++ LibExt)),
quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
("libmer_rt" ++ LibExt)),
StaticGCLibs]) }
; { MercuryLinkage = "shared" } ->
make_link_lib(TargetType, "mer_std", StdLib),
make_link_lib(TargetType, "mer_rt", RuntimeLib),
{ StdLibs = string__join_list(" ",
[SharedTraceLibs, StdLib, RuntimeLib, SharedGCLibs]) }
make_link_lib(TargetType, "mer_std", StdLib),
make_link_lib(TargetType, "mer_rt", RuntimeLib),
{ StdLibs = string__join_list(" ",
[SharedTraceLibs, StdLib, RuntimeLib, SharedGCLibs]) }
;
{ error("unknown linkage " ++ MercuryLinkage) }
{ error("unknown linkage " ++ MercuryLinkage) }
).
:- pred make_link_lib(linked_target_type::in, string::in, string::out,

View File

@@ -48,7 +48,9 @@ The subdirectories containing major subsystems are as follows:
<li> library: the Mercury standard library (written in Mercury)
<li> compiler: the Mercury compiler (written in Mercury)
<li> trace: the part of the Mercury debugger that is written in C
<li> browser: the part of the Mercury debugger that is written in Mercury
<li> browser: the part of the Mercury debugger that is written in Mercury,
including the library that defines the Mercury data structures generated
by the compiler for the debugger.
<li> profiler: the Mercury profiler (written in Mercury)
<li> extras: additional Mercury libraries. These are distributed
separately from the main Mercury distribution.
@@ -123,8 +125,9 @@ from `configure.in'.
<h2> Libraries and dependencies </h2>
Each major subsystem (except `extras') gets compiled to a single
library or executable program.
Each major subsystem (which doesn't include `extras')
gets compiled to a single library or executable program,
except for the browser directory, which gets compiled to two libraries.
On most systems, mutual recursion between libraries is not very
well supported. On Unix, for static linking you need to list the
@@ -146,6 +149,7 @@ a program in the following order:
<li> the main program object files (e.g. compiler/*.o or profiler/*.o)
<li> trace library (trace/libmer_trace.a)
<li> browser library (browser/libmer_browser.a)
<li> mdbcomp library (browser/libmer_mdbcomp.a)
<li> standard library (library/libmer_std.a)
<li> runtime library (runtime/libmer_rt.a)
<li> Boehm collector (boehm_gc/libgc.a)
@@ -162,6 +166,6 @@ other components.
<hr>
<!---------------------------------------------------------------------------->
Last update was $Date: 2000-08-21 14:49:50 $ by $Author: fjh $@cs.mu.oz.au. <br>
Last update was $Date: 2003-10-27 06:00:38 $ by $Author: zs $@cs.mu.oz.au. <br>
</body>
</html>

View File

@@ -24,8 +24,8 @@
:- import_module hlds__instmap.
:- import_module parse_tree__prog_data.
:- import_module mdb.
:- import_module mdb__program_representation.
:- import_module mdbcomp.
:- import_module mdbcomp__program_representation.
:- import_module list.

View File

@@ -30,13 +30,28 @@ DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
# include the file `canonical_grade.sh-subr'
@CANONICAL_GRADE@
# If you change these, you will also need to change Mmake.workspace,
# compiler/compile_target_code.m, scripts/ml.in, tools/bootcheck,
# tools/binary, tools/binary_step and tools/linear.
# If you change one of these, or if you add a new one, you will also need
# to check the following files to see if corresponding changes are needed
# there as well:
#
# Mmake.workspace
# Mmakefile
# compiler/compile_target_code.m
# scripts/c2init.in
# scripts/ml.in
# tools/bootcheck,
# tools/binary
# tools/binary_step
# tools/linear
# tools/lmc
# tools/lml
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
MDBCOMP_LIB_NAME=mer_mdbcomp
ANALYSIS_LIB_NAME=mer_analysis
MKINIT=${MERCURY_MKINIT=mkinit}
@@ -53,8 +68,10 @@ esac
if [ "$mercury_stdlib_dir" != "" ]
then
MERCURY_MOD_LIB_MODS="$mercury_stdlib_dir/modules/$RT_LIB_NAME.init \
$mercury_stdlib_dir/modules/$STD_LIB_NAME.init"
MERCURY_TRACE_LIB_MODS="$mercury_stdlib_dir/modules/$BROWSER_LIB_NAME.init"
$mercury_stdlib_dir/modules/$STD_LIB_NAME.init"
MERCURY_TRACE_LIB_MODS="\
$mercury_stdlib_dir/modules/$BROWSER_LIB_NAME.init \
$mercury_stdlib_dir/modules/$MDBCOMP_LIB_NAME.init"
fi
MERCURY_TRACE_LIB_MODS="$MERCURY_TRACE_LIB_MODS $trace_init_files"

View File

@@ -88,13 +88,13 @@ DL_LIBRARY="@DL_LIBRARY@"
# Likewise for -lreadline -l{termcap,curses,ncurses}
READLINE_LIBRARIES="@READLINE_LIBRARIES@"
# If you change these, you will also need to change Mmake.workspace,
# compiler/compile_target_code.m, scripts/c2init.in, tools/bootcheck,
# tools/binary, tools/binary_step and tools/linear.
# If you change these, you will also need to change the files indicated
# in scripts/c2init.in.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
MDBCOMP_LIB_NAME=mer_mdbcomp
MAYBE_STATIC_OPT=""
@@ -212,7 +212,8 @@ case $readline in
esac
case $trace in
true) TRACE_LIBS="-l$TRACE_LIB_NAME -l$BROWSER_LIB_NAME"
true) TRACE_LIBS="-l$TRACE_LIB_NAME -l$BROWSER_LIB_NAME \
-l$MDBCOMP_LIB_NAME"
TRACE_LIBS_SYSTEM="$TRACE_LIBS_SYSTEM $READLINE_LIBRARIES"
TRACE_STATIC_LIBS="\
`$FIX_PATH_FOR_LINKER \

View File

@@ -60,9 +60,8 @@ Options:
Execute runtests from the named subdirectory of tests.
"
# If you change this, you will also need to change scripts/ml.in,
# scripts/c2init.in, Mmake.workspace, tools/bootcheck, tools/binary_step
# and tools/linear.
# If you change this, you will also need to change the files indicated
# in scripts/c2init.in.
STD_LIB_NAME=mer_std
set -x

View File

@@ -40,9 +40,8 @@ Options:
Execute runtests from the named subdirectory of tests.
"
# If you change this, you will also need to change scripts/ml.in,
# scripts/c2init.in, Mmake.workspace, tools/bootcheck, tools/binary
# and tools/linear.
# If you change this, you will also need to change the files indicated
# in scripts/c2init.in.
STD_LIB_NAME=mer_std
set -x

View File

@@ -176,13 +176,13 @@ then
write_out_profile_data=false
fi
# If you change these, you will also need to change scripts/ml.in,
# scripts/c2init.in, Mmake.workspace, tools/binary, tools/binary_step
# and tools/linear.
# If you change these, you will also need to change the files indicated
# in scripts/c2init.in.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
MDBCOMP_LIB_NAME=mer_mdbcomp
ANALYSIS_LIB_NAME=mer_analysis
while [ $# -gt 0 ]; do
@@ -520,6 +520,7 @@ then
$LN_S $root/browser/*.m .
cp $root/browser/Mmake* $root/browser/Mercury.options .
$LN_S $root/browser/$BROWSER_LIB_NAME.init .
$LN_S $root/browser/$MDCOMP_LIB_NAME.init .
$LN_S $root/browser/RESERVED_MACRO_NAMES .
cd $root/stage2
mkdir analysis
@@ -853,6 +854,7 @@ then
$LN_S $root/browser/*.m .
cp $root/browser/Mmake* $root/browser/Mercury.options .
$LN_S $root/browser/$BROWSER_LIB_NAME.init .
$LN_S $root/browser/$MDBCOMP_LIB_NAME.init .
cd $root/stage3
mkdir analysis
cd analysis

View File

@@ -43,9 +43,8 @@ Options:
Execute runtests from the named subdirectory of tests.
"
# If you change this, you will also need to change scripts/ml.in,
# scripts/c2init.in, Mmake.workspace, tools/bootcheck, tools/binary
# and tools/binary_step.
# If you change this, you will also need to change the files indicated
# in scripts/c2init.in.
STD_LIB_NAME=mer_std
bootcheck=""

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#---------------------------------------------------------------------------#
# Copyright (C) 2001 The University of Melbourne.
# Copyright (C) 2001, 2003 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.
#---------------------------------------------------------------------------#
@@ -34,7 +34,7 @@ else
echo "$WORKSPACE/boehm_gc does not have a gc library"
fi
MERCURY_LIBS="$WORKSPACE/trace/libmer_trace.a $WORKSPACE/browser/libmer_browser.a $WORKSPACE/library/libmer_std.a $WORKSPACE/runtime/libmer_rt.a $gclib -lm"
MERCURY_LIBS="$WORKSPACE/trace/libmer_trace.a $WORKSPACE/browser/libmer_browser.a $WORKSPACE/browser/libmer_mdbcomp.a $WORKSPACE/library/libmer_std.a $WORKSPACE/runtime/libmer_rt.a $gclib -lm"
export MERCURY_LIBS
PATH="$WORKSPACE/scripts:$WORKSPACE/util:$PATH"

View File

@@ -32,7 +32,7 @@
#include "mdb.browse.mh"
#include "mdb.browser_info.mh"
#include "mdb.program_representation.mh"
#include "mdbcomp.program_representation.mh"
#include <stdio.h>
#include <stdlib.h>