From ecdc285bc705d08e5dc08a0e88d6fde20c24bd1c Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Mon, 27 Oct 2003 06:00:50 +0000 Subject: [PATCH] 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. --- Mmake.common.in | 6 +- Mmake.workspace | 15 +++-- Mmakefile | 42 ++++++++++---- browser/Mercury.options | 3 +- browser/Mmakefile | 93 ++++++++++++++++++------------ browser/browser_info.m | 16 +++++ browser/declarative_analyser.m | 6 +- browser/declarative_debugger.m | 11 +++- browser/declarative_execution.m | 8 ++- browser/declarative_tree.m | 12 +++- browser/declarative_user.m | 13 ++++- browser/mdb.m | 3 +- browser/mdbcomp.m | 45 +++++++++++++++ browser/mer_mdbcomp.m | 16 +++++ browser/program_representation.m | 14 +---- compiler/compile_target_code.m | 35 ++++++----- compiler/notes/overall_design.html | 12 ++-- compiler/prog_rep.m | 4 +- scripts/c2init.in | 27 +++++++-- scripts/ml.in | 9 +-- tools/binary | 5 +- tools/binary_step | 5 +- tools/bootcheck | 8 ++- tools/linear | 5 +- tools/lml | 4 +- trace/mercury_trace_internal.c | 2 +- 26 files changed, 291 insertions(+), 128 deletions(-) create mode 100644 browser/mdbcomp.m create mode 100644 browser/mer_mdbcomp.m diff --git a/Mmake.common.in b/Mmake.common.in index 3f8d32e0e..a53219dee 100644 --- a/Mmake.common.in +++ b/Mmake.common.in @@ -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 = diff --git a/Mmake.workspace b/Mmake.workspace index 353e94f32..dc23244b1 100644 --- a/Mmake.workspace +++ b/Mmake.workspace @@ -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 diff --git a/Mmakefile b/Mmakefile index a9e31ffb7..40ae65c8e 100644 --- a/Mmakefile +++ b/Mmakefile @@ -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 diff --git a/browser/Mercury.options b/browser/Mercury.options index 4c762d7b8..d65797c0a 100644 --- a/browser/Mercury.options +++ b/browser/Mercury.options @@ -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 diff --git a/browser/Mmakefile b/browser/Mmakefile index d8401c69f..538e747ca 100644 --- a/browser/Mmakefile +++ b/browser/Mmakefile @@ -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 - - diff --git a/browser/browser_info.m b/browser/browser_info.m index 0586694e4..13ff5636b 100644 --- a/browser/browser_info.m +++ b/browser/browser_info.m @@ -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"). + +%---------------------------------------------------------------------------% diff --git a/browser/declarative_analyser.m b/browser/declarative_analyser.m index 7cc195b1d..3ac4d207d 100644 --- a/browser/declarative_analyser.m +++ b/browser/declarative_analyser.m @@ -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. diff --git a/browser/declarative_debugger.m b/browser/declarative_debugger.m index 79e8287da..be81b0951 100644 --- a/browser/declarative_debugger.m +++ b/browser/declarative_debugger.m @@ -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) :- diff --git a/browser/declarative_execution.m b/browser/declarative_execution.m index c03d033f3..e53b37fd3 100644 --- a/browser/declarative_execution.m +++ b/browser/declarative_execution.m @@ -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. diff --git a/browser/declarative_tree.m b/browser/declarative_tree.m index b4da25965..ac439d5be 100644 --- a/browser/declarative_tree.m +++ b/browser/declarative_tree.m @@ -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) diff --git a/browser/declarative_user.m b/browser/declarative_user.m index 984dbeb3c..bcc9f621f 100644 --- a/browser/declarative_user.m +++ b/browser/declarative_user.m @@ -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 diff --git a/browser/mdb.m b/browser/mdb.m index 11778bf28..584952970 100644 --- a/browser/mdb.m +++ b/browser/mdb.m @@ -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. diff --git a/browser/mdbcomp.m b/browser/mdbcomp.m new file mode 100644 index 000000000..8a853f5b3 --- /dev/null +++ b/browser/mdbcomp.m @@ -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"). + +%---------------------------------------------------------------------------% diff --git a/browser/mer_mdbcomp.m b/browser/mer_mdbcomp.m new file mode 100644 index 000000000..317ac848b --- /dev/null +++ b/browser/mer_mdbcomp.m @@ -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. diff --git a/browser/program_representation.m b/browser/program_representation.m index c7dd0328f..cf25b6a01 100644 --- a/browser/program_representation.m +++ b/browser/program_representation.m @@ -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). diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m index c7883c430..5ee711c16 100644 --- a/compiler/compile_target_code.m +++ b/compiler/compile_target_code.m @@ -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, diff --git a/compiler/notes/overall_design.html b/compiler/notes/overall_design.html index ba97f38e2..25a44d4e1 100644 --- a/compiler/notes/overall_design.html +++ b/compiler/notes/overall_design.html @@ -48,7 +48,9 @@ The subdirectories containing major subsystems are as follows:
  • library: the Mercury standard library (written in Mercury)
  • compiler: the Mercury compiler (written in Mercury)
  • trace: the part of the Mercury debugger that is written in C -
  • browser: the part of the Mercury debugger that is written in Mercury +
  • 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.
  • profiler: the Mercury profiler (written in Mercury)
  • extras: additional Mercury libraries. These are distributed separately from the main Mercury distribution. @@ -123,8 +125,9 @@ from `configure.in'.

    Libraries and dependencies

    -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:
  • the main program object files (e.g. compiler/*.o or profiler/*.o)
  • trace library (trace/libmer_trace.a)
  • browser library (browser/libmer_browser.a) +
  • mdbcomp library (browser/libmer_mdbcomp.a)
  • standard library (library/libmer_std.a)
  • runtime library (runtime/libmer_rt.a)
  • Boehm collector (boehm_gc/libgc.a) @@ -162,6 +166,6 @@ other components.
    -Last update was $Date: 2000-08-21 14:49:50 $ by $Author: fjh $@cs.mu.oz.au.
    +Last update was $Date: 2003-10-27 06:00:38 $ by $Author: zs $@cs.mu.oz.au.
    diff --git a/compiler/prog_rep.m b/compiler/prog_rep.m index 14424fe09..fc7f30389 100644 --- a/compiler/prog_rep.m +++ b/compiler/prog_rep.m @@ -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. diff --git a/scripts/c2init.in b/scripts/c2init.in index da9ad9642..56bb0c764 100755 --- a/scripts/c2init.in +++ b/scripts/c2init.in @@ -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" diff --git a/scripts/ml.in b/scripts/ml.in index 0fca8c65d..b40365d9f 100644 --- a/scripts/ml.in +++ b/scripts/ml.in @@ -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 \ diff --git a/tools/binary b/tools/binary index a8a98a82e..f07ae1891 100755 --- a/tools/binary +++ b/tools/binary @@ -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 diff --git a/tools/binary_step b/tools/binary_step index 036db95d3..24234acd4 100755 --- a/tools/binary_step +++ b/tools/binary_step @@ -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 diff --git a/tools/bootcheck b/tools/bootcheck index c42f370f2..330632761 100755 --- a/tools/bootcheck +++ b/tools/bootcheck @@ -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 diff --git a/tools/linear b/tools/linear index 20c869927..cb7a94049 100755 --- a/tools/linear +++ b/tools/linear @@ -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="" diff --git a/tools/lml b/tools/lml index 939943749..a5f66721e 100755 --- a/tools/lml +++ b/tools/lml @@ -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" diff --git a/trace/mercury_trace_internal.c b/trace/mercury_trace_internal.c index 49992c312..f73b7b7ad 100644 --- a/trace/mercury_trace_internal.c +++ b/trace/mercury_trace_internal.c @@ -32,7 +32,7 @@ #include "mdb.browse.mh" #include "mdb.browser_info.mh" -#include "mdb.program_representation.mh" +#include "mdbcomp.program_representation.mh" #include #include