mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 00:15:27 +00:00
Estimated hours taken: 160
Implement a new data structure for declarative debugging. The
major differences between this and the old implementation are:
- The data structure is implemented in Mercury. The definition
of the type, and procedures for constructing values of that
type, have been moved from trace/mercury_trace_declarative.{c,h}
to browser/declarative_execution.m (which is a new module).
- The front end no longer needs to call the back end via an
indirect pointer---the front end does not call the back end at
all.
- The data structure is not specifically for wrong answer
analysis, it is intended to be used for any sort of analysis.
- The data structure represents execution at a lower level---the
new front end defines a more abstract view in terms of this
data structure.
Implement a test harness for debugging the front end code. This allows
the front end to run as a stand-alone program, which can then be
debugged using `mdb'.
The code in the front end does not currently handle the new structure
very nicely. This is because that code is about to undergo some major
structural changes, so there is little point cleaning it up now.
Consequently:
- Some of the code in the front end is incorrect (eg. the
user interface does not print missing answer nodes
properly).
- The tests have not been reinstated.
These things will be fixed in subsequent changes.
Likewise the compiler still reserves two stack slots, even though
only one is required. After this change the algorithm should be able
to get away with using no stack slots, so modifications to the compiler
will be postponed until then.
browser/declarative_execution.m:
New module. Implement the execution_tree typeclass, which
represents the execution of a Mercury program. Implement
two instances of this typeclass, one for normal use and one for
testing purposes.
browser/declarative_test.m:
New module. A test harness that can be compiled as a
stand-alone program, enabling the front end to be debugged.
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
- Remove the definition of the old data structure.
- Add some macros which enable the new Mercury data structure
to be destructively updated by C code.
- Change the interface to this module so that it reflects more
general diagnosis, not just wrong answer analysis.
- Implement the new algorithm.
- Call an alternative front end if in test mode.
- Update comments.
trace/mercury_trace_internal.h:
Add a new mode for debugging the declarative debugger.
trace/mercury_trace_internal.c:
Change the command from `dd_wrong' to `dd', since it is not
specifically for wrong answer analysis. Add a new command
`dd_dd' which calls the alternative front end used for testing.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
Remove any reference to `MR_edt_root_node', since it is no
longer used.
browser/declarative_debugger.m:
- Add a case for missing answer nodes to `edt_node'.
- Change the `evaluation_tree' typeclass into `mercury_edt'
typeclass. This is to make it more distinct from the new
`execution_tree' typeclass, which is a lower level concept.
- New interface to the diagnoser: types `diagnoser_response'
and `diagnoser_state', and procedure `diagnosis'.
- Define an instance of `mercury_edt' from an instance of
`execution_tree'.
- Updates to the analyser to get it to compile---further changes
will be forthcoming.
browser/declarative_user.m:
- Updates to the user interface to get it to compile---further
changes will be forthcoming.
browser/browser_library.m:
Import the new module (declarative_execution.m).
browser/debugger_interface.m:
browser/util.m:
Move the definitions of trace_port_type and goal_path_string
to browser/util.m, since they are now used by more than just
the external debugger.
browser/Mmakefile:
Add the test harness as a `depend' target.
browser/browse_test.m:
Use the correct interface to the browser.
187 lines
5.6 KiB
Plaintext
187 lines
5.6 KiB
Plaintext
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 1998-1999 The University of Melbourne.
|
|
# This file may only be copied under the terms of the GNU General
|
|
# Public License - see the file COPYING in the Mercury distribution.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# browser/Mmakefile - this is the Mmakefile for building the Mercury
|
|
# browser library, which also includes other functionality needed
|
|
# by Mercury debuggers.
|
|
|
|
# Since the code in this directory is intended to be invoked only from
|
|
# the trace library, which turns off tracing in the Mercury code it calls,
|
|
# compiling the modules in this directory with tracing on only makes
|
|
# the generated code much bigger. However, since all Mercury code
|
|
# in an executable must be of the same grade, we need to be able to
|
|
# compile the modules in this directory in debug grades as well.
|
|
|
|
MERCURY_DIR=..
|
|
include $(MERCURY_DIR)/Mmake.common
|
|
|
|
MAIN_TARGET=library
|
|
|
|
VPATH=$(LIBRARY_DIR)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# If we're going to generate both `.o' files and `.pic_o' files, then
|
|
# don't remove the intermediate `.c' files.
|
|
RM_C = $(LIBRARY_RM_C)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Specify which compilers to use to compile the library.
|
|
# Don't change these without good reason - if you want to
|
|
# do a temporary change, change ../Mmake.params.
|
|
|
|
M_ENV = MERCURY_INT_DIR=$(LIBRARY_DIR) \
|
|
MERCURY_ALL_C_INCL_DIRS="\
|
|
-I$(TRACE_DIR) \
|
|
-I$(RUNTIME_DIR) \
|
|
-I$(BOEHM_GC_DIR) \
|
|
-I$(BOEHM_GC_DIR)/include \
|
|
"
|
|
|
|
MCD = $(M_ENV) $(MC) --generate-dependencies
|
|
MCI = $(M_ENV) $(MC) --make-interface
|
|
MCPI = $(M_ENV) $(MC) --make-private-interface
|
|
MCSI = $(M_ENV) $(MC) --make-short-interface
|
|
MCOI = $(M_ENV) $(MC) --make-opt-int
|
|
MCTOI = $(M_ENV) $(MC) --make-trans-opt
|
|
MCG = $(M_ENV) $(MC) --compile-to-c
|
|
MCS = $(M_ENV) $(MC) --split-c-files -c --cflags "$(ALL_CFLAGS)"
|
|
MGNUC = $(M_ENV) $(SCRIPTS_DIR)/mgnuc
|
|
MGNUCFLAGS = $(DLL_CFLAGS)
|
|
LDFLAGS = -L$(LIBRARY_DIR) -L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR)
|
|
LDLIBS = -l$(STD_LIB_NAME) -l$(RT_LIB_NAME) \
|
|
` case "$(GRADE)" in \
|
|
*.gc*.prof*) echo "-lgc_prof" ;; \
|
|
*.gc*) echo "-lgc" ;; \
|
|
esac \
|
|
`
|
|
|
|
MTAGS = $(SCRIPTS_DIR)/mtags
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Stuff for Windows DLLS using gnu-win32
|
|
|
|
ifeq ($(USE_DLLS),yes)
|
|
|
|
DLL_CFLAGS = -Dlib$(BROWSER_LIB_NAME)_DEFINE_DLL
|
|
|
|
include $(MERCURY_DIR)/Makefile.DLLs
|
|
|
|
else
|
|
|
|
DLL_CFLAGS =
|
|
DLL_DEF_LIB =
|
|
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# targets
|
|
|
|
.PHONY: all
|
|
all : library browse_test declarative_test
|
|
|
|
.PHONY: depend
|
|
depend : browser_library.depend browse_test.depend \
|
|
declarative_test.depend
|
|
|
|
.PHONY: check
|
|
check : browser_library.check
|
|
|
|
.PHONY: all-ints
|
|
all-ints: ints int3s
|
|
|
|
.PHONY: ints
|
|
ints : browser_library.ints browse_test.ints declarative_test.ints
|
|
|
|
.PHONY: int3s
|
|
int3s : browser_library.int3s
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
tags : $(MTAGS) $(browser_library.ms)
|
|
$(MTAGS) $(browser_library.ms) ../library/*.m
|
|
|
|
browser_library.stats : $(COMPILER_DIR)/source_stats.awk $(browser_library.ms)
|
|
awk -f $(COMPILER_DIR)/source_stats.awk \
|
|
`vpath_find $(browser_library.ms)` > $@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: dates
|
|
dates :
|
|
touch $(browser_library.dates)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: os cs
|
|
os: $(browser_library.os)
|
|
cs: $(browser_library.cs)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: library
|
|
library: lib$(BROWSER_LIB_NAME).a lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)
|
|
library: $(BROWSER_LIB_NAME).init
|
|
|
|
lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a : $(browser_library.os)
|
|
rm -f lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a
|
|
ar cr lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a $(browser_library.os)
|
|
$(RANLIB) lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a
|
|
|
|
RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
|
|
RPATH_2=$(SHLIB_RPATH_SEP)$(FINAL_INSTALL_MERC_GC_LIB_DIR)
|
|
|
|
lib$(BROWSER_LIB_NAME).so : $(browser_library.pic_os)
|
|
$(LINK_SHARED_OBJ) -o lib$(BROWSER_LIB_NAME).so \
|
|
$(browser_library.pic_os) \
|
|
$(RPATH_1)$(RPATH_2) \
|
|
$(LDFLAGS) $(LDLIBS) \
|
|
$(SHARED_LIBS)
|
|
|
|
$(BROWSER_LIB_NAME).init: $(deps_subdir)browser_library.dep
|
|
for file in $(browser_library.ms); do \
|
|
grep '^INIT ' $$file; \
|
|
echo "INIT mercury__`basename $$file .m`__init"; \
|
|
done > $(BROWSER_LIB_NAME).init
|
|
|
|
# Ensure we recompile browser_library__version if VERSION is changed.
|
|
$(os_subdir)browser_library.o \
|
|
$(os_subdir)browser_library.pic_o \
|
|
: $(RUNTIME_DIR)/mercury_conf.h
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
realclean_local:
|
|
rm -f lib$(BROWSER_LIB_NAME).a lib$(BROWSER_LIB_NAME).so \
|
|
$(BROWSER_LIB_NAME).init
|
|
rm -f tags
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Installation targets
|
|
|
|
.PHONY: install
|
|
install: install_init install_library
|
|
|
|
.PHONY: install_dirs
|
|
install_dirs:
|
|
[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
|
|
[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
|
|
|
|
.PHONY: install_init
|
|
install_init: $(BROWSER_LIB_NAME).init install_dirs
|
|
cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
|
|
|
|
.PHONY: install_library
|
|
install_library: lib$(BROWSER_LIB_NAME).a \
|
|
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) install_dirs
|
|
cp `vpath_find lib$(BROWSER_LIB_NAME).a \
|
|
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
|
|
$(INSTALL_MERC_LIB_DIR)
|