Files
mercury/tests/debugger/Mmakefile
Zoltan Somogyi 04e614485d Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500
Branches: main

Implement deep profiling; merge the changes on the deep2 branch back
onto the trunk.

The main documentation on the general architecture of the deep profiler
is the deep profiling paper.

doc/user_guide.texi:
	Document how to use the deep profiler.

deep_profiler:
deep_profiler/Mmakefile:
	A new directory holding the deep profiler and its mmakefile.

Mmakefile:
	Add targets for the new directory.

	Add support for removing inappropriate files from directories.

deep_profiler/interface.m:
	The deep profiler consists of two programs: mdprof_cgi.m, which acts
	as a CGI "script", and mdprof_server.m, which implements the server
	process that the CGI script talks to. Interface.m defines the
	interface between them.

script/mdprof.in:
	A shell script template. ../configure uses it to generate mdprof,
	which is a wrapper around mdprof_cgi that tells it how to find
	mdprof_server.

deep_profiler/mdprof_cgi.m:
	The CGI "script" program.

deep_profiler/mdprof_server.m:
	The top level predicates of the server.

deep_profiler/profile.m:
	The main data structures of the server and their operations.

deep_profiler/read_profile.m:
	Code for reading in profiling data files.

deep_profiler/startup.m:
	Code for post-processing the information in profiling data files,
	propagating costs from procedures to their ancestors and performing
	various kinds of summaries.

deep_profiler/server.m:
	Code for responding to requests from the CGI script.

deep_profiler/cliques.m:
	Code to find cliques in graphs.

deep_profiler/array_util.m:
deep_profiler/util.m:
	Utility predicates.

deep_profiler/dense_bitset.m:
	An implementation of (part of) the set ADT with dense bit vectors.

deep_profiler/measurements.m:
	Operations on profiling measurements.

deep_profiler/timeout.m:
	An implementation of a timeout facility.

deep_profiler/conf.m:
	Functions that depend on autoconfigured settings.

configure.in:
	Find out what command to use to find the name of the local host.

	Install deep profiling versions of the standard library along with the
	other profiling versions.

runtime/mercury_conf.h.in:
	Add some macros for deep_profiler/conf.m to use.

library/profiling_builtin.m:
runtime/mercury_deep_call_port_body.h:
runtime/mercury_deep_leave_port_body.h:
runtime/mercury_deep_redo_port_body.h:
	A new library module that implements deep profiling primitives.
	Some of these primitives have many versions, whose common code is
	factor is factored out in three new include files in the runtime.

compiler/deep_profiling.m:
	New module to perform the program transformations described in the
	paper.

compiler/notes/compiler_design.html:
	Document the new compiler module.

compiler/mercury_compiler.m:
	Invoke the new module in deep profiling grades. Allow global static
	data to be generated by deep_profiling.m.

compiler/options.m:
	Add options to turn on deep profiling and (for benchmarking purposes)
	control its implementation.

	Add an optiooption disable tailcall optimization in the LLDS backend,
	to help benchmarking deep profiling.

compiler/jumpopt.m:
compiler/optimize.m:
	Obey the option to disable tailcalls.

compiler/handle_options.m:
	Handle the implications of deep profiling.

compiler/modules.m:
	In deep profiling grades, automatically import profiling_builtin.m.

compiler/prog_util.m:
doc/Makefile:
library/library.m:
	Handle the new builtin module.

compiler/export.m:
	In deep profiling grades, wrap deep profiling code around exported
	procedures to handle the "unscheduled call" aspects of callbacks to
	Mercury from the foreign language.

compiler/higher_order.m:
profiler/demangle.m:
util/demangle.c:
	When creating a name for a higher-order-specialized predicate, include
	the mode number in the name.

compiler/add_trail_ops.m:
compiler/type_util.m:
	Move c_pointer_type from add_trail_ops to type_util, so it can also be
	used by deep_profiling.m.

compiler/hlds_goal.m:
	Add a new goal feature that marks a tail call, for use by
	deep_profiling.m.

compiler/hlds_pred.m:
	Add a new field to proc_info structures for use by deep_profiling.m.

	Add a mechanism for getting proc_ids for procedure clones.

	Remove next_proc_id, an obsolete and unused predicate.

compiler/hlds_data.m:
	Add a new cons_id to refer to the proc_static structure of a procedure.

compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/dependency_graph.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/switch_util.m:
compiler/unify_gen.m:
	Trivial changes to handle the new cons_id, goal feature and/or
	proc_info argument.

compiler/rtti.m:
	Add a utility predicate for extracting pred_id and proc_id from an
	rtti_proc_label, for use by hlds_out.m

compiler/layout.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_common.m:
	Add support for proc_static and call_site_static structures.

compiler/layout_out.m:
compiler/llds_out.m:
	Add code for the output of proc_static structures.

compiler/code_util.m:
	Make code_util__make_proc_label_from_rtti a function, and export it.

util/mkinit.c:
compiler/llds_out.m:
compiler/layout.m:
compiler/modules.m:
	Add support for a fourth per-module C function, for writing out
	proc_static structures (and the call_site_static structures they
	contains).

	Since proc_static structures can be referred to from LLDS code (and not
	just from other static structures and compiler-generated C code),
	reorganize the declarations of static structures slightly.

	Change the schema for the name of the first per-module C function
	slightly, to make it the addition of the fourth function easier.
	The scheme now is:

		mercury__<modulename>__init
		mercury__<modulename>__init_type_tables
		mercury__<modulename>__init_debugger
		mercury__<modulename>__write_out_proc_statics

	Improve formatting of the generated C code.

library/*.m:
runtime/mercury.c:
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
trace/mercrury_trace.[ch]:
trace/mercrury_trace_declarative.c:
trace/mercrury_trace_external.c:
trace/mercrury_trace_internal.c:
	Conform to the new scheme for initialization functions for hand-written
	modules.

compiler/mercury_compile.m:
library/benchmarking.m:
runtime/mercury_conf_param.h:
runtime/mercury.h:
runtime/mercury_engine.c:
runtime/mercury_goto.c:
runtime/mercury_grade.h:
runtime/mercury_ho_call.c:
runtime/mercury_label.[ch]:
runtime/mercury_prof.[ch]:
	Add an MR_MPROF_ prefix in front of the C macros used to control the
	old profiler.

compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Make deep profiling completely separate from the old profiling system,
	by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME
	and the compiler option --profile-time.

library/array.m:
library/builtin.m:
library/std_util.m:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_compare_body.h:
	In deep profiling grades, wrap the deep profiling call, exit, fail
	and redo codes around the bodies of hand-written unification
	and comparison procedures.

	Make the reporting of array bounds violations switchable between
	making them fatal errors, as we currently, and reporting them by
	throwing an exception. Throwing an exception makes debugging code
	using arrays easier, but since exceptions aren't (yet) propagated
	across engine boundaries, we keep the old behaviour as the default;
	the new behaviour is for implementors.

runtime/mercury_deep_profiling_hand.h:
	New file that defines macros for use in Mercury predicates whose
	definition is in hand-written C code.

library/exception.m:
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
	In deep profiling grades, wrap the deep profiling call, exit, fail
	and redo codes around the bodies of the various modes of builtin_catch.

	Provide a function that C code can use to throw exceptions.

library/benchmarking.m:
library/exception.m:
library/gc.m:
library/std_util.m:
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_overflow.h:
runtime/mercury_regs.h:
runtime/mercury_stacks.h:
runtime/mercury_thread.c:
runtime/mercury_wrapper.c:
	Add prefixes to the names of the fields in the engine and context
	structures, to make code using them easier to understand and modify.

runtime/mercury_deep_profiling.[ch]:
	New module containing support functions for deep profiling and
	functions for writing out a deep profiling data file at the end of
	execution.

runtime/mercury_debug.[ch]:
	Add support for debugging deep profiling.

	Add support for watching the value at a given address.

	Make the buffered/unbuffered nature of debugging output controllable
	via the -du option.

	Print register contents only if -dr is specified.

runtime/mercury_goto.h:
runtime/mercury_std.h:
	Use the macros in mercury_std.h instead of defining local variants.

runtime/mercury_goto.h:
runtime/mercury_stack_layout.h:
runtime/mercury_stack_trace.c:
runtime/mercury_tabling.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.c:
	Standardize some of the macro names with those used in the debugger
	paper.

runtime/mercury_heap.h:
	Add support for memory profiling with the deep profiler.

runtime/mercury_prof.[ch]:
runtime/mercury_prof_time.[ch]:
	Move the functionality that both the old profiler and the deep profiler
	need into the new module mercury_prof_time. Leave mercury_prof
	containing stuff that is only relevant to the old profiler.

runtime/mercury_prof.[ch]:
runtime/mercury_strerror.[ch]:
	Move the definition of strerror from mercury_prof to its own file.

runtime/mercury_wrapper.[ch]:
	Add support for deep profiling.

	Add suppory for controlling whether debugging output is buffered or
	not.

	Add support for watching the value at a given address.

runtime/Mmakefile:
	Mention all the added files.

scripts/mgnuc.in:
	Add an option for turning on deep profiling.

	Add options for controlling the details of deep profiling. These
	are not documented because they are intended only for benchmarking
	the deep profiler itself, for the paper; they are not for general use.

tools/bootcheck:
	Compile the deep_profiler directory as well as the other directories
	containing Mercury code.

	Turn off the creation of deep profiling data files during bootcheck,
	since all but one of these in each directory will be overwritten
	anyway.

	Add support for turning on --keep-objs by default in a workspace.

tools/speedtest:
	Preserve any deep profiling data files created by the tests.

trace/mercury_trace.c:
	Trap attempts to perform retries in deep profiling grades, since they
	would lead to core dumps otherwise.

util/Mmakefile:
	Avoid compile-time warnings when compiling getopt.

tests/*/Mmakefile:
tests/*/*/Mmakefile:
	In deep profiling grades, switch off the tests that test features
	that don't work with deep profiling, either by design or because
	the combination hasn't been implemented yet.
2001-05-31 06:00:27 +00:00

330 lines
11 KiB
Plaintext

#-----------------------------------------------------------------------------#
main_target: check
include ../Mmake.common
-include ../Mmake.params
#-----------------------------------------------------------------------------#
# We suppress the printing of the banner, because different workspaces
# may get different version numbers printed in it. This would otherwise be
# the source of irrelevant difference between the actual and expected outputs.
MDB = MERCURY_SUPPRESS_MDB_BANNER=yes mdb
#-----------------------------------------------------------------------------#
RETRY_PROGS = \
all_solutions \
browser_test \
mdb_command_test \
queens \
retry \
tabled_read
NONRETRY_PROGS = \
breakpoints \
browse_pretty \
debugger_regs \
exception_cmd \
exception_value \
exception_vars \
existential_type_classes \
field_names \
implied_instance \
interpreter \
loopcheck \
multi_parameter \
output_term_dep \
polymorphic_output \
resume_typeinfos \
shallow
# The following tests are disabled, since currently they get some spurious
# failures if readline support is enabled:
# interactive
# Note that some of the make rules for interactive are disabled too.
MCFLAGS-shallow = --trace shallow
MCFLAGS-tabled_read = --trace-table-io
MCFLAGS = --trace deep
MLFLAGS = --trace
C2INITFLAGS = --trace
# We need to use shared libraries for interactive queries to work.
# The following is necessary for shared libraries to work on Linux.
GRADEFLAGS-interactive = --pic-reg
MLFLAGS-interactive = --shared
# Debugging doesn't yet don't work in MLDS grades (hl*), and the retry command
# doesn't and will not work in deep profiling grades (profdeep).
# Also base grades `jump' and `fast' cannot be used with
# stack layouts (which are required for tracing).
ifneq "$(findstring hl,$(GRADE))" ""
PROGS=
else
ifneq "$(findstring profdeep,$(GRADE))" ""
# Eventually, this should be DEBUGGER_PROGS=$(NONRETRY_PROGS).
# However, the code that is required to switch off the profiling
# primitives in Mercury code invoked by the debugger (e.g. for
# browsing) has not yet been implemented.
DEBUGGER_PROGS=
else
DEBUGGER_PROGS=$(NONRETRY_PROGS) $(RETRY_PROGS)
endif
ifneq "$(findstring asm_,$(GRADE))" ""
PROGS=$(DEBUGGER_PROGS)
else
ifneq "$(findstring jump,$(GRADE))" ""
PROGS=
else
ifneq "$(findstring fast,$(GRADE))" ""
PROGS=
else
PROGS=$(DEBUGGER_PROGS)
endif
endif
endif
endif
#-----------------------------------------------------------------------------#
all_solutions.out: all_solutions all_solutions.inp
$(MDB) ./all_solutions < all_solutions.inp > all_solutions.out 2>&1
breakpoints.out: breakpoints breakpoints.inp
$(MDB) ./breakpoints < breakpoints.inp > breakpoints.out 2>&1
# We need to pipe the output through sed to avoid hard-coding dependencies on
# particular line numbers in the standard library source code.
browse_pretty.out: browse_pretty browse_pretty.inp
$(MDB) ./browse_pretty < browse_pretty.inp 2>&1 | \
sed 's/io.m:[0-9]*/io.m:NNNN/g' > browse_pretty.out 2>&1
# We need to pipe the output through sed to avoid hard-coding dependencies on
# particular line numbers in the standard library source code.
browser_test.out: browser_test browser_test.inp
$(MDB) ./browser_test < browser_test.inp 2>&1 | \
sed 's/io.m:[0-9]*/io.m:NNNN/g' > browser_test.out 2>&1
debugger_regs.out: debugger_regs debugger_regs.inp
$(MDB) ./debugger_regs < debugger_regs.inp > debugger_regs.out 2>&1
# We need to pipe the output through sed to avoid hard-coding dependencies on
# particular line numbers in the standard library source code.
exception_value.out: exception_value exception_value.inp
$(MDB) ./exception_value < exception_value.inp 2>&1 | \
sed -e 's/exception.m:[0-9]*/exception.m:NNNN/g' | \
sed -e '/EXCP/s/).*/)/' > exception_value.out 2>&1
# The exception_cmd, exception_vars, polymorphic_output and loopcheck tests
# are supposed to return a non-zero exit status, since they exit by throwing
# an exception. We strip the goal paths from their exception events, since
# the exact goal paths are dependent on optimization level. The stripping
# must be done outside the condition of the if-then-else.
exception_cmd.out: exception_cmd exception_cmd.inp
if $(MDB) ./exception_cmd < exception_cmd.inp \
> exception_cmd.tmp 2>&1; \
then \
sed -e '/EXCP/s/).*/)/' < exception_cmd.tmp \
> exception_cmd.out 2>&1; \
rm exception_cmd.tmp; \
false; \
else \
sed -e '/EXCP/s/).*/)/' < exception_cmd.tmp \
> exception_cmd.out 2>&1; \
rm exception_cmd.tmp; \
true; \
fi
exception_vars.out: exception_vars exception_vars.inp
if $(MDB) ./exception_vars < exception_vars.inp \
> exception_vars.tmp 2>&1; \
then \
sed -e '/EXCP/s/).*/)/' < exception_vars.tmp \
> exception_vars.out 2>&1; \
rm exception_vars.tmp; \
false; \
else \
sed -e '/EXCP/s/).*/)/' < exception_vars.tmp \
> exception_vars.out 2>&1; \
rm exception_vars.tmp; \
true; \
fi
polymorphic_output.out: polymorphic_output polymorphic_output.inp
if $(MDB) ./polymorphic_output < polymorphic_output.inp \
> polymorphic_output.tmp 2>&1; \
then \
sed -e '/EXCP/s/).*/)/' < polymorphic_output.tmp\
> polymorphic_output.out 2>&1; \
rm polymorphic_output.tmp; \
false; \
else \
sed -e '/EXCP/s/).*/)/' < polymorphic_output.tmp\
> polymorphic_output.out 2>&1; \
rm polymorphic_output.tmp; \
true; \
fi
loopcheck.out: loopcheck loopcheck.inp
if $(MDB) ./loopcheck < loopcheck.inp \
> loopcheck.tmp 2>&1; \
then \
sed -e '/EXCP/s/).*/)/' < loopcheck.tmp \
> loopcheck.out 2>&1; \
rm loopcheck.tmp; \
false; \
else \
sed -e '/EXCP/s/).*/)/' < loopcheck.tmp \
> loopcheck.out 2>&1; \
rm loopcheck.tmp; \
true; \
fi
# We need to pipe the output through sed to avoid hard-coding dependencies on
# particular line numbers in the standard library source code.
existential_type_classes.out: existential_type_classes \
existential_type_classes.inp
$(MDB) ./existential_type_classes < existential_type_classes.inp 2>&1 | \
sed 's/string.m:[0-9]*/string.m:NNNN/g' > existential_type_classes.out
field_names.out: field_names field_names.inp
$(MDB) ./field_names < field_names.inp > field_names.out 2>&1
implied_instance.out: implied_instance implied_instance.inp
$(MDB) ./implied_instance < implied_instance.inp \
> implied_instance.out 2>&1
interpreter.out: interpreter interpreter.inp
$(MDB) ./interpreter interpreter.m < interpreter.inp \
> interpreter.out 2>&1
# We need to pipe the output through sed to avoid hard-coding dependencies on
# particular line numbers in the standard library source code.
multi_parameter.out: multi_parameter multi_parameter.inp
$(MDB) ./multi_parameter < multi_parameter.inp 2>&1 | \
sed 's/char.m:[0-9]*/char.m:NNNN/g' > multi_parameter.out
# We need to pipe the output through sed to avoid hard-coding dependencies on
# particular line numbers in the standard library source code.
output_term_dep.out: output_term_dep output_term_dep.inp
$(MDB) ./output_term_dep < output_term_dep.inp 2>&1 | \
sed 's/io.m:[0-9]*/io.m:NNNN/g' > output_term_dep.out 2>&1
queens.out: queens queens.inp
$(MDB) ./queens < queens.inp > queens.out 2>&1
resume_typeinfos.out: resume_typeinfos resume_typeinfos.inp
$(MDB) ./resume_typeinfos < resume_typeinfos.inp 2>&1 | \
sed 's/resume_typeinfos.m:[0-9]*/resume_typeinfos.m:NNNN/g' \
> resume_typeinfos.out 2>&1
retry.out: retry retry.inp
$(MDB) ./retry < retry.inp > retry.out 2>&1
shallow.out: shallow shallow.inp
$(MDB) ./shallow < shallow.inp > shallow.out 2>&1
tabled_read.out: tabled_read tabled_read.inp
$(MDB) ./tabled_read < tabled_read.inp > tabled_read.out 2>&1
# Note that interactive.out.orig depends on $(interactive.ints) because
# interactive.inp contains interactive queries that require interactive.ints
# to have been built.
# This rule is commented out while the interactive test case is disabled,
# because otherwise we get an undefined variable warning from make.
# interactive.out.orig: interactive interactive.inp $(interactive.ints)
# $(MDB) ./interactive < interactive.inp > interactive.out.orig 2>&1
# We pipe the output through sed to remove some spurious warnings that
# `ld' issues.
# XXX we should fix the spurious warnings about unresolved symbols.
# (The spurious warnings about exception handling are due to a flaw
# in the Digital Unix 3.2 linker, so that one is DEC's problem.)
interactive.out: interactive.out.orig
cat interactive.out.orig | \
sed \
-e '/\/usr\/bin\/ld:$$/N' \
-e 's/\/usr\/bin\/ld:.//' \
-e '/Warning: Linking some objects which contain exception information sections$$/N' \
-e 's/Warning: Linking some objects which contain exception information sections.//' \
-e '/ and some which do not. This may cause fatal runtime exception handling$$/N' \
-e 's/ and some which do not. This may cause fatal runtime exception handling.//' \
-e '/ problems (last obj encountered without exceptions was .*)\.$$/N' \
-e 's/ problems (last obj encountered without exceptions was .*)\..//' \
-e '/Warning: Unresolved:$$/N' \
-e 's/Warning: Unresolved:.//' \
-e '/<predicate .main.\/2 mode 0>$$/N' \
-e 's/<predicate .main.\/2 mode 0>.//' \
-e '/<predicate .interactive:qperm.\/2 mode 0>$$/N' \
-e 's/<predicate .interactive:qperm.\/2 mode 0>.//' \
-e '/__start$$/N' \
-e 's/__start.//' \
> interactive.out
# ignore egcs internal errors -- those are not our fault
if grep 'gcc.*Internal compiler error' interactive.out; then \
cp interactive.exp interactive.out; \
fi
# We ignore the result of this action because
# the exit status of grep is not useful in this case
mdb_command_test.out: mdb_command_test mdb_command_test.inp
-$(MDB) ./mdb_command_test < mdb_command_test.inp 2>&1 \
| egrep "internal error in the trace help system" \
> mdb_command_test.out
#-----------------------------------------------------------------------------#
DEPS= $(PROGS:%=$(deps_subdir)%.dep)
DEPENDS= $(PROGS:%=%.depend)
OUTS= $(PROGS:%=%.out)
RESS= $(PROGS:%=%.res)
dep_local: $(DEPS)
depend_local: $(DEPENDS)
check_local: $(OUTS) $(RESS)
all_local: $(PROGS)
#-----------------------------------------------------------------------------#
SUBDIRS = declarative
check_subdirs:
for dir in $(SUBDIRS); do \
(cd $$dir && $(SUBDIR_MMAKE) check) || exit 1; \
done
dep_subdirs:
for dir in $(SUBDIRS); do \
(cd $$dir && $(SUBDIR_MMAKE) dep) || exit 1; \
done
depend_subdirs:
for dir in $(SUBDIRS); do \
(cd $$dir && $(SUBDIR_MMAKE) depend) || exit 1; \
done
realclean_subdirs:
for dir in $(SUBDIRS); do \
(cd $$dir && $(SUBDIR_MMAKE) realclean) || exit 1; \
done
clean_subdirs:
for dir in $(SUBDIRS); do \
(cd $$dir && $(SUBDIR_MMAKE) clean) || exit 1; \
done
all_subdirs:
for dir in $(SUBDIRS); do \
(cd $$dir && $(SUBDIR_MMAKE) all) || exit 1; \
done
#-----------------------------------------------------------------------------#