Files
mercury/Mmake.workspace
Zoltan Somogyi 9ec86d6a6d The objective of this diff is to switch from a table of solver events built
Estimated hours taken: 32
Branches: main

The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.

The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).

Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.

configure.in:
	Require flex and and bison to be available.

doc/user_guide.texi:
	Document user defined events and the new debugger capabilities.

doc/mdb_categories:
	Include "user" in the list of forward movement commands.

	Fix some earlier omissions in that list.

runtime/mercury_stack_layout.h:
	Include an event number in the user-defined event structure.

	Include a string representing an event set specification in module
	layout structures.

runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
	Switch from solver events to user events in names.

runtime/mercury_trace_term.[ch]:
	Provide a representation of flat terms, for use in representing
	the calls that generate synthesized attributes.

	Ensure that exported field names have an MR_ prefix.

browser/cterm.m:
	Conform to the change to runtime/mercury_trace_term.h.

scripts/c2init.in:
scripts/ml.in:
	Include the eventspec library in programs compiled with debugging
	enabled.

compiler/Mmakefile:
	Include the eventspec library in the compiler.

compiler/options.m:
	Add a new option, --event-spec-file-name, that allows the user to
	specify the set of user-defined events the program may use.

compiler/handle_options.m:
	Set this optimization from an environment variable (which may be
	set by the mmc script) if the new option is not explicitly given.

compiler/prog_data.m:
	Define the data structures for the compiler's representation of the
	event set specification.

	Move some definitions around to group them more logically.

compiler/hlds_module.m:
	Include the event set specification as a new field in the module_info.

compiler/prog_event.m:
	Add the code for invoking the parser in the eventspec library,
	and for converting the simple term output by the parser to the
	compiler own representation, which contains more information
	(to wit, the types of the function attributes) and which has had
	a whole bunch of semantic checks done on it (e.g. whether synthesized
	attributes depend on themselves or on nonexistent attributes).

	Provide a function to generate a canonicalized version of the event
	specification file.

compiler/module_qual.m:
compiler/equiv_type.m:
	Process event spec specifications as well as items, to module qualify
	the names of the types of event arguments, and expanding out
	equivalence types.

	In equiv_type.m, rename some variables to make clear what kind of info
	they represent.

compiler/mercury_compile.m:
	Process the event set specification file if one has been selected:
	read it in, module qualify it, expand its equivalence types, and add
	to the module_info.

compiler/compile_target_code.m:
	Include the event_spec library when linking debuggable executables.

compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
	Generate user-defined events instead of solver events.

compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Include a canonicalized version of the event specification file
	in the module layout if the module has any user-defined events.

compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
	Conform to the changes above.

compiler/passes_aux.m:
	Rename a predicate to avoid an ambiguity.

trace/Mmakefile:
	Add the definition and rules required to build the eventspec library.

trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
	A scanner and a parser for reading in event spec specifications.

trace/mercury_event_spec_missing.h:
	Provide the declarations that should be (but aren't) provided by
	flex and bison.

trace/mercury_event_spec.[ch]:
	The main module of the eventspec library. Provides functions to read
	in event set specifications from a file, and to write them out as a
	Mercury term in the form needed by the compiler.

trace/mercury_trace_tables.c:
	If the module layouts being registered include event set
	specifications, then check their consistency. Make the specification
	and the consistency indication available to other modules.

trace/mercury_trace_internal.c:
	During initialization, if the modules contain a consistent set of event
	set specifications, then read that specification into the debugger.
	(We don't yet make use of this information.)

	Add an extra mdb command, "user", which goes forward to the next
	user-defined event.

trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
	Implement the new mdb command.

trace/mercury_trace_vars.[ch]:
	For user-defined events, include the attributes' values among the
	values that can be printed or browsed.

trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
	Minor changes.

scripts/scripts/prepare_tmp_dir_grade_part:
	Copy the .y and .l files to the tmp dir we use for installs.

tools/bootcheck:
	Copy the .y and .l files of the trace directory to stage 2.

tools/lmc.in:
	Include the eventspec library when linking debuggable executables.

tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
	New test case to test the new functionality.

tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
	Enable the new test case.

tests/debugger/completion.exp:
	Expect the new "user" mdb command in the completion output.
2006-11-24 03:48:30 +00:00

238 lines
7.4 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 2002-2006 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# Mmake.workspace - build a program or library using the current workspace,
# not an installed library.
#
# The variable WORKSPACE must be set externally.
#
# If the variable LINK_STATIC is set to `yes', the names of the `.a' files
# for the Mercury libraries will be included in MLLIBS, otherwise
# `-l' options will be included.
#
# By default, if LINK_STATIC is unset or set to `no', `-R' options
# will be passed to ml for each of the directories containing the
# Mercury libraries. If SET_RPATH is set to `no', these options will
# not be passed. This is useful for building the Mercury libraries,
# for which the rpath must be set in each Mmakefile to point to
# the installed library directory.
#
# Setting LINK_BOEHM_GC_ONLY to `yes' causes only the boehm_gc directory
# (and/or the mps_gc directory) to be included in MLFLAGS, MLLIBS and CFLAGS.
# Setting LINK_RUNTIME_ONLY to `yes' causes only the *_gc and runtime
# directories to be included in MLFLAGS, MLLIBS and CFLAGS.
# Setting LINK_STDLIB_ONLY to `yes' causes only the *_gc, runtime
# and library directories to be included in MLFLAGS, MLLIBS and CFLAGS.
#-----------------------------------------------------------------------------#
ifeq ($(origin LINK_STATIC),undefined)
LINK_STATIC = no
endif
ifeq ($(origin SET_RPATH),undefined)
SET_RPATH = yes
endif
ifeq ($(origin LINK_BOEHM_GC_ONLY),undefined)
LINK_BOEHM_GC_ONLY = no
endif
ifeq ($(origin LINK_RUNTIME_ONLY),undefined)
LINK_RUNTIME_ONLY = no
endif
ifeq ($(origin LINK_STDLIB_ONLY),undefined)
LINK_STDLIB_ONLY = no
endif
SCRIPTS_DIR = $(WORKSPACE)/scripts
RUNTIME_DIR = $(WORKSPACE)/runtime
LIBRARY_DIR = $(WORKSPACE)/library
TRACE_DIR = $(WORKSPACE)/trace
MDBCOMP_DIR = $(WORKSPACE)/mdbcomp
BROWSER_DIR = $(WORKSPACE)/browser
BOEHM_GC_DIR = $(WORKSPACE)/boehm_gc
MPS_GC_DIR = $(WORKSPACE)/mps_gc/code
COMPILER_DIR = $(WORKSPACE)/compiler
UTIL_DIR = $(WORKSPACE)/util
ROBDD_DIR = $(WORKSPACE)/robdd
ANALYSIS_DIR = $(WORKSPACE)/analysis
# Specify the MPS "platform"
# E.g. lii4gc means Linux, i486, gcc
MPS_PFM = lii4gc
# Specify the MPS "variety"
# E.g. "hi" means "hot internal" (production version),
# "ci" means "cold internal" (version with extra debugging checks)
MPS_VARIETY = hi
MPS_GC_OBJ_DIR=$(MPS_GC_DIR)/$(MPS_PFM)/$(MPS_VARIETY)
# The names of the various libraries.
# The archives and shared object objects have a "lib" prefix and a ".a" or
# ".so" (or ".dll") suffix around these names; the initialization files
# have just a ".init" suffix. (The trace library does not have a .init file,
# since it contains no Mercury code.)
#
# If you change these, you will also need to change the files indicated
# in scripts/c2init.in.
RT_LIB_NAME = mer_rt
STD_LIB_NAME = mer_std
TRACE_LIB_NAME = mer_trace
EVENTSPEC_LIB_NAME = mer_eventspec
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),
# which is used by the linker to help it to map different shared objects
# to different virtual memory addresses at static link time, so as to avoid
# the need to relocate them at dynamic link time.
SO_LOCATIONS_DIR = $(WORKSPACE)/
export SO_LOCATIONS_DIR
MC = $(SCRIPTS_DIR)/mmc
MGNUC = $(SCRIPTS_DIR)/mgnuc
ML = $(SCRIPTS_DIR)/ml
C2INIT = MERCURY_MKINIT=$(UTIL_DIR)/mkinit $(SCRIPTS_DIR)/c2init
MKLIBINIT = $(UTIL_DIR)/mkinit -k
MTAGS = $(SCRIPTS_DIR)/mtags
MTAGSFLAGS += $(EXTRA_MTAGSFLAGS)
VPATH = $(LIBRARY_DIR)
ifeq ($(origin MERCURY_CONFIG_FILE),undefined)
MERCURY_CONFIG_FILE = $(SCRIPTS_DIR)/Mercury.config.bootstrap
CONFIG_OVERRIDE =
else
CONFIG_OVERRIDE = --config-file $(MERCURY_CONFIG_FILE)
endif
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
MCFLAGS += --options-file $(WORKSPACE)/Mercury.options
endif
# now in FLAGS files
# MCFLAGS += -I$(LIBRARY_DIR)
# no in .mgnuc_opt files
# MGNUCFLAGS += --no-mercury-stdlib-dir
C2INITFLAGS += --trace-init-file $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init \
--trace-init-file $(MDBCOMP_DIR)/$(MDBCOMP_LIB_NAME).init
C2INITARGS += $(LIBRARY_DIR)/$(STD_LIB_NAME).init \
$(RUNTIME_DIR)/$(RT_LIB_NAME).init
MLFLAGS += --no-mercury-stdlib-dir
# now in .mgnuc_copts files
# #
# # Work out the C include directories.
# #
# C_INCL_DIRS = -I$(BOEHM_GC_DIR) -I$(BOEHM_GC_DIR)/include -I$(MPS_GC_DIR)
# ifneq ($(LINK_BOEHM_GC_ONLY),yes)
# C_INCL_DIRS += -I$(RUNTIME_DIR)
# ifneq ($(LINK_RUNTIME_ONLY),yes)
# C_INCL_DIRS += -I$(LIBRARY_DIR) -I$(LIBRARY_DIR)/$(mihs_subdir)
# ifneq ($(LINK_STDLIB_ONLY),yes)
# C_INCL_DIRS += -I$(MDBCOMP_DIR) -I$(MDBCOMP_DIR)/$(mihs_subdir) \
# -I$(BROWSER_DIR) -I$(BROWSER_DIR)/$(mihs_subdir) -I$(TRACE_DIR)
# endif
# endif
# endif
# CFLAGS += $(C_INCL_DIRS)
# now in FLAGS files
# MCFLAGS += $(C_INCL_DIRS:-I%=--c-include-directory %)
#
# Work out the .NET directories
#
MERC_C_INCL_DIR = $(RUNTIME_DIR)
MERC_DLL_DIR = $(LIBRARY_DIR)
#
# Work out which libraries to link with.
# The $(shell) here is needed to allow the variable values in
# ECHO_MERCURY_OPTIONS in Mmake.vars to be single-quoted when
# passed to echo in order to preserve double-quotes (e.g. for
# file names containing spaces).
#
GC_LIBS_0=`$(ML) --grade $(GRADE) --print-gc-grade`
GC_LIBS=$(shell echo $(GC_LIBS_0))
STATIC_GC_LIBS_0 = \
` \
case $(GRADE) in \
*.gc*) echo $(BOEHM_GC_DIR)/lib$(GC_LIBS).$A ;; \
*.mps*) echo $(MPS_GC_OBJ_DIR)/mps.$A ;; \
esac \
`
STATIC_GC_LIBS = $(shell echo $(STATIC_GC_LIBS_0))
SHARED_GC_LIBS_0 = \
` \
case $(GRADE) in \
*.gc*) echo -l$(GC_LIBS) ;; \
*.mps*) echo $(MPS_GC_OBJ_DIR)/mps.$A ;; \
esac \
`
SHARED_GC_LIBS = $(shell echo $(SHARED_GC_LIBS_0))
ifeq ($(LINK_STATIC),yes)
STATIC_RT_LIBS=
STATIC_STD_LIBS=
STATIC_TRACE_LIBS=
ifneq ($(LINK_BOEHM_GC_ONLY),yes)
STATIC_RT_LIBS = $(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A
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 \
$(TRACE_DIR)/lib$(EVENTSPEC_LIB_NAME).$A \
$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A \
$(MDBCOMP_DIR)/lib$(MDBCOMP_LIB_NAME).$A
endif
endif
endif
MLOBJS += $(STATIC_TRACE_LIBS) $(STATIC_STD_LIBS) \
$(STATIC_RT_LIBS) $(STATIC_GC_LIBS)
MCFLAGS += --mercury-linkage static
else # LINK_STATIC != yes
LINK_RT_LIB_OPTS=
LINK_STD_LIB_OPTS=
LINK_TRACE_LIB_OPTS=
ifneq ($(LINK_BOEHM_GC_ONLY),yes)
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$(EVENTSPEC_LIB_NAME) \
-l$(BROWSER_LIB_NAME) -l$(MDBCOMP_LIB_NAME)
endif
endif
endif
LINK_LIB_OPTS = $(LINK_TRACE_LIB_OPTS) $(LINK_STD_LIB_OPTS) \
$(LINK_RT_LIB_OPTS) $(SHARED_GC_LIBS)
LIB_DIR_OPTS = -L$(BOEHM_GC_DIR) -L$(MPS_GC_DIR) -L$(RUNTIME_DIR) \
-L$(LIBRARY_DIR) -L$(TRACE_DIR) -L$(MDBCOMP_DIR) \
-L$(BROWSER_DIR)
MLFLAGS += $(LIB_DIR_OPTS)
# now in FLAGS files
# MCFLAGS += $(LIB_DIR_OPTS)
MLLIBS += $(LINK_LIB_OPTS)
MCFLAGS += --mercury-linkage shared
ifeq ($(SET_RPATH),yes)
MLFLAGS += $(LIB_DIR_OPTS:-L%=-R%)
MCFLAGS += --flags RPATH
endif
endif # LINK_STATIC != yes