The big diff that replaced the item list with proper parse trees included code
that the compiler couldn't handle in decldebug grades, aborting with a message
about liveness mismatch between different switch arms. The problem occurred
when compiling this code in generate_missing_start_section_warning_int,
which is one arm of a switch on !.MissingStartSectionWarning:
!.MissingStartSectionWarning =
have_not_given_missing_section_start_warning,
!:MissingStartSectionWarning =
have_given_missing_section_start_warning,
Pieces = [invis_order_default_start(1), ...],
_Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(Context, [always(Pieces)])])
The problem was liveness.m's handling of the from_ground_term_construct
scope that is generated for the assigmnet of the ground term to Pieces.
compiler/liveness.m:
During the first pass through the procedure body, the liveness pass,
replace with the empty conjunction any from_ground_term_construct scopes
that construct terms to assign to dead variables. This prevents the
second pass, the deadness pass, from including the dead variable
(Pieces in the above example, after the assignment to _Spec was
optimized away by earlier passes) in the set of variables that
have been seen, since obviously, they won't be seen in the other arms.
This inclusion was the cause of the assertion failure that led to
the compiler abort.
Improve the existing debugging infrastructure to help find bugs like this,
by printing out what the selected procedure's body looks like before
as well as after the initial requantification.
compiler/quantification.m:
Replace from_ground_term_construct scopes whose ground term is assigned
to a dead variable with empty conjunctions, so that the compiler passes
between the first quantification after mode checking and the liveness
pass also see a smaller HLDS.
Implement an unrelated improvement whose possibility I discovered when
investigating why a version of the test case *without* the from_ground_term
scope wasn't getting the abort. When processing unifications, build up the
set of variables in the unification directly, not by recording a bunch
of maybe(somethings)s and then processing the somethings, if they existed,
later. This yields code that is shorter, simpler *and* faster.
tests/valid/liveness_disagree.m:
A new test case for this bug. It is a cut-down version of
generate_missing_start_section_warning_int.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
Enable the new test case, and try to compile it in a declarative debugging
grade.
compiler/assertion.m:
compiler/deep_profiling.m:
compiler/lookup_switch.m:
compiler/par_loop_control.m:
Add module qualifications in several places. I found the need for these
when I temporarily redefined the set_of_var type to use sets instead of
sparse_bitsets, to make debugging the bug in liveness.m easier; without
them, I got errors about excessive overloading.
Do some other cleanups as well.
tests/debugger/all_solutions.exp4:
tests/debugger/exception_cmd.exp3:
tests/debugger/loopcheck.exp3:
tests/debugger/uci_index.exp2:
tests/declarative_debugger/Mmakefile:
tests/declarative_debugger/builtin_call_rep.exp:
tests/declarative_debugger/catch_retry.exp:
tests/declarative_debugger/condition_bug.exp:
tests/declarative_debugger/find_origin.exp3:
tests/declarative_debugger/lpe_example.exp3:
tests/declarative_debugger/priv_builtin_bug.exp:
tests/declarative_debugger/solns.exp3:
tests/declarative_debugger/sort.exp:
tests/declarative_debugger/track_through_catch.exp:
tests/declarative_debugger/typed_unify.exp:
Update all these expected outputs for the changes in line numbers
caused by my cleanups of the test cases early in 2015.
For the declarative_debugger/{condition_bug,sort} test cases, also
update them for the change to print the types and values of foreign types.
tests/hard_coded/type_qual.{m,exp}:
This test case failed for an earlier version of this diff, so add some
context to its outputs, to make such failures easier to debug.
To make *that* easier, bring it to date in programming style.
library/solutions.m:
Fix mode error in `solutions' predicate in the `multi' mode.
Convince the compiler with a run-time check that the solution
list will be non-empty.
Similarly for `builtin_solutions'.
tests/debugger/declarative/solns.exp3:
tests/debugger/loopcheck.exp3:
Update expected outputs.
Estimated hours taken: 1
Branches: main
Fix some tests that fail in the decldebug grades.
tests/debugger/Mmakefile:
Don't run the tailrec1 test in decldebug grades, as the tail
recursion optimisation isn't supported in those grades.
tests/debugger/loopcheck.exp3:
Update an event number. Presumably this changed because of
changes to the standard library.
tests/debugger/declarative/condition_bug.exp:
tests/debugger/declarative/condition_bug.inp:
Break on stream.put/4 instead of io.write_string/4.
Don't expect context for put method calls.
tests/debugger/declarative/condition_bug.m:
Remove a comment that doesn't seem to apply anymore.
tests/debugger/declarative/solns.exp3:
tests/debugger/declarative/solns.inp3:
Fix the input and expected output for this test in the
decldebug grade.
Estimated hours taken: 1
Branches: main
Fix some test case failures in decldebug grades.
tests/debugger/declarative/loopcheck.exp3:
Expect a different number of events after recent changes to io.m.
tests/debugger/declarative/condition_bug.{m,inp,exp}:
Update this test case for recent changes to term_to_xml.m.
Document the remaining bug that causes this test case to still fail.
tests/EXPECT_FAIL_TESTS.all_grades:
For now, expect the condition_bug test case to fail for grades that
execute it.
runtime/mercury_type_info.[ch]:
Add a utility function to print the type represented by a type_info.
trace/mercury_trace_vars.c:
Use the new utility function to print the type of each variable when
the var_details command is given. This is how I tracked down the
remaining bug in the condition_bug test case.
Estimated hours taken: 16
Branches: main, release
Replace the "set" command of mdb with a bunch of commands: the `format',
`format_param', `list_context_lines', `list_path', `xml_browser_cmd',
`xml_tmp_filename', `fail_trace_counts', `pass_trace_counts' and
`max_io_actions' commands. Each of these set just one parameter
or one of set of closely related parameters.
Move all these commands, and some existing commands that set parameters
that were elsewhere, to the "parameter" command category.
Extend some of these commands so that if given no arguments, they report
the current values of the parameters they would otherwise set.
Replace the "set" commands of the mdb browser and of the declarative debugger
with a bunch of commands: "format", "depth", "size", "width", "lines",
"actions" and "params" (the last prints the current value of the parameters).
For each category of mdb commands, create files mercury_trace_cmd_<cat>.[ch],
and move the functions dealing with that category of commands there from
mercury_trace_internal.c. Give each of these new files a logical structure
that was sometimes missing from the relevant parts of mercury_trace_internal.c.
NEWS:
Mention these changes.
doc/mdb_categories:
Document these changes.
doc/user_guide.texi:
Document these changes.
Fix an old documentation bug: you couldn't set listing paramaters
from a declarative debugger command.
Fix an old documentation bug: the description of the goal_path step
for scopes was obsolete.
Fix some obsolete references to : as module qualifier.
browser/parse.m:
Update the browser command set along the lines at the top.
browser/declarative_user.m:
Update the declarative debugger command set along the lines at the top.
Move the declaration for the type representing declarative debugger
commands to near the top of the file.
browser/browser_info.m:
Provide some access predicates.
Update the predicate that generates mdb commands to save the persistent
state of the debugger to generate the new forms of parameter commands.
Move types and predicates for dealing with browser parameters from
browse.m to here, so that declarative_user.m can use them too.
browser/browse.m:
Delete the code moved to browser_info.m, and conform to the other
changes in the other modules.
browser/listing.m:
Provide a predicate to return the type of listing paths.
scripts/mdbrc.in:
Update the commands that set the XML parameters.
scripts/Mmakefile:
Get mmake to rebuild mdbrc from mdbrc.in when mdbrc.in changes.
trace/mercury_trace_internal.c:
trace/mercury_trace_cmds.h:
trace/mercury_trace_cmd_*.[ch]:
Implement the changes described at the top.
Fix an old bug: the commands that update the search path for the "list"
command don't make the search path term permanent, which is needed in
non-conservative-gc grades.
trace/mercury_trace_spy.c:
Fix some obsolete references to : as module qualifier.
trace/mercury_trace_browse.[ch]:
Delete the functionality now moved to mercury_trace_cmd_parameter.c.
tests/debugger/mdb_command_test.inp:
Update the set of commands being tested.
tests/debugger/save.{inp,exp}:
Update the parameter commands in this test case.
Estimated hours taken: 4
Branches: main
Trace builtin and private_builtin (with the exception of external predicates
and those that are polymorhphic, but have no extra type_info arguments).
This allows subterms to be traced through calls to predicates in builtin
and private_builtin and fixes an assertion failure in the declarative debugger
that was triggered when an untraced builtin called a traced predicate
(the debugger would then think the events from the traced predicate were
child events of the parent of the untraced predicate, which would cause the
assertion failure).
compiler/code_gen.m:
compiler/hlds_pred.m:
compiler/mercury_compile.m:
compiler/ml_code_util.m:
compiler/polymorphism.m:
compiler/stack_layout.m:
compiler/term_constr_initial.m:
mdbcomp/prim_data.m:
mdbcomp/program_representation.m:
Move no_type_info_builtin from compiler/hlds_pred.m to
mdbcomp/program_representation.m, so that the debugger can call it
to see what builtin polymorphic predicates do not have extra type_info
arguments.
Define pred_is_external to be true for predicates defined with
:- external. The debugger needs to know not to expect any events for
such predicates.
Trace the builtin and private_builtin modules.
tests/debugger/loopcheck.exp3:
tests/debugger/uci.exp2:
tests/debugger/uci_index.exp:
Changes to expected output due to the fact that builtins are now
traced.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/typed_unify.exp:
tests/debugger/declarative/typed_unify.inp:
tests/debugger/declarative/typed_unify.m:
Test tracking of a subterm through a builtin.
Estimated hours taken: 1
Branches: main
Ensure the variable numbers we use procedure layouts are consistent across
trace levels.
compiler/continuation_info.m:
compiler/code_gen.m:
Record procedure bodies even if the trace level is not --trace rep,
to allow it to be used to compute the variable number compression map.
compiler/stack_layout.m:
Always compute and use the variable number compression map.
tests/debugger/field_names.exp:
tests/debugger/declarative/dependency.exp:
Update the expected variable numbers.
tests/debugger/declarative/loopcheck.exp:
Expect fewer events in declarative debugging grades after my previous
change to buultin.unify.
Estimated hours taken: 2
Branches: main
Remove call depth numbers from standardized event printing. This will make
maintaining the debugger test cases easier since a lot of the expected outputs
differ only in the call depth of their events, because of deep tracing of the
standard library in the decldebug grade.
Not all the debugger tests are run with standardized event printing, so
printing of call depths will still be exercised.
tests/debugger/breakpoints.exp
tests/debugger/breakpoints.exp2
tests/debugger/browser_test.exp
tests/debugger/exception_cmd.exp
tests/debugger/exception_cmd.exp2
tests/debugger/exception_cmd.exp3
tests/debugger/exception_value.exp
tests/debugger/exception_value.exp2
tests/debugger/exception_vars.exp
tests/debugger/existential_type_classes.exp
tests/debugger/existential_type_classes.exp2
tests/debugger/exported_eqv_type.exp
tests/debugger/higher_order.exp
tests/debugger/interpreter.exp2
tests/debugger/lambda_expr.exp
tests/debugger/loopcheck.exp3
tests/debugger/loopcheck.inp2
tests/debugger/nondet_stack.exp
tests/debugger/nondet_stack.exp2
tests/debugger/polymorphic_output.exp
tests/debugger/polymorphic_output.exp2
tests/debugger/polymorphic_output.exp3
tests/debugger/print_goal.exp
tests/debugger/print_table.exp
tests/debugger/queens.exp
tests/debugger/queens.exp2
tests/debugger/resume_typeinfos.exp
tests/debugger/retry.exp
tests/debugger/retry.exp2
tests/debugger/tabled_read.exp
tests/debugger/tabled_read_decl.exp
tests/debugger/tabled_read_unitize.exp
tests/debugger/type_desc_test.exp
tests/debugger/declarative/aadebug.exp
tests/debugger/declarative/app.exp
tests/debugger/declarative/args.exp
tests/debugger/declarative/big.exp
tests/debugger/declarative/filter.exp
tests/debugger/declarative/if_then_else.exp
tests/debugger/declarative/input_term_dep.exp
tests/debugger/declarative/io_stream_test.exp
tests/debugger/declarative/io_stream_test.exp2
tests/debugger/declarative/output_term_dep.exp
tests/debugger/declarative/propositional.exp
tests/debugger/declarative/remember_modes.exp
tests/debugger/declarative/special_term_dep.exp
tests/debugger/declarative/tabled_read_decl.exp
tests/debugger/declarative/trust.exp
Remove call depth numbers from output run with standardized event
printing.
trace/mercury_trace_internal.c
Remove call depth from standardized event printing.
Estimated hours taken: 1
Branches: main
Fix some debugger test cases failing in grade decldebug because the library is
deep traced in that grade.
tests/debugger/Mmakefile
Set INP variable to inp2 for decldebug grade, so loopcheck can have
different input in this grade.
tests/debugger/all_solutions.exp4
tests/debugger/exception_cmd.exp3
tests/debugger/print_table.exp3
tests/debugger/retry.exp3
New expected outputs with the only differences the event and depth
number of some events.
tests/debugger/exception_value.exp3
This expected output had its print format set to verbose for some
reason, so overwrote this expected output with new output with flat
format (the default) and new depth/event numbers for decldebug grade.
tests/debugger/polymorphic_output.exp3
This expected output still used the non-standardized event printing,
even though the test is run with standardized event printing. So
replaced this expected outout file with the decldebug expected output.
tests/debugger/loopcheck.exp3
tests/debugger/loopcheck.inp2
Add new input that only prints events in loopcheck module, otherwise
there are just way too many events printed.