Estimated hours taken: 60
Branches: main
Implement coverage testing. The output format is a bit crude, but people
have been asking for this capability.
The main problem tackled in this diff is that coverage testing requires
gathering information from a lot of program executions, and the execution count
files for all these executions require a huge amount of disk space. We now
therefore put a limit on the number of files we keep; when this limit is
exceeded, the program execution that reaches the limit will automatically
summarize all these files back into a single file before it exits.
This diff also tackles the same problem along a different axis by changing
the format of execution count files to make them smaller. One way is to factor
out and represent just once some information that is common to many procedures:
the file name and the module name. Another is to abbreviate some keywords,
e.g. "fproc" instead of "proc function". The third is not to write out the
defining module's name unless it differs from the declaring module's name,
which it almost never does. (The two differ only when the compiler is invoked
with intermodule optimization, and creates a specialized version of a predicate
in a module other than its home module.)
Since we are changing the trace count file format anyway, make another change
useful for coverage testing: record the entire provenance of the trace counts
in the file, including the name of the program and what files went into unions
and diffs of trace count files.
When doing coverage testing of the compiler, the compiler *must* be in a debug
grade. However, the tools for summarizing trace files, invoked from the
compiler executable when the compiler is being coverage tested, *cannot* be
in debug grade, because debug grade disables tail recursion, and without tail
recursion the summarization program runs out of stack space. This diff
therefore arranges for the slice directory to not be affected by the parameters
applying to the rest of the workspace (including the top level Mmake.params).
Mmakefile:
Don't apply the top level mmake's parameters to recursive mmakes in
the slice directory.
Factor out some common code.
configure.in:
Require that the installed compiler contain the renamed standard
library function names installed by my diff on Sep 20, since the
slice directory needs them, and cannot get them from the workspace.
mdbcomp/trace_counts.m:
Update the parsing code to parse the new format for trace count files,
and update the code for writing out trace counts to generate the new
format.
Replace the proc_label_and_filename type with the proc_label_in_context
type, which makes it easier to keep track of the current module as well
as the current file (this is required by the new, more compact format
for trace count files).
When considering the union of multiple trace counts files, keep track
of whether they contained all counts or just the nonzero counts. This
requires keeping track of this info for single files as well.
Provide ways to represent and to compute differences between trace
count files, to support the new program in slice/mtc_diff.m.
mdbcomp/slice_and_dice.m:
Reformat to conform to our Mercury style guide.
Conform to the change to trace_counts.m.
compiler/tupling.m:
Conform to the change to mdbcomp.
runtime/mercury_wrapper.c:
Implement the new option values used to implement coverage testing.
These allow control of the limit on the number of execution count
files, and collecting execution counts only from a specified
executable.
Add MR_ prefixes.
runtime/mercury_trace_base.[ch]:
Provide the mechanism for summarizing execution counts when we reach
the limit on the number of execution counts files.
Update the code that writes out trace counts files to generate
the new format for trace counts files. Make this code take the boolean
that says whether to include labels with zero counts in the output
as an explicit parameter, not as a global variable.
Break up an excessively large function.
scripts/mtc:
Add the options needed to control the process of automatic
summarization of trace counts files.
slice/.mgnuc_copts:
slice/.mgnuc_opts:
slice/SLICE_FLAGS.in:
Make these files empty, since we don't want to refer to the rest of the
workspace. (We could delete them as well, but CVS doesn't handle
resurrection of deleted files very well, and we don't want to burn any
bridges.)
slice/Mmakefile:
Add the new executables, and make the code in this directory
independent of the other directories in the workspace.
Since we need the code of the modules in the mdbcomp directory
but don't want to link to the object files in that directory (since
the grades may differ), make copies of those modules in this directory.
slice/mcov.m:
Add this module, the code for the Mercury coverage test tool.
slice/mtc_diff.m:
Add this module, the code for computing the diff between two trace
counts files. The intended use is to compare two trace counts files
dumped at different stages of execution. (Since foreign_procs can be
used to invoke the C functions in the runtime that write out the trace
counts files in the middle of a program's execution, not just the end.)
slice/mdice.m:
slice/mslice.m:
slice/mtc_union.m:
Convert to four space indentation.
tools/bootcheck:
Since the slice directory's grade is independent of the grade of the
other directories, don't copy it to the stage2 and stage3 by default.
If it is copied, then still compile it (and otherwise handle it)
separate from the other directories.
Add an option for gathering coverage test data during bootchecking.
Estimated hours taken: 1
Branches: main, 0.13
Fix a problem with the automatically generated trace counts file name.
The filename contained the name of the invoked program with "/" replaced by
":". Using ":" is a problem on Windows because it is not allowed in windows
filenames. Instead we now use "_".
Allow the user to specify their own trace counts file name with an extra option
to mtc.
runtime/mercury_trace_base.c:
When dumping trace counts, first check if the user gave a filename to
be used and if they did use that, otherwise generate a filename, but
use "_" instead of ":".
runtime/mercury_trace_base.h:
Add MR_trace_counts_file for recording a user defined trace counts
file name.
runtime/mercury_wrapper.c:
Process the --tc-output-file MERCURY_OPTIONS option that allows the
user to give their own trace counts file name.
scripts/mtc:
Add an -o option to allow the user to give their own file name.
Also add a --help option.
tests/debugger/declarative/Mmakefile:
Make the dice test use the --tc-output-file option.
Estimated hours taken: 0.5
Branches: main
scripts/mtc:
Add this new script (Mercury trace count, by analogy with mdb),
which simply invokes the command represented by the rest of the
command line after setting up MERCURY_OPTIONS to ask for the trace
counts to be generated.
scripts/Mmakefile:
Add the new script to the list of scripts.
scripts/mdb.in:
Fix a grammar error.