Estimated hours taken: 12
Branches: main
Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.
The problem was not in lco.m, but in follow_code.m. In some cases,
(specifically, the LCMC version of insert_2 in sparse_bitset.m),
follow_code.m moved an impure goal (store_at_ref) into the arms of an
if-then-else without marking those arms, or the if-then-else, as impure.
The next pass, simplify, then deleted the entire if-then-else, since it
had no outputs. (The store_at_ref that originally appeared after the
if-then-else was the only consumer of its only output.)
The fix is to get follow_code.m to make branched control structures such as
if-then-elses, as well as their arms, semipure or impure if a goal being moved
into them is semipure or impure, or if they came from an semipure or impure
conjunction.
Improve the optimization of the LCMC version of sparse_bitset.insert_2, which
had a foreign_proc invocation of bits_per_int in it: replace such invocations
with a unification of the bits_per_int constant if not cross compiling.
Add a new option, --optimize-constructor-last-call-null. When set, LCMC will
assign NULLs to the fields not yet filled in, to avoid any junk happens to be
there from being followed by the garbage collector's mark phase.
This diff also makes several other changes that helped me to track down
the bug above.
compiler/follow_code.m:
Make the fix described above.
Delete all the provisions for --prev-code; it won't be implemented.
Don't export a predicate that is not now used anywhere else.
compiler/simplify.m:
Make the optimization described above.
compiler/lco.m:
Make sure that the LCMC specialized procedure is a predicate, not a
function: having a function with the mode LCMC_insert_2(in, in) = in
looks wrong.
To avoid name collisions when a function and a predicate with the same
name and arity have LCMC applied to them, include the predicate vs
function status of the original procedure included in the name of the
new procedure.
Update the sym_name of calls to LCMC variants, not just the pred_id,
because without that, the HLDS dump looks misleading.
compiler/pred_table.m:
Don't have optimizations like LCMC insert new predicates at the front
of the list of predicates. Maintain the list of predicates in the
module as a two part list, to allow efficient addition of new pred_ids
at the (logical) end without using O(N^2) algorithms. Having predicates
in chronological order makes it easier to look at HLDS dumps and
.c files.
compiler/hlds_module.m:
Make module_info_predids return a module_info that is physically
updated though logically unchanged.
compiler/options.m:
Add --optimize-constructor-last-call-null.
Make the options --dump-hlds-pred-id, --debug-opt-pred-id and
--debug-opt-pred-name into accumulating options, to allow the user
to specify more than one predicate to be dumped (e.g. insert_2 and
its LCMC variant).
Delete --prev-code.
doc/user_guide.texi:
Document the changes in options.m.
compiler/code_info.m:
Record the value of --optimize-constructor-last-call-null in the
code_info, to avoid lookup at every cell construction.
compiler/unify_gen.m:
compiler/var_locn.m:
When deciding whether a cell can be static or not, make sure that
we never make static a cell that has some fields initialized with
dummy zeros, to be filled in for real later.
compiler/hlds_out.m:
For goals that are semipure or impure, note this fact. This info was
lost when I changed the representation of impurity from markers to a
field.
mdbcomp/prim_data.m:
Rename some ambiguous function symbols.
compiler/intermod.m:
compiler/trans_opt.m:
Rename the main predicates (and some function symbols) of these modules
to avoid ambiguity and to make them more expressive.
compiler/llds.m:
Don't print line numbers for foreign_code fragments if the user has
specified --no-line-numbers.
compiler/make.dependencies.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.usage.m:
Don't use io.write to write out information to files we may need to
parse again, because this is vulnerable to changes to the names of
function symbols (e.g. the one to mdbcomp/prim_data.m).
The compiler still contains some uses of io.write, but they are
for debugging. I added an item to the todo list of the one exception,
ilasm.m.
compiler/recompilation.m:
Rename a misleading function symbol name.
compiler/parse_tree.m:
Don't import recompilation.m here. It is not needed (all the components
of parse_tree that need recompilation.m already import it themselves),
and deleting the import avoids recompiling almost everything when
recompilation.m changes.
compiler/*.m:
Conform to the changes above.
compiler/*.m:
browser/*.m:
slice/*.m:
Conform to the change to mdbcomp.
library/sparse_bitset.m:
Use some better variable names.
Estimated hours taken: 3
Branches: main
Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.
analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
Remove unused module imports.
Fix some minor departures from our coding standards.
analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
Set --no-warn-unused-imports for those modules that are used as
packages or otherwise break --warn-unused-imports, e.g. because they
contain predicates with both foreign and Mercury clauses and some of
the imports only depend on the latter.
Estimated hours taken: 2
Branches: main
browser/*.m:
Replace __ with . as the module qualifier everywhere in all the modules
of the browser directory. Convert the currently tab-indented modules
to four-space indentation. Delete some unnecessary module
qualifications. Change some type names and function symbols to avoid
ambiguities. Replace a bunch of uses of DCGs with state variable
notation.
Estimated hours taken: 30
Branches: main
Use dicing information in the declarative debugger. Each label in the program
is assigned a suspicion based on a supplied dice. A new search mode then
performs divide and query using the total suspicion of a subtree as the
weighting of the subtree.
browser/declarative_analyser.m:
Parameterize the divide and query search mode by allowing it to work
with an arbitrary weighting heuristic.
Support two weighting heuristics: number of events and suspicion.
Since there is still only one weight field for each suspect,
if the weighting heuristic changes, then update all the weights of all
the suspects.
Return a different reason for asking a divide and query question,
depending on the weighting heuristic.
Some information (specifically how many suspect events remain and
the estimated number of questions remaining for divide and query)
returned by the info command depends on the current weighting heuristic
being the number of events. If the current weighting heuristic is not
the number of events then do not show this information.
browser/declarative_debugger.m:
Pass the trace node store to set_fallback_search_mode so that the
weights can be recalculated if the search strategy changes.
browser/declarative_edt.m:
In the mercury_edt typeclass, rename the edt_weight method to
edt_number_of_events and add a new method edt_subtree_suspicion.
The weight field of each suspect in the search space can either
be based on suspicion or number of events.
Add a field to the search_space type to determine which weighting
heuristic to use. Export predicates to get and set the current
weighting heuristic being used. If the weighting heuristic
changes the recalculate the weights of all the suspects.
When calculating the weight of a suspect use the current weighting
heuristic.
browser/declarative_execution.m:
Record a suspicion accumulator at each interface event which
can be used to calculate the suspicion of a subtree in the EDT.
Move the label_layout and proc_layout types as well as all utility
predicates for those types to a new module, mdbcomp.label_layout.
browser/declarative_oracle.m:
browser/declarative_user.m:
browser/debugger_interface.m:
Import mdbcomp.label_layout.
browser/declarative_tree.m:
Adjust for the extra field in interface nodes in the annotated trace.
Look at the weighting heuristic when calculating the weight of a
subtree.
browser/util.m:
mdbcomp/program_representation.m:
Move goal_path_string to mdbcomp.program_representation since
it is needed in mdbcomp.label_layout.
doc/user_guide.texi:
Document the new search mode.
mdbcomp/label_layout.m:
This module contains the types label_layout and proc_layout and
supporting predicates which were in mdb.declarative_execution.
These types are needed in the mdbcomp.slice_and_dice module.
mdbcomp/mdbcomp.m:
Include label_layout.
mdbcomp/slice_and_dice.m:
Add functions for calculating different suspicion formulas. The
intention is to experiment with different formulas in the future.
Export predicates for reading a dice from the C backend.
Export a predicate for retrieving the suspicion of a label
given a dice. This predicate uses the suspicion_ratio_binary
formula, since that seems most effective in my (as yet very limited)
experience. I will implement better ways to control and customise
the formula used in the future.
mdbcomp/trace_counts.m:
Add a function for constructing a path_port given a goal path and
a trace port.
If there is an unexpected exception when reading a trace counts
file then print the unexpected exception.
Add a predicate to convert trace count file types to a string and
vica versa.
runtime/mercury_stack_layout.h:
Fix a typo.
runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
Export a function to look up the trace count slot for a label.
Use this function when recording trace counts.
This function will also be used in the declarative debugger backend to
look up suspicions for labels.
Add a function to initialise the array which records which ports
need a goal path to uniquely identifiy the label.
Initially I used this array elsewhere which is why I exported it.
I didn't actually end up needing to use it in the final version,
but I'm still exporting it, since it might be useful in the future.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/dice.exp:
tests/debugger/declarative/dice.inp:
tests/debugger/declarative/dice.m:
Test the new search mode.
tests/debugger/declarative/info.exp:
tests/debugger/declarative/change_search.exp:
The weigting heuristic is now printed with the info command.
Also some information, such as the number of suspect events,
is no longer printed if the weigthing heuristic is not the number
of events (since then that information is not available).
trace/mercury_trace_declarative.c:
Add a function to setup the trace counts array with a suspicion for
each label. For efficiency the suspicion is converted from a
float to an integer between 0 and 100.
If a flag is set, then increment an accumulator with the
suspicion of each label executed as the annotated trace is being
constructed. Store the value of the accumulator at interface events,
so that the frontend can efficiently calculate the suspicion of any
subtree.
Remove a redundant variable and comment: the goal path is no
longer passed to the frontend, because the frontend has access to
the label_layout from which it can get the goal path (the variable and
comment are artifacts of a previous change).
When checking if a search mode is valid also check if failing and
passing trace counts are required for the search mode.
Allow abbreviations for the search mode arguments.
trace/mercury_trace_declarative.h:
Export the predicate to set up the suspicions for each label.
trace/mercury_trace_internal.c:
Allow passing and failing test case(s) to be passed
as arguments to the dd command.
If passing and failing test case(s) are supplied then record
suspicions in the annotated trace even if the sdq search mode
is not specified. The user could switch to the sdq search mode later
on.
Initialise some values which were causing warnings from the C
compiler.
browser/debugger_interface.m:
browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/util.m:
doc/user_guide.texi:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/dice.exp:
tests/debugger/declarative/dice.inp:
tests/debugger/declarative/dice.m:
tests/debugger/declarative/info.exp:
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
trace/mercury_trace_internal.c:
Estimated hours taken: 8
Branches: main
Add two new capabilities to the debugger.
The first capability is the idea of "held variables", variables that the
debugger holds onto even when execution has left the event they came from.
You can hold onto a variable via the mdb command "hold varname heldvarname".
You can suffix the name of the existing variable with a term path, in which
case the new held variable will refer only to the specified part of the term.
Later mdb commands can refer to the held variable by prefixing its name with
a dollar sign. For example, after "hold HeadVar__1^2 x", "$x" will refer to
the term that was the second argument of HeadVar__1 at the program point
at which the "hold" command was executed.
The second capability is the ability to compute the diff of two terms and
express those diffs as the term paths of the function symbols at which the two
terms differ, instead of the line numbers you get by using save_to_file and the
usual Unix diff command. The mdb command is "diff var1 var2". We limit the
number of term paths of difference sites that we display at any one time;
the mdb diff command has options to control this.
NEWS:
Mention the new capabilities.
doc/user_guide.texi:
Document the new mdb commands "hold" and "diff", the new mdb command
"held_vars" which simply lists the names of all the held variables
(just as "vars" lists the names of all the nonheld variables currently
accessible), and the concept of held variables.
doc/mdb_categories:
Update this file for the new mdb commands and concepts.
browser/browse_diff.m:
This new module implements the diff operation on terms.
browser/mdb.m:
Add the new module to the list of submodules of the mdb package.
browser/*.m:
Minor cleanups, such as importing only one module per line; there
are no algorithmic changes.
trace/mercury_trace_hold_vars.[ch]:
This new module implements the database of held variables.
trace/Mmakefile:
Mention the new module.
trace/mercury_trace_internal.c:
Implement the three new mdb commands.
trace/mercury_trace_vars.[ch]:
Modify the functions that recognize variable specifications or
process them to work with held variables as well as variables from
the current environment. This required some reorganization of the
internals of this module.
Provide some a utility function, MR_trace_parse_lookup_var_path,
for converting a string representing the specification of a term
(a variable and possibly some path within it) to the type and value
of that term. Make the utility function this is based upon,
MR_lookup_unambiguous_var_spec, replace the previous but less capable
MR_convert_var_spec_to_type_value.
trace/mercury_trace_spy.c:
Conform to the change in mercury_trace_vars.c.
trace/mercury_trace_util.c:
Make a utility function more robust.
trace/mercury_trace_alias.c:
Minor cleanups.
tests/debugger/queens.{inp,exp*}:
Update this test case to test the debugger's new capabilities.
tests/debugger/completion.{inp,exp*}:
Update this test case to expect the new mdb commands, and avoid the
ambiguity between "help" and "held_vars".
Estimated hours taken: 4
Branches: main
Reduce the amount of clutter on mgnuc command lines by moving arguments that
are always the same for a given directory into a file that is always consulted
by mgnuc in the current directory.
scripts/mgnuc.in:
Always include as C compiler arguments the contents of a file named
.mgnuc_copts in the current directory, if it exists. (It is named
.mgnuc_copts instead of .mgnuc_opts because it may not contain
general mgnuc options, such as --no-mercury-stdlib-dir.)
Mmake.workspace:
Comment out the additions of search paths to CFLAGS.
*/Mmakefile:
Delete the additions of search paths to CFLAGS.
*/.mgnuc_copts:
New files containing the directory-specific search paths, and in some
cases the required macro definitions. These replace what was taken out
of Mmake.workspace and */Mmakefile. In some cases, the old search paths
included inappropriate directories; the .mgnuc_copt files don't.
tests/.mgnuc_copts.ws:
New files containing the directory-specific search paths; bootcheck
makes tests/.mgnuc_copts from it.
*/.nocopyright:
Don't require copyright notices in .mgnuc_copts files.
tools/bootcheck:
Copy the various .mgnuc_copts files from the stage1 to stages 2 and 3.
They aren't needed in stage3 right now, but that may change.
Create tests/.mgnuc_copts.
browser/util.m:
Delete an unused and inappropriate #include.
scripts/Mmake.rules:
Use a single invocation of mkdir -p to create all subdirectories
needed by Java. Update a piece of documentation.
scripts/Mmakefile:
Reorganize the process of invoking config.status to avoid invoking
it on inappropriate files, and to ensure the right permissions
on the files it is invoked on.
scripts/prepare_tmp_dir_grade_part:
Copy the .mgnuc_copts files when populating tmp_dir.
Estimated hours taken: 0.2
Branches: main
browser/*.m:
Fix the current mixture of __ and . to module qualify module names
by standardizing on the latter.
Estimated hours taken: 17
Branches: main
This adds a module mdbcomp__trace_counts that reads in the
.mercury_trace_counts files produced by the compiler's trace mechanism.
The format of said files was slightly changed.
As the new module is to be used by the compiler and the debugger, it is
placed in the mdbcomp module. This required bringing some types from the
compiler into a new module within mdbcomp.
browser/trace_counts.m:
New module for reading execution trace summaries.
browser/prim_data.m:
New module holding types and predicates moved in from the compiler.
Types:
pred_or_func, sym_name, module_name, proc_label,
special_pred_id, trace_port
Predicates:
string_to_sym_name, insert_module_qualifier
The mode field of proc_label is now an int instead of a proc_id
to avoid pulling proc_id into mdbcomp.
browser/mdbcomp.m:
Add trace_counts and prim_data to the mdbcomp module.
browser/declarative_execution.m:
Renamed mdb's definition of module_name to flat_module_name
to avoid conflicts with the definition in mdbcomp__prim_data.
runtime/mercury_trace_base.c:
In the format of .mercury_trace_counts, write module and predicate
names now use quoted atom syntax so that names with spaces and
non-printable characters can be machine-parsed.
browser/:
compiler/:
Many changes to account for movement of types, and the change to
proc_label.
Estimated hours taken: 0.2
Branches: main
browser/dl.m:
browser/help.m:
browser/parse.m:
browser/util.m:
Bring these modules up to date with our current coding guidelines:
using predmode declarations and state variable syntax where relevant.
Estimated hours taken: 0.1
Branches: main
Remove the use of the old C interface in the debugger.
browser/dl.m:
browser/interactive_query.m:
browser/util.m:
Use the new foreign language interface rather than
the old one.
Estimated hours taken: 1
Branches: main
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/interactive_query.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
Add Mercury versions of code which has been defined only as
foreign procs so as to allow this directory to compile for
the non-C backends.
The Mercury versions just call private_builtin__sorry.
Estimated hours taken: 1.5
Branches: main
Change the declarative debugger so it always prints syntactically
correct goals.
browser/declarative_user.m:
Print atoms using browse__print_synthetic. This means that goals
will always be syntactically correct, even if they are printed
in the multi-line form.
Make the predicates write_decl{_init,_final,}_atom take an argument
of type browse_caller_type. When printing a single goal use the
caller type "print", and when printing a sequence of goals use
"print_all".
browser/browse.m:
When writing out a synthetic term using io__write_univ, check for
arguments with type util__unbound. Print such values as a single
unquoted underscore (io__write_univ would print an underscore in
single quotes, which means something different).
browser/util.m:
Export functions is_predicate and is_function to convert values of
type pred_or_func to values of type bool.
tests/debugger/print_goal.exp:
tests/debugger/queens_rep.exp:
Update the output of these tests after the change to browse.m.
tests/debugger/declarative/app.exp:
tests/debugger/declarative/app.exp2:
tests/debugger/declarative/filter.exp:
tests/debugger/declarative/filter.exp2:
tests/debugger/declarative/input_term_dep.exp:
tests/debugger/declarative/input_term_dep.exp2:
tests/debugger/declarative/output_term_dep.exp:
tests/debugger/declarative/output_term_dep.exp2:
tests/debugger/declarative/queens.exp:
tests/debugger/declarative/tabled_read_decl.exp:
tests/debugger/declarative/tabled_read_decl.exp2:
Update the output of these test cases.
Branches: main
Estimated hours taken: 2
Fix a bug which broke tests/debugger/interactive_query in non-GC grades,
e.g. asm_fast on murlibobo (dec-alpha-osf*).
browser/util.m:
Fix a bug: call_trace_getline needs to be annotated with
`will_not_call_mercury' instead of `may_call_mercury'.
This is required because the code for it accesses MR_hp,
which is only valid if `will_not_call_mercury' is specified.
The fix also required changing the return type from bool to int,
so that it can return the right value without calling Mercury code.
Estimated hours taken: 2
Branches: main
browser/util.m:
Fix a bug: call_trace_getline now may call Mercury. Asserting
will_not_call_mercury was causing succip to be clobbered,
which lead to test case failures whose symtom was that the
declarative debugger did not report the bug it found.
Estimated hours taken: 0.1
Branches: main
browser/util.m:
Fix a bug in Zoltan's last change which broke hlc grades.
Use `:- pragma foreign_import_module(c, bool)' rather
than `#include "bool.h"'.
Estimated hours taken: 12
Branches: main
Until now, programmers could add `tabled_for_io' annotations to foreign_procs
that do I/O, which asks the compiler to make those foreign_procs idempotent,
i.e. ensures that they are performed at most once even in the presence of a
retry operation in the debugger. This change adds a compiler option,
--trace-table-io-require, which generates an error if a foreign_proc that does
I/O does not have this annotation. Specifying this option thus ensures
that all I/O done by the program is idempotent.
In the future, we may want to have this option turned on in all debugging
grades. Until we decide about, the new option is not yet documented.
compiler/options.m:
Add the new option --trace-table-io-require.
compiler/handle_options.m:
Make --trace-table-io-require imply --trace-table-io.
compiler/table_gen.m:
If --trace-table-io-require is enabled, require all I/O primitives
to have the tabled_for_io annotation.
compiler/mercury_compile.m:
Pass I/O states to table_gen.m, since it can now generate error
messages.
trace/mercury_trace_util.h:
trace/mercury_trace_vars.c:
When calling Mercury code from the trace directory, disable I/O
tabling, since any I/O actions executed by Mercury code in the browser
directory (or by library code called from there) should not be tabled,
not being part of the user program.
Due to the depth of nesting, make mercury_trace_vars.c use four-space
indentation.
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
compiler/gcc.m:
compiler/mercury_compile.m:
compiler/passes_aux.m:
compiler/process_util.m:
compiler/stack_layout.m:
library/io.m:
library/time.m:
tests/debugger/declarative/tabled_read_decl.m:
Add a whole lot of tabled_for_io annotations, to enable the compiler to
bootstrap with --trace-table-io-require enabled.
In many cases, this required turning old-style pragma c_code into
pragma foreign_proc. While doing that, I standardized the layouts
of pragma foreign_procs.
browser/util.m:
Turn an impure semidet predicate into a pure det predicate with I/O
states, to allow it to be tabled. Make it return a Mercury bool
to indicate success or failure.
library/bool.m:
Add functions that allow C code to get their hands on the constants
`yes' and `no', for communication with Mercury code.
library/table_builtin.m:
Add debugging code to the main primitive of I/O tabling. This is
controlled both by the macro for retry debugging and a boolean global.
library/mercury_trace_base.[ch]:
Add the boolean global variable to switch the new debugging code in
table_builtin.m on and off.
library/mercury_trace_internal.c:
When starting I/O tabling with retry debug enabled, turn on the switch.
tests/debugger/queens.exp3:
New expected output file that applies when the library is compiled with
--trace-table-io-require.
Estimated hours taken: 4
Branches: main
Add MR_ prefixes to the remaining non-prefixed symbols.
This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.
runtime/mercury_std.h:
Add MR_ prefixes to bool, TRUE, FALSE, max, min,
streq, strdiff, strtest, strntest, strneq, strndiff,
strntest, NO_RETURN.
Delete a commented out definition of `reg'.
runtime/mercury_tags.h:
Add an MR_ prefix to TAGBITS.
configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
Add an MR_ prefix to PIC.
runtime/mercury_conf_param.h:
Allow non-prefixed PIC and HIGHTAGS to be defined on
the command line.
runtime/mercury_bootstrap.h:
Add backwards compatibility definitions.
RESERVED_MACRO_NAMES:
Remove the renamed macros.
compiler/export.m:
compiler/ml_code_gen.m:
Use MR_bool rather than MR_Bool (MR_Bool is
meant to be for references to the Mercury type
bool__bool).
runtime/mercury_types.h:
Add a comment the MR_Bool is for references to
bool__bool.
*/*.c:
*/*.h:
*/*.m:
Add MR_ prefixes.
Estimated hours taken: 20
Branches: main
Give the debugger the ability to print goals.
NEWS:
Mention the new ability.
browser/browser_info.m:
Define a new type, browser_term, which represents either a plain term,
or a "synthetic term", which is a string (predicate or function name),
a list of argument values, and an indication of whether the synthetic
term is a predicate goal (i.e. of the form p(a1, ..., an)) or a
function goal (i.e. of the form f(a1, ..., an-1) = an).
Add utility predicates for processing browser_terms.
browser/browse.m:
Add predicates for printing and browsing synthetic terms, and export
them to C code.
browser/browse.m:
browser/size_pretty.m:
Generalize lots of predicates to handle browser_terms, not just plain
terms.
browser/util.m:
Add a new type, "unbound", for use by mercury_trace_vars.c.
library/pprint.m:
Add functions for converting synthetic terms to docs.
Fix a potential efficiency problem: an unnecessary deconstruct.
runtime/mercury_type_info.h:
Add macros for defining static type_infos in C code.
Add macros for computing the names of type_ctor_infos even in non-hlc
grades.
Give C code access to the representation of bools and of values of
the new type "unbound".
trace/mercury_trace_browse.[ch]:
Add functions for printing goals.
trace/mercury_trace_internal.c:
Add code to recognize and handle the commands "print goal" and
"browse goal".
doc/user_guide.texi:
Document the new commands.
trace/mercury_trace_vars.[ch]:
Add a function to compute the components of synthetic terms.
tests/debugger/browse_pretty.{inp,exp*}:
Add new commands to the input to test the printing and browsing of
predicate goals, and update the expected outputs accordingly.
tests/debugger/polymorphic_output.{inp,exp*}:
Add new commands to the input to test the printing and browsing of
function goals, and update the expected outputs accordingly.
Estimated hours taken: 3
Branch: main
Add line numbers in Morphine.
trace/mercury_trace_external.c
Modify MR_output_current_slots() so that it takes a MR_Event_Info *
rather than a MR_Label_Layout *. The reason is that I need it to
get the parent of the current event. I need the parent of the current
goal because I want the line number where the call is made,
not the one where the procedure is defined.
Add the line number as an output of ML_DI_output_current_slots_*.
browser/util.m
Define the line_number type.
browser/debugger_interface.m
Add the line number as argument of output_current_slots/13.
extras/morphine/source/current_slots.op
Add the line number as argument of current_attributes/12.
extras/morphine/source/display.op
Add the line number as argument of attribute_display/12 and
of the attribute_display parameter.
extras/morphine/source/event_attributes.op
Define the new event attribute alias.
extras/morphine/non-regression-tests/test_vars.exp:
extras/morphine/non-regression-tests/queens.exp:
Update the expected output of the non-regression test.
extras/morphine/non-regression-tests/queens.in:
Disable the testing of the browser as it is currently broken.
Estimated hours taken: 20
Various fixes to get the GCC back-end interface to bootstrap.
library/exception.m:
Define function versions of mercury__exception__builtin_catch_3_p_*.
This is needed (a) in case we take their address, and (b) for the
GCC back-end interface, where we can't use C macros, since we're
compiling to assembler.
browser/dl.m:
browser/util.m:
browser/interactive_query.m:
compiler/stack_layout.m:
Add #includes for header files needed by these modules.
browser/dl.m:
Delete an unnecessary nested extern declaration, to avoid
a warning from `gcc -Wshadow'.
compiler/mlds_to_gcc.m:
When calling mlds_to_c to process foreign_code, make all
definitions public, so that the can be used from the assembler
code that we generate in mlds_to_gcc.
Don't call mlds_to_c to generate `.c' and `.h' files if the
module contains only `pragma foreign_decls', not `pragma
foreign_code', `pragma foreign_proc', or `pragma export'.
This change is needed to avoid calling mlds_to_c when
intermodule optimization is enabled and `pragma c_header_code'
declarations have been read in from the `.opt' file and have
propagated through to the MLDS. Calling mlds_to_c when the
module itself doesn't contain C code breaks things, since
Mmake won't compile and link in the generated `.c' files, but
those files contain the definition of the `*__init_type_tables()'
functions that are referenced by `*_init.c'.
XXX This is not quite right, since if the module itself contains
`pragma foreign_decls', the `.h' file might be needed.
But the Mercury standard library needs intermodule optimization
enabled for `make install' to work.
A better fix would be to ignore foreign_decls that were defined
in other modules, but to call mlds_to_c for foreign_decls
that were defined in the module that we're compiling.
compiler/modules.m:
Change the code which decides when to link in extra object files
for foreign code to reflect the above change to when mlds_to_gcc.m
invokes mlds_to_c.m.
compiler/mlds_to_c.m:
When target=asm, i.e. we're compiling to asm, but mlds_to_c.m
has been invoked to generate C code for a `foreign_code',
`foreign_proc', or `pragma export' declaration, don't generate
#include directives for the imported modules, since we may not
have generated any header file for them.
XXX This is a bit of a hack; it might sometimes lead to
problems, since the header files might sometimes be needed.
But including them unconditionally is definitely wrong,
since they may not exist, and so this change is needed to get
the compiler to bootstrap.
compiler/Mmakefile:
Add a dependency of mercury_compile on $(GCC_BACK_END_LIBS),
so that we know to relink it if the GCC back-end has changed.
(That variable is set to empty if we're not linking in the GCC
back-end, so it won't cause problems when not using the GCC
back-end.)
library/Mmakefile:
browser/Mmakefile:
compiler/Mmakefile:
Add an `ss' target, for use by tools/bootcheck.
tools/bootcheck:
Add `--target asm' option. If that is set, pass `--target asm'
to mmake, and build and compare the stage 3 `.s' files rather
than the `.c' files.
Also add `--make-opts' option, for passing options to `make'.
Put `-k' in `--make-opts', not `--mmake-opts', since `-k' is
an option to `make', not to `mmake'. This makes a difference
since although `make' options can be passed to `mmake', any
options after the first `make' option are assumed to be
options to `make', not to `mmake'.
Estimated hours taken: 2.5
Distinguish between predicates and functions in the declarative debugger.
browser/declarative_execution.m:
Add a pred_or_func field to trace_atom.
trace/mercury_trace_declarative.c:
Construct trace atoms with the extra field.
browser/declarative_user.m:
Print function call results using function syntax.
browser/debugger_interface.m:
browser/util.m:
Move the definition of type pred_or_func to util.m, so it can
be used by the declarative debugger as well as the external debugger.
runtime/mercury_stack_layout.h:
Update a reference to the location of type pred_or_func.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/func_call.{m,inp,exp}:
Test case for the new feature.
tests/debugger/declarative/*.exp:
tests/debugger/declarative/*.exp2:
Update expected output from tests.
Estimated hours taken: 0.1
Minor fixups to my last change.
browser/util.m:
- Avoid unnecessary casts.
- Use 'MR_free' rather than 'free'.
trace/mercury_trace_internal.c:
Better comments for MR_trace_get_command.
Estimated hours taken: 3
Allow multiple browser commands on one line, separated by semicolons.
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Separate the code for splitting lines and checking for EOF into
a new function, MR_trace_get_command.
browser/parse.m:
Call util__trace_get_command to read each command.
browser/util.m:
Implement util__trace_get_command, which calls the function
in the trace directory via an indirect pointer.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
Set up the indirect pointer to the new function.
tests/debugger/browser_test.inp:
tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp2:
Test the new feature.
Estimated hours taken: 20
Change the MercuryFile structure so that it now contains pointers to
functions which operate on the MercuryFile. This allows us, for
example, to create a MercuryFile structure which operates on sockets and
use the predicates in io.m to operate on the socket stream.
runtime/mercury_library_types.h:
Define the new implementation of MercuryFile structure.
The MercuryFile structure now contains pointers to functions to do
all the basic I/O operations.
Define macros to access all the different parts of the MercuryFile
structure.
runtime/mercury_file.h:
runtime/mercury_file.c:
Implement a MercuryFile structure which operates on C FILE *'s.
library/io.m:
Call the basic I/O operations from the MercuryFile structure.
Explicitly check that we are using a file stream when required.
As we cannot supply a variable number of arguments to a macro,
define a new function ML_fprintf() to provide fprintf functionality.
Hide all direct access to the MercuryFile data structure behind
macros.
browser/util.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
Hide all direct access to the MercuryFile data structure behind
macros.
extras/logged_output/Mmakefile:
extras/logged_output/README:
extras/logged_output/logged_output.m:
extras/logged_output/main.m:
Add an example of defining a new MercuryFile structure. This new
structure defines an output stream which writes to stdout and logs
to a file at the same time.
runtime/Mmakefile:
Add the new files mercury_file.{c,h}.
runtime/mercury_imp.h:
Include `mercury_file.h'.
Estimated hours taken: 1
Make all the modules in the browser library sub-modules of
module `mdb', to avoid link errors when users use module names
such as `parse'.
browser/Mmakefile:
browser/browser_library.m:
browser/mdb.m:
Rename browser_library.m to mdb.m.
Change `:- import_module' declarations to
`:- include_module' declarations.
browser/Mmakefile:
Remove the special case rule for `mer_browser.init' --
it doesn't work when the file names are not the same
as the module name. Instead, the default rule for `mdb.init'
is used and the output is copied to `mer_browser.init'.
browser/.cvsignore:
Rename header files, etc.
browser/*.m:
Add a `mdb__' prefix to the names of modules in the browser library
in `:- module' and `:- import_module' declarations.
trace/*.c:
Rename the header files for the browser library in
`#include' statements.
tests/hard_coded/Mmakefile:
tests/hard_coded/parse.m:
tests/hard_coded/parse.exp:
Test case.
Estimated hours taken: 0.25
browser/util.m:
Fix a bug reported by Erwan Jahier:
the order of the enum here should match that
in runtime/mercury_trace_base.h.
runtime/mercury_trace_base.h:
Update the documentation to point to browser/util.m
rather than browser/debugger_interface.m.
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.
Estimated hours taken: 6
If calling from the internal debugger, use readline input for the
interactive term browser and interactive queries.
browser/browse.m:
Change some if-then-elses to switches, which will help
catch errors if a new functor is added to the debugger type.
browser/parse.m:
browser/util.m:
Return a string from util__trace_getline/4 rather than a
list of chars, which saves converting from a string to a list
of chars and then back again.
browser/util.m:
Add a version of util__trace_getline that also takes I/O
stream arguments. Pass these arguments to MR_trace_getline.
browser/declarative_oracle.m:
Call util__trace_getline/4 to do input via readline (if
available). Improve error handling.
browser/interactive_query.m:
Call util__trace_getline to get user input, instead of
standard library predicates.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Add two I/O stream arguments to MR_trace_getline.
Estimated hours taken: 5
Use the same method of input for the browser as for the internal
tracer. Previously, the browser did input via the Mercury library
and the internal tracer did input via readline (if available). This
did not work properly if files were redirected into stdin, which meant
that test cases could not be written for the browser. This change
also adds a test case.
browser/util.m:
Add a predicate, util__trace_getline/4, which does input via
the same method used by the internal debugger.
browser/parse.m:
Call util__trace_getline/4 instead of io__read_line/3.
browser/browse.m:
Pass the prompt to browser/parse.m as a string, rather than
printing it before calling.
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Declare MR_trace_getline extern.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
Make MR_trace_getline available to the browser via a function
pointer.
tests/debugger/Mmakefile:
Add the new test case.
tests/debugger/browser_test.m:
tests/debugger/browser_test.inp:
tests/debugger/browser_test.exp:
The new test case.
runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
Export MR_tracing_not_enabled() for use by browser/util.m.
Estimated hours taken: 40
Add a simple term browser for use by the trace-based debugger.
This is minimal but useful browser. Not included in this version
are a scripting language, Windows Explorer-style tree expansion,
and other features not yet thought of.
N.B. This still needs to be hooked into the debugger.
browser/Mmakefile:
Added target browse_test.
browser/browser_library.m:
Added modules required for the browser.
browser/browse_test.m:
A simple driver for the browser with an example
data structure to browse. (new file)
browser/browse.m:
The browser proper. (new file)
browser/parse.m:
Parser for browser's command language. (new file)
browser/util.m:
Miscellaneous utilities used in the browser code. (new file)
browser/frame.m:
Bare minimal ASCII graphics frames. (new file)