Estimated hours taken: 0.1
Branches: main
tests/debugger/*.exp2:
Update the expected outputs of debug grade bootchecks for the recent
update that changed to format of goal paths for switch arms.
Estimated hours taken: 3
Branches: main
Make the stack and nondet_stack commands in mdb limit the number of lines
printed, instead of the number of stack frames reported on.
runtime/mercury_stack_trace.[ch]:
Add a mechanism to limit the number of lines printed by stack traces.
trace/mercury_trace_internal.c:
Change the existing "stack" and "nondet_stack" mdb commands to make the
integer argument specify the number of lines printed by default, not
the number of stack frames reported on, since this is usually what is
wanted. The number of stack frames N to be reported on can still be
specified, via the new option -fN.
Add a new mdb command, "stack_default_limit", that specifies the
default number of lines to print in stack traces.
trace/mercury_trace_external.c:
Conform to the changed interfaces in mercury_stack_trace.h.
doc/user_guide.texi:
Document the changes to mdb commands.
tests/debugger/mdb_command_text.inp:
Test the documentation of the new command.
tests/debugger/completion.exp*:
Expect to see the new stack_default_limit command listed.
tests/debugger/queens.exp*:
Expect the new meaning of the stack command.
tests/debugger/nondet_stack.{inp,exp*}
Use the new -f option of the nondet_stack command to specify the
printing of the same number of frames as before. Update the expected
accordingly.
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: 8
Branches: main
Optimize away stack slots storing dummy values; values of the io__state and
store__store types.
compiler/stack_alloc.m:
Allocate distinct negative stack slot numbers to values of dummy types.
We need
compiler/hlds_pred.m:
Add a predicate for testing whether a value is of a dummy type.
compiler/code_into.m:
When constructing the list of live locations after a call, do not
include the negative stack slots containing dummy values. The list
of live locations is used by the (future) native collector, which
should ignore dummy types, and by the debugger. The debugger can't
do anything with these dummy values on the stack except tell the
user about their existence, which doesn't do the debugger user any
good.
We still keep liveness information about dummy values in registers
at calls and returns, since both the procedural and declarative
debuggers need to know procedures' full argument lists.
With respect to the list of live locations before the call, which
was used only by the (now extinct) value numbering optimization,
filter out all dummy types, since their values need not be preserved.
compiler/trace.m:
Do not ask the code generator to preserve values of dummy types,
since doing so would require referring to negative stack slots.
compiler/unify_gen.m:
compiler/var_locn.m:
Fix a couple of situations in which we could refer to the negative
stack slots we now allocate to dummy values.
compiler/call_gen.m:
Reorder some code to make the source match what happens at runtime.
compiler/llds_out.m:
Fix the formatting of the sanity check for negative stack slots.
compiler/handle_options.m:
Since the --debug-opt-pred-id option is useless without --debug-opt,
make --debug-opt-pred-id option imply --debug-opt. This was useful
in debugging this diff.
trace/mercury_trace.c:
Adapt the test for whether a retry is across I/O. We used to base the
test on whether the retried predicate has any I/O state arguments,
and if so, whether the original I/O state variable is still around
on the stack. After this change, the answer to the second half of
that question would always be "no", so we now use only the first half:
whether the retried predicate has any I/O state arguments. This
requires us to consider more retries to be retries across I/O, but
from the point of view of a user who may not remember whether the I/O
predicate has done any I/O so far or not, is arguably more consistent
than our previous policy.
Allow retries even if a value of type store.store is missing, since
store.store is a dummy type just as io.state is.
trace/mercury_trace.c:
compiler/type_util.m:
Document the fact that you need to update both these files if you
want to modify the set of dummy types.
tests/debugger/retry.{inp,exp,exp2}:
Due to the change in mercury_trace.c, one retry in this test case
changes to being retry over I/O. Update the test input to force this
retry over I/O, and expect the expanded input to be echoed in the
output.
tests/debugger/nondet_stack.{exp,exp2}:
Update these expected outputs to account for the fact that we now need
fewer stack slots to hold old I/O states when debugging is enabled.
Estimated hours taken: 1.5
Branches: main
Make debugging of minimal model tabling more convenient.
compiler/handle_options.m:
Make -Dmm generate HLDS dumps tailored for understanding the
code of procedures transformed by minimal model tabling.
runtime/mercury_minimal_model.c:
When printing the stack segments being saved, print the values of
variables in the affected stack frames.
runtime/mercury_stack_trace.c:
When dumping the nondet stack, print the name of the procedure
that established each ordinary frame, and the goal path at which
control will reenter the stack frame, if this information is available.
Since mercury_minimal_model.c now asks for the printing of variable
values (which is done by Mercury code) while execution is outside
the debugger and hence while execution tracing may be enabled,
explicitly turn off debugging while in the Mercury code that prints
variable values.
runtime/mercury_trace_base.[ch]:
Provide a simple mechanism for turning off debugging functionality
in a region of code.
trace/mercury_trace_internal.c:
Use the new mechanism in mercury_trace_base to handle turning off
debugging output inside the debugger. This also allows us to simplify
the code implementing the "flag" mdb command.
Make the reports generated by the "unhide_events" and "table_io"
commands follow the same format as other commands.
Note that mercury_trace_declarative.c doesn't use the new mechanism,
because it wants the reexecution of the call being debugged to be
exactly the same as its first execution; in particular, turning off
I/O tabling for reexecution would generate incorrect results.
tests/debugger/nondet_stack.exp*:
tests/debugger/tabled_read.exp*:
tests/debugger/tabled_read_decl.exp*:
tests/debugger/tabled_read_unitize.exp*:
tests/debugger/io_stream_test.exp*:
tests/debugger/declarative/tabled_read_decl.exp*:
Update the expected out of these test cases to reflect the new
functionality above.
Estimated hours taken: 160
Branches: main
This change adds new facilities for debugging minimal model tabling, and
has several bug fixes found with the aid of those facilities. Most of the
diff affects the behavior of the system only in minimal model grades and/or
when debugging flags are defined.
compiler/ite_gen.m:
In minimal model grades, surround the conditions of if-then-elses
with calls to three functions. These functions detect when a
condition fails due to one or more suspensions, and abort the
program. (After resumptions, the condition may actually have
solutions, but by then the computation has committed to the wrong
path.)
compiler/table_gen.m:
Change the program transformation for model_non predicates
to use a switch instead of nested if-then-elses, to avoid the
overhead of wrapping the condition. The version with switches
is also a bit easier to debug.
The transformation for model_det and model_semi predicates
stays as before, because for such predicates finding the status
(which we want to switch on) requires computation, not just a lookup.
Switch to state variable syntax in the affected predicates.
Make the error message for an internal error in loopcheck predicates
more precise.
Mark the code fragments that modify tabling data structures as impure
and code fragments that examine tabling data structures as semipure.
runtime/mercury_stacks.[ch]:
Implement the new stack of possibly negated contexts that we use
to detect false failures due to suspensions in negated contexts.
Fix a bug: don't refer to MR_cut_stack[-1].
Shorten the name of the generator stack.
runtime/mercury_context.[ch]:
runtime/mercury_memory.c:
runtime/mercury_wrapper.[ch]:
Allocate memory for the new stack of possibly negated contexts.
Use the shortened name of the generator stack.
runtime/mercury_regorder.h:
Allocate a pointer for the new stack of possibly negated contexts.
runtime/mercury_minimal_model.[ch]:
A new module holding the part of mercury_tabling.[ch]
that is specific to minimal model tabling. This version contains
tools to help debugging of minimal model tabling, as well as some
bug fixes found with the aid of those tools.
runtime/mercury_tabling.[ch]:
Remove the code moved to mercury_minimal_model.[ch], and add the
code moved here from trace/mercury_trace_internal.c.
Add prefixes to a bunch of structure fields to make it easier
to read code accessing those fields.
Add mechanisms to allocate and copy tabling structures with type
safety.
runtime/mercury_imp.h:
#include the new header file, if it is needed.
runtime/Mmakefile:
Mention the new module, and fix sortedness errors.
runtime/mercury_stack_trace.c:
Fix a bug that sometimes caused stack traces to abort in minimal model
grades: they were trying to get layout information from labels
that do not have them, such as do_fail.
If MR_TABLE_DEBUG is defined, print the locations of stack frames
when doing stack dumps.
runtime/mercury_trace_base.h:
Export to mercury_stack_trace.c the labels that we use to let the
debugger get control at redos and fails, since they don't have
layout information.
runtime/mercury_types.h:
Move typedefs here from mercury_tabling.h, and add typedefs for some
newly added types.
runtime/mercury_engine.[ch]:
Add a table mapping debugging flags to their offsets in the
MR_debugflag array, for use in the debugger.
runtime/mercury_misc.c:
Make the formatting of det stack pointers the same as nondet stack
pointers in debugging output.
runtime/mercury_debug.[ch]:
Add conditionally compiled debugging output when creating temp frames
on the nondet stack.
library/table_builtin.m:
Conform to the new names of some fields.
Add a predicate to return the status of a subgoal.
Add conditionally compiled debugging code.
library/Mmakefile:
Make table_builtin.m depend on runtime/mercury_minimal_model.h.
trace/mercury_trace.c:
Conform to the new names of some fields.
trace/mercury_trace_internal.c:
Add two new mdb commands, to print the cut stack and the new possibly
negated context stack.
Add two new mdb commands to print a subgoal and a consumer.
Move some of the code to print tabling-related
data structures to runtime/mercury_tabling.[ch].
Add a new mdb command to report the values of debugging flags and
to set and clear them. Previously, one had to turn on these debugging
flags with environment variables, which were problematic because they
turned on diagnostic printouts even in Mercury programs that *weren't*
being debugged, such as the Mercury compiler when being used to
generate the program to be debugged. Now the flags can be turned on
from a .mdbrc file, which eliminates much setting and unsetting of
environment variables.
doc/user_guide.tex:
Document the new mdb commands.
tests/debugger/mdb_command_test.inp:
Test the documentation of the new mdb commands.
tests/debugger/completion.exp:
Expect the new commands in the command completion test.
tests/debugger//nondet_stack.exp*:
Expect the new format of det stack pointers.
tests/debugger/all_solutions.exp3:
tests/debugger/exception_value.exp3:
tests/debugger/declarative/catch.exp3:
tests/debugger/declarative/ho5.exp3:
tests/debugger/declarative/throw.exp3:
New expected test cases for use in minimal model grades. They
differ from existing expected output files only in the precise
phrasing of error messages.
tests/debugger/declarative/Mmakefile:
Disable the untraced_subgoal test case in .mm grades, since we don't
pass it yet.
tests/tabling/Mmakefile:
Enable the mday test case, now that we pass it.
Estimated hours taken: 14
Branches: main
Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.
Infix `.' now has associativity yfx and priority 10.
NEWS:
Report the change.
configure.in:
Amend the test for an up-to-date Mercury compiler to check whether
it recognises `.' as a module qualifier.
compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
Change `:' to `.' as module separator for output.
compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
As above.
Fixed a bug where `.' was not being recognised as a module separator.
doc/reference_manual.texi:
Report the change.
library/term_io.m:
Ensure that infix `.' is written without surrounding spaces.
tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
Test case added.
Estimated hours taken: 1
Branches: main
compiler/handle_options.m:
Fix a bug: make --trace-table-io-all imply --trace-table-io, as
originally intended. Without this, the "table_io start" mdb command
doesn't do what it should in debugging grades, because the I/O
primitives in the standard library aren't actually tabled.
tests/debugger/Mercury.options:
Test the implication from --trace-table-io-all to --trace-table-io
by specifying only the former.
tests/debugger/nondet_stack.exp2:
Update the expected output. Some stack frames in debug grades are now
one word bigger.
Estimated hours taken: 2
Branches: main
Fix (most of) the expected outputs of the debugger test cases after my recent
changes. In some cases, this involved modifying the input scripts to make tests
less dependent on event numbers.
tests/debugger/Mmakefile:
Use MDB_STD instead of MDB for more test cases than before.
Disable the output_term_dep test case, since it doesn't actually test
anything that the other test cases don't test, and it prints so many
events that its .exp files depend on event numbers far too much.
tests/debugger/*.exp*:
tests/debugger/*.inp:
Update expected outputs, and in some cases, the inputs.
Estimated hours taken: 10
Branches: main
Improve variable naming in the debugger. Where possible, use
the user's argument names rather than `HeadVar__N'.
compiler/clause_to_proc.m:
Use the user's names for the arguments of
`:- pragma foreign_proc' procedures.
compiler/simplify.m:
When performing excess assignment elimination with `--trace deep',
don't replace a variable with a meaningful name with `HeadVar__N'
or an unnamed variable.
compiler/trace_params.m:
Add a predicate `trace_level_needs_meaningful_var_names'
for use by simplify.m.
compiler/typecheck.m:
For predicates with a single clause, attempt to replace the
`HeadVar__N' variables with the user's original head variables.
trace/mercury_trace_declarative.c:
trace/mercury_trace_vars.c:
Don't assume head variables have names of the form `HeadVar__N'.
Print the argument number when printing the names of
head variables.
tests/debugger/browser_test.inp:
tests/debugger/completion.inp:
Change names of variables in `print' commands.
tests/debugger/*.exp:
tests/debugger/*.exp2:
tests/debugger/declarative/dependency.exp:
tests/invalid/aditi_errors.err_exp:
tests/invalid/mode_inf.err_exp:
tests/invalid/record_syntax_errors.err_exp:
Update expected output.
Estimated hours taken: 50
Branches: main
Allow the debugger to print higher order values and typeinfos, mainly by
making the committed choice modes of the predicates in deconstruct.m to
deconstruct higher order values and typeinfos. (The non committed choice
versions will continue to return only placeholders.)
Having the debugger print typeinfos is occasionally useful but more often
it is just distracting. This change therefore adds a new debugger command,
"print_optionals", that toggles the printing of optional values. For now,
the only optional values are typeinfos.
NEWS:
Mention the new capability and the new predicates in the library.
Mention the predicates added previously that allow the caller to
specify how non-canonical terms should be handled, since the change
in their semantics that we anticipated when they were added has now
happened, and their semantics should now be more stable.
browser/browser_info.m:
Use the predicates in the deconstruct.m instead of std_util,
to make the choice of noncanonical term method handling explicit.
browser/browse.m:
When writing small terms using io__write_univ, explicitly use
the same noncanonical term handling method as browser_info.m
library/io.m:
Add predicates to retrieve the current input and output streams.
Add versions of io__write_univ that specify the stream and maybe
the method of handling noncanonical terms.
Add a mode to io__write_list that allows the closure that prints the
list elements to be cc_multi.
All of these are for the new functionality in the browser.
runtime/mercury_ml_expand_body.h:
In committed choice contexts, deconstruct closures as if they were
ordinary terms, with the function symbol being the name of the
predicate/function and the arguments being the terms stored in
the closure.
In committed choice contexts, deconstruct typeinfos as if they were
ordinary terms, with the function symbol being the name of the type
constructor and the arguments being the type constructor's arguments.
runtime/mercury_type_info.[ch]:
Add a new function, MR_collapse_ctor_equivalences, for use by
mercury_ml_expand_body.h.
Delete a redundant function comment.
library/deconstruct.m:
Document the changes in the behavior of the predicates defined in this
module as a result of the change to mercury_ml_expand_body.h.
runtime/mercury_ho_call.h:
runtime/mercury_stack_layout.h:
Add prefixes on structure field names that did not have them.
browser/dl.m:
Add prefixes where needed by the changes to mercury_ho_call.h.
runtime/mercury_layout_util.[ch]:
Remove the first argument of MR_materialize_closure_typeinfos, since
its correct value is always the same part of the second argument.
runtime/mercury_deep_copy_body.h:
Do not pass the first argument of MR_materialize_closure_typeinfos.
Add field name prefixes where necessary.
compiler/modules.m:
The mercury_builtin module is no longer part of the library.
compiler/pd_debug.m:
compiler/rl_analyze.m:
Minor updates to avoid trying to take the address of io__write_list,
since it now has more than one mode.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
trace/mercury_trace_vars.[ch]:
Add a parameter to MR_trace_browse_all_on_level that specifies
whether we should print values of type type_info.
trace/mercury_trace_vars.c:
Do not ignore predicates and functions anymore.
runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
Pass the new parameter of MR_trace_browse_all_on_level.
trace/mercury_trace_internal.c:
Implement the "print_optionals" command.
doc/user_guide.texi:
Document the "print_optionals" command.
tests/debugger/mdb_command_test.inp:
Test the documentation of "print_optionals".
tests/debugger/higher_order.{m,inp,exp,exp2}:
A new test case to exercise the ability to print higher order values.
Note that the format of the predicate names in the output should be
improved, but that is a separate change since doing it the right way
requires bootstrapping.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/nondet_stack.exp*:
Update the expected output to reflect the fact that nondet stack dumps,
being intended for debugging, include type_infos.
tests/debugger/tabled_read_decl.exp*:
Update the expected output to reflect the fact that for maximum
usefulness, the printing of I/O action atoms prints meaningful
type_infos.
tests/hard_coded/deconstruct_arg.*:
tests/hard_coded/write_reg1.*:
Expand these tests to check that we handle higher order values
correctly not just when canonicalizing but also in committed choice
modes.
Estimated hours taken: 32
Branches: main
Make the debugging of minimal model tabling easier by providing a mechanism
to print the contents of the nondet stack, *including* the values of the
variables in its stack frames, even for frames which are not ancestors
of the currently executing call.
runtime/mercury_stack_trace.[ch]:
Add functions for traversing the nondet stack, and for keeping track of
through which label control returns to each nondet stack frame, so that
we know which label's layout structure to interpret the stack frame's
contents. For some, this will be the return label of a call; for
others, it will be the label of a resumption point stored in a
redoip slot.
Rename an old function to allow the new one to fit into our naming
scheme.
runtime/mercury_stack_trace.[ch]:
runtime/mercury_tabling.c:
library/exception.m:
trace/mercury_trace.c:
Add MR_ prefixes to the values of the enum returned by
MR_stack_walk_step.
Rename references to the renamed function.
runtime/mercury_conf_param.h:
Add macros for debugging label names and for debugging retries (which
needs label names, just as debugging tabling does).
Add a macro for controlling whether mercury_debug.c prints raw
addresses as well as offsets (for stack pointers) or label names (for
labels). The raw pointers can be useful in debugging, but they need to
be turned off in test cases one wants to be reproducible.
runtime/mercury_label.h:
runtime/mercury_conf_param.h:
Move the MR_NEED_ENTRY_LABEL_ARRAY and MR_NEED_ENTRY_LABEL_INFO macros
from mercury_label.h to mercury_conf_param.h, since mercury_debug.c
also needs them now.
runtime/mercury_debug.c:
addresses as well as offsets (for stack pointers) or label names (for
labels). The raw pointers can be useful in debugging, but they need to
be turned off in test cases one wants to be reproducible.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
util/mkinit.c:
Add a global variable pointing to a function through which the stack
walk code in runtime/mercury_stack_trace.c can invoke code from the
debugger to print the values of the variables in nondet stack frames
without breaking the rule prohibiting references to the trace directory
from the runtime directory.
runtime/mercury_wrapper.c:
Define the succip of the dummy frame at the bottom of the nondet stack,
to avoid dereferencing a garbage pointer during detailed stack dumps.
runtime/mercury_goto.h:
Add a mechanism for always registering the name of a specific label,
even if label names are not being registered in general. This mechanism
is intended to be used for labels such as do_fail, which occur
frequently in nondet stack traces.
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
Use this mechanism for the labels defined in these modules.
library/builtin.m:
Define type_ctor_infos for the pseudotypes representing nondet stack
frame slots unconditionally, since the debugger may now need them.
trace/mercury_trace.c:
Add conditionally enabled to code to make debugging retry easier.
trace/mercury_trace_internal.c:
Add a -d option to the nondet_stack command that causes it to print
detailed nondet stack dumps, including the names and values of the
variables in each nondet stack frame.
trace/mercury_trace_vars.c:
Provide a mechanism for printing the variables of a stack frame
even when that stack frame is not an ancestor of the current call.
doc/user_guide.texi:
Document the new option of the nondet_stack command.
tests/debugger/nondet_stack.{m,inp,exp,exp2}:
A new test case to test "nondet_stack -d".
tests/debugger/Mmakefile:
Enable the new test case.