browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/interactive_query.m:
browser/listing.m:
browser/parse.m:
browser/util.m:
Rename some predicates to avoid ambiguity.
Factor out common code.
If some versions of a field of a structure have names in a predicate
(by being stored in a named variable), then give all *other* versions
of that field in that structure names in that predicate as well.
If a field of a structure is used more than once in a predicate,
then again, store it in a named variable.
Reorder predicate arguments to put state variables last.
Use io.format instead of sequences of calls to io.write_string.
In declarative_user.m, note a probable bug (in a position where
it is probably rarely stumbled upon).
In listing.m, use a consistent naming scheme to differentiate
between Mercury streams and their C counterparts.
Replace if-then-else chains with switches where possible.
browser/name_mangle.m:
Note bit rot.
browser/browse.m:
Conform to the changes above.
library/io.m:
Improve predicate and variable names.
browser/mdb.m:
browser/mer_browser.m:
browser/percent_encoding.m:
browser/term_rep.m:
browser/tree234_cc.m:
library/library.m:
Improve comments.
browser/declarative_oracle.m:
Optimize table lookups when checking whether a procedure is trusted.
Instead of doing three separate lookups to test
- whether the module in which the procedure is in is trusted,
- whether the Mercury standard library is trusted, and this module
is in the Mercury standard library, and
- whether the predicate or function the procedure is in is trusted,
look up the module the procedure is in just once, then
- replace both of the first two lookups above with testing a single flag
each, and then
- look up the procedure in a map of trusted predicate or function names.
The last test should be faster than its old equivalent, because the map
it searches will be local to the module, whereas it used to be global.
Print the list of trusted entities (which this module calls trusted
"objects") in the same order regardless of whether we are printing
for users or as commands. The order will be the order in which they were
trusted.
Undo an unnecessary capitalization in the list of trusted objects.
browser/declarative_debugger.m:
Improve the style of some related code.
tests/debugger/save.exp:
tests/declarative_debugger/skip.exp:
tests/declarative_debugger/trust.exp:
Expect the changes described above in the list of trusted objects.
browser/browse.m:
browser/browser_info.m:
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_oracle.m:
browser/declarative_user.m:
browser/diff.m:
browser/help.m:
browser/interactive_query.m:
browser/parse.m:
browser/util.m:
Replace implicit streams with explicit streams.
Shorten lines longer than 79 chars.
In some places, simplify some code, often using constructs such as
string.format that either did not exist or were too expensive to use
when the original code was written.
In some places, change predicate names that were not meaningful
without module qualification by *including* the module qualification
in the name (e.g. init -> browser_info_init).
In some places, add XXXs.
In browser_info.m, make the output stream *part* of the debugger type,
because without this, having the debugger type belong to the stream
typeclass does NOT make sense. (The typeclass instance for debugger
used to always write to the current output stream, which this diff
is replacing with the use of explicitly specified streams.)
In browse.m, consistently put stream arguments before other arguments.
In browse.m, when exporting Mercury predicates to C, export them
under names with the standard ML_BROWSE_ prefix, NOT under the name
of a *different* predicate with that prefix.
In diff.m, eliminate an unnecessary difference between what we print
when the difference between two terms is at the root, vs what we print
when the difference between two terms is lower down.
In interactive_query.m, when trying to write a program out to a file,
do NOT write the program to the current output stream if we cannot open
the file, since that would accomplish nothing useful.
Also in interactive_query.m, cleanup .dylib instead of .so on MacOS.
In util.m, delete some unused predicates.
In collect_lib.m, document why some code is not worth updating.
In declarative_oracle.m, rename predicates with previously-ambiguous
names.
browser/MDBFLAGS.in:
Specify --warn-implicit-stream-calls for all Mercury modules
in the browser directory from now.
trace/mercury_trace_browse.c:
trace/mercury_trace_cmd_browsing.c:
ssdb/ssdb.m:
Conform to the changes in browser/*.m.
tests/debugger/queens.{exp,exp2}:
Expect the extra output from browser/diff.m.
browser/help.m:
Simplify the data types representing the nested structure
of help information. Simplify the code of the predicates
that work on that structure.
Simplify some of the predicates, e.g. by having a search predicate
do *just* search.
Give types and predicates more meaningful names. Make argument order
more suitable for state-variables. Move a predicate next to its
only call site.
browser/declarative_user.m:
Conform to the change in help.m.
Replace two bools with values of bespoke types.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
Conform to the changes in help.m and declarative_user.m.
doc/generate_mdb_doc:
Fix the vim modeline.
trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
Conform to the changes in the browser directory.
util/info_to_mdb.c:
Switch from /**/ to // for comments.
Give a macro a meaningful name.
Fix indentation.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
Specify the type constructor for every inst definition that lists
the functors that values of that type may be bound to.
In library/maybe.m, delete the inst maybe_errors/1, because
(a) its name is misleading, since it is for the maybe_error/1 type (no s),
and (b) there is already an inst with the non-misleading name maybe_error
which had an identical definition.
In compiler/dep_par_conj.m, delete two insts that were duplicates
of insts defined in hlds_goal.m, and replace references to them
accordingly.
Many predicates that do their jobs via foreign_procs in C have a fallback
Mercury clause for non-C backends, which usually throws an exception.
When compiled in non-C grades, these often get a warning that their
determinism declaration could have been tigther, e.g. erroneous instead of det.
*.m:
Add no_determinism_warnings pragmas before such fallback clauses.
library/dir.m:
As above, but also remove the unnecessary "dir." prefix on many predicate
declarations and clause heads.
browser/browse.m:
browser/browser_info.m:
browser/collect_lib.m:
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_test.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/diff.m:
browser/dl.m:
browser/frame.m:
browser/help.m:
browser/interactive_query.m:
browser/io_action.m:
browser/listing.m:
browser/mdb.m:
browser/mer_browser.m:
browser/name_mangle.m:
browser/term_rep.m:
browser/tree234_cc.m:
Fix inconsistencies between (a) the order in which functions and predicates
are declared, and (b) the order in which they are defined.
In most modules, either the order of the declarations or the order
of the definitions made sense, and I changed the other to match.
In some modules, neither made sense, so I changed *both* to an order
that *does* make sense (i.e. it has related predicates together).
In some places, put dividers between groups of related
functions/predicates, to make the groups themselves more visible.
In some places, fix comments or programming style.
browser/MDB_FLAGS.in:
Since all the modules in this directory are now free from any warnings
generated by --warn-inconsistent-pred-order-clauses, specify that option
by default in this directory to keep it that way.
mdbcomp/sym_name.m:
New module, containing the part of the old prim_data.m that
dealt with sym_names.
mdbcomp/builtin_modules.m:
New module, containing the part of the old prim_data.m that
dealt with builtin modules.
mdbcomp/prim_data.m:
Remove the things that are now in the two new modules.
mdbcomp/mdbcomp.m:
deep_proiler/Mmakefile:
slice/Mmakefile:
Add the two new modules.
browser/*.m:
compiler/*.m:
deep_proiler/*.m:
mdbcomp/*.m:
slice/*.m:
Conform to the above changes.
Branches: main, 11.07
Fix the decldebug grades with MSVC.
(XXX Most of the system can now be built in none.gc.decldebug with MSVC
except for the deep profiler; the Windows header files #define interface
and this stuffs up compilation of deep_profiler/interface.m.)
compiler/layout_out.
Avoid declarations for layout structures that contain incomplete
types. MSVC treats them as erroneous definitions rather than
declarations. Use the existing mechanism we have in the LLDS
backend for doing this, the MR_STATIC_LINKAGE macro.
Replace my earlier fix or alloc_sites arrays with the
above as well.
library/thread.semaphore.m:
browser/declarative_debugger.m:
browser/util.m:
Use don't care variables for the I/O state in more
foreign procs in order to avoid warnings from MSVC.
supertree of the starting node and there has been no interaction with the user
yet show a warning and ask the user if the search should continue in
ancestor calls (bug #20). This could happen when the user issues the dd
command at a node whose descendents are all trusted. In this case the
declarative debugger will begin searching in the ancestors of the node where
the dd command was issued, which can seem unintuitive. The warning message
should help the user understand what is going on.
browser/declarative_debugger.m:
Add a warn_if_searching_supertree flag to the declarative debugger state.
This flag is initially set to yes and is changed to no after a user
interaction.
Print a warning if a supertree is requested and there has been
no interaction with the user yet. Ask the user if the search should
continue in the supertree.
Add a predicate to perform per-session initialization. This
currently resets the warn_if_searching_supertree flag.
browser/declarative_oracle.m:
browser/declarative_user.m:
Add get_user_input_stream functions.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/all_trusted.exp:
tests/debugger/declarative/all_trusted.exp2:
tests/debugger/declarative/all_trusted.inp:
Include the warning message in the expected output.
tests/debugger/declarative/supertree_warning.exp:
tests/debugger/declarative/supertree_warning.inp:
tests/debugger/declarative/supertree_warning.m:
New test case.
trace/mercury_trace_cmd_dd.c:
Do per-session initialization.
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
Add a wrapper function to call the new session initialization
predicate.
Estimated hours taken: 12
Branches: main
Fix a bug in the handling of I/O actions by the debugger: the procedural
debugger didn't implement the documented commands for printing I/O actions.
Also implement some new variants of the print commands to make it easier
to print I/O actions.
Also track down and pinpoint a bug that caused the declarative debugger
to ask questions from *outside* the tree it was asked to debug, as shown
by this example from a new test case compiled in a decldebug grade (so that
the library, and thus io.read, gets compiled with deep, not shallow tracing):
-----------------------------------------------------------------------------
mdb ./io_read_bug
1: 1 1 CALL pred io_read_bug.main/2-0 (cc_multi) io_read_bug.m:22
I/O tabling started.
mdb> g 4
Please input the number of queens and a period:
4: 3 2 CALL pred io.read/3-0 (det) io.m:4240 (io_read_bug.m:24)
mdb> f
5.
513: 3 2 EXIT pred io.read/3-0 (det) io.m:4240 (io_read_bug.m:24)
mdb> dd
[1, 3, 5, 2, 4]
main(_, _)
31 tabled IO actions: too many to show
Valid?
-----------------------------------------------------------------------------
browser/declarative_tree.m:
Put an XXX at the spot of the second bug.
browser/declarative_analyser.m:
browser/declarative_debugger.m:
Change the formatting of some code to give consistent and more
meaningful names to some arguments, and to make switches easier
to read. There are no algorithmic changes.
runtime/mercury_trace_base.[ch]:
Move the code for disabling/enabling deep profiling to the code that
does disabling/enabling of I/O actions, to put all relevant actions
for entering and leaving Mercury code together.
Note the similarity of MR_turn_debug_off/MR_turn_debug_back_on
with MR_TRACE_CALL_MERCURY, and make the similarity even greater
by adding the code for disabling/enabling deep profiling to
MR_TRACE_CALL_MERCURY (without which the deep profiler data structures
would have been screwed up by the declarative debugger).
Add a const qualifier to an argument.
trace/mercury_trace_cmd_browsing.c:
Fix the first bug: update the code of the "print" and "browse" mdb
commands to implement their documented capabilities with respect to
printing I/O actions.
Add a new capability: "print io" (or "print action") will now print
a bunch of I/O actions, starting with the first available one, and on
successive invocations will print successive bunches. This is an easy
way to print all I/O actions (without being overwhelmed by a huge
printout if there are too many).
Add a new capability: "print io limits" will now print the numbers of
the first and last I/O actions.
doc/user_guide.texi:
Document the new capabilities.
trace/mercury_trace_declarative.c:
Fix the second bug: disable debugging and then restore the old state
around calls to Mercury code from the declarative debugger.
My guess is that the bug was introduced when we gave declarative
debugging its own trace function; the one it used to share with
the procedural debugger still does the same disable/restore pair.
trace/mercury_trace_internal.c:
Delete the code now moved to mercury_trace_base.c.
trace/mercury_trace_util.[ch]:
Add a utility function for use by the new code in
mercury_trace_cmd_browsing.c, and increase robustness by more
precise representation of unsigned values.
trace/mercury_trace_cmd_dd.c:
Cosmetic fixes.
tests/debugger/declarative/tabled_read_decl.m:
Update this test case to our current coding standards. There are no
changes in the code.
tests/debugger/declarative/tabled_read_decl.{inp,out}:
Test the bug fixes by printing out a bunch of I/O actions.
tests/debugger/declarative/builtin_call_rep.exp:
Update this expected output file to conform for my recent change to
procedure representations.
tests/debugger/declarative/io_read_bug.{m,inp,exp}:
A new test case that exposes the second bug above. The .inp file
exposes the bug; the .exp file is a dummy.
tests/debugger/declarative/Mmakefile:
Add the new test case, but don't enable it yet.
tests/debugger/print_io_actions.{m,inp,exp,data}:
A new test case to test the new "print io" variant of the print
command.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Enable the new test case.
tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug:
Expect the big_array_from_list test to fail in decldebug grades,
since we in that grade we can never get tail recursion, even in the
standard library.
resets the declarative debugger's knowledge base of previous question answers.
NEWS:
Mention the new option.
Move an item that was in the wrong place.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
Export a procedure to reset the oracle's knowledge base.
doc/user_guide.texi:
Document the new option.
tests/debugger/declarative/oracle_db.exp:
tests/debugger/declarative/oracle_db.inp:
Test the new option.
trace/mercury_trace_cmd_dd.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
Add the new option.
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: 6
Branches: main
Document my recent change implementing coverage testing. At the same time,
eliminate the old hack that allowed a file containing a list of file names to
be considered a trace count file. We haven't needed it since the addition of
mtc_union, and it can lead to incomprensible error messages. (The presence
of the old hack made documenting coverage testing harder.)
In the process, fix the tools code for rerunning failed test cases only.
doc/user_guide.texi:
Document my recent change implementing coverage testing, and the
elimination of the old hack.
mdbcomp/trace_counts.m:
Modify the predicates for reading in trace count files along the lines
above.
mdbcomp/slice_and_dice.m:
Modify the predicates for reading in slices and dices along the lines
above.
Rename some function symbols to avoid ambiguities.
compiler/tupling.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_declarative.c:
Conform to the changes above.
slice/mcov.m:
Fix the usage message, which referred to this program by its old name
mct.
Allow the output to be restricted to a set of named modules only.
This is to make testing easier.
slice/mtc_diff.m:
Rename the long form of the -o option from --out to --output-file,
to make it consistent with the other programs.
tests/run_one_test:
tools/bootcheck:
Modify the algorithm we use to gather trace counts for the Mercury
compiler from both passed and failed test cases to run mtc_union
periodically instead of gathering all the trace counts file and keeping
them to the end (which takes far too much disk space).
Fix an old bug: gather trace counts from executions of the Mercury
compiler only.
tests/debugger/Mmakefile:
tests/debugger/dice.passes:
Modify the dice test case to compute the union of the trace counts for
the passed versions of this test case to use mtc_union to create
dice.passes, instead of having dice.passes statically contain the list
of the names of the passed trace count files (since that capability
is deleted by this diff).
tools/bootcheck:
tests/Mmake.common:
Fix the code for rerunning failed tests only.
mdbcomp/prim_data.m:
Eliminate some ambiguities in predicate names.
compiler/*.m:
Conform to the change to prim_data.m.
compiler/error_util.m:
Add reading files as a phase in error messages.
compiler/mercury_compile.m:
Use the new facilities in error_util for printing an error message.
Estimated hours taken: 1
Branches: main
Use `pragma foreign_export' in preference to `pragma export' throughout
the Mercury distribution.
Convert more of the extras distribution to four-space indentation and
other minor cleanups.
browser/*.m:
library/*.m:
samples/*:
extras/*:
As above.
Estimated hours taken: 6
Branches: main
This diff contains no algorithmic changes. It merely renames apart a bunch more
function symbols to reduce ambiguity.
After this diff, the summary line from the mdb command "ambiguity -f" is
Total: 351 names used 975 times, maximum 31, average: 2.78
browser/*.m:
compiler/*.m:
Rename function symbols to eliminate ambiguities.
tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency2.exp:
Update the expected out where some internal function symbol names
appear in the output of the debugger. (This output is meant for
implementors only.)
Estimated hours taken: 3
Branches: main, release
Fix the failure of debugger/declarative/sort.m. The problem was that the
depth command in the declarative debugger did not affect the depth to which
I/O actions were printed. This was because printing I/O actions uses the
`print all' configuration parameters and the `depth' command in the
declarative debugger only affects the `print' configuration parameters. The
solution is to add four new formatting commands to the declarative debugger
(really just variants of the existing commands.) These are `depth io', `size
io', `lines io' and `width io'. These function identically to the `depth',
`size', `lines' and `width' commands except that they affect the `print all'
configuration parameters, rather the ones for `print'.
browser/declarative_user.m:
Add the four new commands described above.
doc/user_guide.texi:
Document the new commands.
browser/declarative_debugger.m:
Fix some formatting.
tests/debugger/declarative/sort.inp:
tests/debugger/declarative/sort.exp:
Use the new commands set the depth to which I/O actions are printed in
the declarative debugger to an appropriate level for this test - it
needs to be deep enough to print out the strings returned by
read_line_as_string_2.
tests/debugger/declarative/dd_params.exp:
tests/debugger/declarative/dd_params.inp:
Extend this test to cover the new commands.
Estimated hours taken: 18
Branches: main
Move the univ, maybe, pair and unit types from std_util into their own
modules. std_util still contains the general purpose higher-order programming
constructs.
library/std_util.m:
Move univ, maybe, pair and unit (plus any other related types
and procedures) into their own modules.
library/maybe.m:
New module. This contains the maybe and maybe_error types and
the associated procedures.
library/pair.m:
New module. This contains the pair type and associated procedures.
library/unit.m:
New module. This contains the types unit/0 and unit/1.
library/univ.m:
New module. This contains the univ type and associated procedures.
library/library.m:
Add the new modules.
library/private_builtin.m:
Update the declaration of the type_ctor_info struct for univ.
runtime/mercury.h:
Update the declaration for the type_ctor_info struct for univ.
runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
Update the definition of MR_Univ.
runtime/mercury_init.h:
Fix a comment: ML_type_name is now exported from type_desc.m.
compiler/mlds_to_il.m:
Update the the name of the module that defines univs (which are
handled specially by the il code generator.)
library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
Conform to the above changes. Import the new modules where they
are needed; don't import std_util where it isn't needed.
Fix formatting in lots of modules. Delete duplicate module
imports.
tests/*:
Update the test suite to confrom to the above changes.
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: 20
Branches: main
Implement a second version of the subterm dependency tracking algorithm
that uses the following heuristic to speed things up: If the subterm is being
tracked through an output argument, and there is an input argument with the
same name as the output argumnet, except for a numerical suffix, then the new
algorithm will check if the subterm appears in the same position in the input
argument. If it does then it will continue tracking the subterm in the input
argument, thus bypassing the subtree rooted at the call. Since dereferencing a
subterm in a large structure can be expensive, the new algorithm will only try
to bypass calls to procedures it has not tried to bypass before. The set of
procedures it has tried is reset each time a new explicit subtree or supertree
is generated.
Add a `track' command that behaves in the same way as `mark', except that
it doesn't assert that the node is erroneous or inadmissible.
Add an optional `--accurate' argument which tells the declarative debugger to
use the original tracking algorithm.
We still allow the old algorithm to be used, because there
are situations where the new algorithm could find the wrong call (i.e.
when a subterm appears in the same position in an input argument,
but the subterm in the output argument is actually bound by a descendent call
-- it just happens to be bound to the same value as the input subterm).
doc/user_guide.texi:
Change the documentation accordingly.
browser/browse.m:
browser/browser_info.m:
browser/parse.m:
browser/declarative_user.m:
Add a `track' command that does the same thing as a `mark' command,
except it doesn't assert the atom to be erroneous or inadmissible.
Allow an `--accurate' or `-a' argument for the `mark' and `track'
commands which indicates that the old subterm dependency tracking
algorithm should be used.
Pass information about tracked subterms to the declarative debugger.
Do not allow a whole atom to be tracked or marked as this doesn't
make sense.
browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_oracle.m:
Implement the new tracking algorithm.
browser/term_rep.m:
Add a predicate to dereference a subterm in another term.
mdbcomp/rtti_access.m:
Add a predicate to find a candidate input argument on which to
apply the new heuristic.
runtime/Mmakefile:
runtime/mercury_layout_util.h:
runtime/mercury_stack_layout.h:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
Move the function for finding the name of a variable to the runtime,
so that it can be called from the declarative debugger.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/nodescend_tracking.exp:
tests/debugger/declarative/nodescend_tracking.inp:
tests/debugger/declarative/nodescend_tracking.m:
Test the new heuristic.
tests/debugger/declarative/closure_dependency.inp2:
tests/debugger/declarative/closure_dependency.exp2:
Expect an error message when marking a whole atom.
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: 15
Branches: main
Allow the search mode to be changed from within the declarative debugger.
Make binary search independent of subterm dependency tracking. The
user can now perform a binary search along the path between the current
question and the root of the search space using the command `mode binary'
(or `m b').
browser/declarative_analyser.m:
Make reask_last_question fail instead of throwing an exception
if there is no last question. If it fails we
recompute the question. This happens when the user
resumes with a new search mode.
Do not return an analyser response when showing info, since we can
just call reask_last_question.
Make set_fallback_search_mode set the last_search_question field to
no. This will force the question to be recomputed with the new
search strategy when analysis continues.
Add change_search_mode which handles the users request to change the
current search mode from within a declarative debugging session.
Do not perform a binary search after tracking a subterm unless
instructed to do so by the user.
browser/declarative_debugger.m:
Allow search mode changes to be undone.
Handle the new change_search oracle response.
Handle the fact that reask_last_question is now semidet.
browser/declarative_oracle.m:
Add a change_search oracle response.
Add a predicate to indicate which oracle responses are undoable.
browser/declarative_user.m:
Add a change_search user response.
doc/user_guide.texi:
Rephrase the description of the undo command to take into account that
search mode changes can be undone.
Add a section about the binary search mode.
Rearrange some text and reword some sentences slightly.
tests/debugger/mdb_command_test.inp:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/binary_search.exp:
tests/debugger/declarative/binary_search.exp2:
tests/debugger/declarative/binary_search.inp:
tests/debugger/declarative/binary_search.inp2:
tests/debugger/declarative/change_search.exp:
tests/debugger/declarative/change_search.inp:
tests/debugger/declarative/change_search.m:
tests/debugger/declarative/info.exp:
tests/debugger/declarative/info.inp:
Test the `mode' command and do not expect the declarative debugger to
automatically go into binary search mode once it has tracked a subterm.
Estimated hours taken: 4
Branches: main
Include a script to test the performance of the debugger in the tools
directory.
Add a --test dd command option. The --test option causes the declarative
debugger to simulate a session where the user answers `no' to all questions
until a bug is found.
Remove the dd_dd mdb command and add a --debug option to the dd command which
does the same thing. The double maintenance of the dd_dd and dd commands was
becoming onerous.
browser/declarative_debugger.m:
Export a predicate to set the testing flag in the user state.
browser/declarative_oracle.m:
Add a predicate to set the testing flag of the user state.
browser/declarative_user.m:
Add a new flag to the user state which indicates whether user answers
should be simulated.
If the new flag is set then simulate answers instead of asking the
user.
doc/user_guide.texi:
Document the --test and --debug developer options.
tools/dd_speedtest:
Script for testing the performance of the declarative debugger.
tools/extract_dd_stats.awk:
Script for summarizing the output of dd_speedtest.
trace/mercury_trace_declarative.c:
Add a predicate to set the testing flag of the diagnoser.
Rename the global variable which says whether the declarative debugger
is being debugged.
Use the -p ps option to print the Memory consumption of the current
process instead of using grep.
trace/mercury_trace_declarative.h:
Fix a typo.
Export the predicate to set the testing flag.
Rename the global variable which says whether the declarative debugger
is being debugged.
trace/mercury_trace_internal.c:
Add the --test and --debug options and remove the dd_dd command.
Estimated hours taken: 6
Branches: main
Implement `undo' command in the declarative debugger.
The `undo' command takes the debugger back to the state it was in before the
last answer was given (`skip' is counted as an answer in this case).
browser/declarative_analyser.m:
Add an interface predicate which allows us to get the last question
asked by the analyser.
Do not handle `show_info' in process_answer, since `show_info' is
no longer considered an answer (see below).
browser/declarative_debugger.m:
Make `show_info' an oracle response, instead of an oracle answer,
since it doesn't affect the search space.
Get rid of diagnoser_{get,set}_{analyser,oracle}, because they serve
no abstraction purpose and maintaining them is a pain.
Add a new field to the diagnoser which records the state of the
diagnoser before the previous oracle answer. This turns the
diagnoser into a stack. Add predicates to push and pop
diagnosers from this stack.
Push the current diagnoser onto the stack when an oracle answer
is received from the user.
Pop the previous diagnoser when the `undo' command is issued.
browser/declarative_oracle.m:
Add `undo' to the set of possible oracle responses.
Add a predicate which makes the current knowledge base of one oracle
the revised knowledge base of another oracle.
Fix a spelling mistake.
Add a predicate to get the output stream used to communicate with the
user.
Report whether an answer came directly from the user or not in
query_oracle.
browser/declarative_user.m:
Add the `undo' user response.
Add a predicate to get the output stream used to communicate with the
user. This is used by the diagnoser to print a "Undo stack empty"
message.
doc/user_guide.texi
Document the new command.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/undo.exp:
tests/debugger/declarative/undo.inp:
tests/debugger/declarative/undo.m:
Test the new command.
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
Do not build an IO action map to pass around to predicates in the
declarative debugger that need access to IO actions.
Instead look these up directly in the IO state.
When using the declarative debugger to debug the Mercury compiler invoked
on typecheck.m, which generates about 2.3 million IO actions,
this change reduces the memory consumption by roughly half and reduces
the delay between the end of execution trace generation and the asking of the
first question from about 30 seconds to about 2 seconds.
Use the --force-disable-tracing option to turn off tracing in the browser
directory, even in .debug and .decldebug grades.
configure.in
Check that the --force-disable-tracing option is recongnised by the
installed compiler, since we now use this option.
browser/MDB_FLAGS.in:
Turn off tracing for all code in the browser directory.
browser/declarative_analyser.m:
Remove the IO action map from the analyser state.
Reformat a comment.
browser/declarative_debugger.m:
Do not initialise the IO action map, since it no longer exists.
For final atoms, record a range of IO action numbers, instead
a list of IO actions. The actions themselves can be looked up from
the numbers when needed.
browser/declarative_edt.m:
browser/declarative_tree.m:
Remove references to the IO action map.
browser/declarative_user.m:
Look up tabled IO actions directly in the IO state when they need to be
displayed.
Implement a predicate, find_tabled_io_action, which finds a particular
tabled IO action given a range of IO action numbers and the sought
tabled IO action number.
Change several predicates to use the above instead of looking for
the IO actions in a list.
Implement a predicate, count_tabled_io_actions, which counts how many
tabled and untabled IO actions are in a range of IO action numbers.
Modify some predicates to use above.
browser/io_action.m:
Remove the io_action_map type and predicates used to construct values
of this type.
Add a new predicate, get_maybe_io_action, which looks up a possibly
untabled IO action number and returns the IO action if it was tabled.
The type returned by this predicate is maybe_tabled_io_action, which
has two functors: tabled/1 and untabled/1. The argument of the
untabled/1 functor is pointless, since it's just the IO action number,
which is required to look up the return value of get_maybe_io_action
in the first place. Remove the pointless argument.
Add a new type, io_action_range, for recording a range of IO actions.
Add an explicit `may_call_mercury' assertion to the pickup_io_action
foreign proc.
trace/mercury_trace_declarative.c:
Do not keep track of the start and finish IO action numbers for
the generated portions of the EDT and do not pass these to the
frontend. We still record the current IO action number at each
CALL and EXIT event.
Fix a bug in the progress indicator which is exposed when event
numbers become very big.
Estimated hours taken: 15
Branches: main
In the declarative debugger, dynamically calculate the depth implicit subtrees
need to be built to, to achieve a desired weight.
This is done by recording the number of events at each depth in each
implicit subtree. The array used to record these depths need only be
as big as the desired weight divided by two, since the thinnest a tree can be
is a stick with two events at each depth (a CALL and an EXIT/FAIL/EXCP).
Initially the tree is built down to a predetermined, conservative depth. At
the root of each implicit subtree in the newly materialized tree, we record
the depth the implicit subtree needs to be built to, to achieve the desired
weight (this is refered to as the ideal depth in the code). This is done
everytime we materialize a new implicit subtree.
This results in about a 3.6% slowdown when the declarative debugger reexecutes
a portion of the program. However, this also reduces the number of
reexecutions of the program, since we needn't be conservative about how deep to
build subtrees to anymore. We also avoid adding too many nodes to the
annotated trace if the tree has a large branching factor, so we are able to
control memory usage more easily.
I also added a progress indicator which is activated if a reexecution continues
for more than a second.
I added some macros to optionally print benchmarking information when
building a new portion of the annotated trace.
browser/declarative_debugger.m:
Pass the ideal depth of a subtree to the backend.
browser/declarative_edt.m:
Handle the case where edt_dependency says an explicit subtree is
required.
browser/declarative_execution.m:
Record the ideal depth at the CALL event corresponding to the root
of an implicit subtree.
Add predicates to get and set this value from the backend.
browser/declarative_tree.m:
Export a new predicate, trace_implicit_tree_info, which is used to
get the info stored at the root of an implicit root.
Make trace_dependency respond that an explicit subtree is required
if it needs to explore the children of an implicit subtree. Previously
we made this situation impossible by requiring the backend to
always generate the children of nodes at the depth limit. This,
however, complicated the backend code unnecessarily.
doc/user_guide.texi:
Change the --depth-step-size dd option to just --depth which is now
only used as the initial depth to build the subtree to. Comment out
the --depth option, since it requires knowledge of the internal
workings of the declarative debugger.
Document the new dd option, --nodes, which controls how many nodes
to build in the annotated trace at a time.
library/gc.m:
Export garbage_collect so it can be called from the backend when
printing out benchmarking information.
tests/debugger/declarative/*.{inp*, exp*}
For the tests set the --nodes and --depth options to a low value, so
that we exercise the code that builds new portions of the annotated
trace.
trace/mercury_trace_declarative.[ch]:
Move the MR_DECL_UNTABLED_IO_RETRY_MESSAGE macro to
mercury_trace_declarative.h.
Add some macros and functions which print benchmarking information
if the MR_DD_PRINT_EDT_STATS macro is defined.
Add an overview of the backend.
Show progress if the tree takes more than a second to generate.
Count the events at each depth in each implicit subtree.
Calculate the ideal depth when exiting an implicit subtree and store
this in the annotated trace.
Add the depth limit as an argument to MR_trace_restart_decl_debug
instead of using the value of the global MR_edt_depth_step_size
(which no longer exists).
Do not materialize the children of nodes at the depth limit, since
this is no longer necessary.
trace/mercury_trace_internal.c:
Add and handle the --nodes dd option. Rename the --depth-step-size
option to --depth.
Estimated hours taken: 3
Branches: main
Look up atoms in the knowledge base as soon as they are added to the search
space.
This generalises a feature of the debugger which I earlier removed
for simplicity, where the analyser would pass a list of questions to the
oracle. If the oracle had any of the questions in its knowledge base it
would return those answers to the analyser, otherwise it would ask the user.
This was changed so that only one question was asked of the oracle at a time.
Now the analyser still asks only one question of the oracle at a time (through
an analyser response), but the oracle's knowledge base is consulted every time
a new suspect is added to the search space i.e. as it is being searched.
The main benefit of this is that search algorithms can immediately avoid
generating queries about trusted nodes. This fixes some slightly annoying
behaviour with subterm dependency tracking. Previously if a subterm was
bound by a trusted predicate, then this would cause a binary search to be
performed between the trusted predicate and the root of the search space.
It would be better for the dependency tracking algorithm to first ask about the
closest untrusted call to the call that bound the subterm, since often subterms
are bound by internal library predicates. The subterm dependency algorithm
was unable to do this, however, because it didn't know which calls were
trusted while it was tracking the subterm. Now it does.
browser/declarative_analyser.m:
Pass the oracle state and the io action map to any predicates
that add suspects to the search space, so that the oracle's
knowledge base can be consulted.
Move the code that checks if a bug has been found from
decide_analyser_response to the top-down search routine. This is okay
since all the other search algorithms will eventually call top-down
search if they can't find any unknown suspects to ask questions about.
When keeping track of the last unknown suspect, double check that the
suspect is still unknown before asking a question about it, since
its status may have been changed because, for example, an erroneous
child was added to the search space.
Pass the mode of the subterm to give_up_subterm_tracking/3, since
tracking of the subterm should only be stopped if it's the input to
an erroneous node.
browser/declarative_debugger.m:
Add a subtype of decl_answer/1 that specifies those answers which
can be obtained from places other than the user.
Pass the oracle state to the analyser.
browser/declarative_edt.m:
Make first_unknown_descendent return a new type which captures
whether an unknown suspect was found, an unknown suspect was not
found, or an explicit_subtree was requested. Previously this predicate
would fail if an explicit subtree was required, which meant that any
suspects added to the search space during the call to
first_unknown_descendent would have to be added again once the
subtree had been generated. This also removes the need for
pick_implicit_root.
Pass the oracle state and the io action map to any predicates
that add suspects to the search space, so that the oracle's
knowledge base can be consulted.
Remove the suspect_is_bug predicate, since this is now done by top-down
search in the anaylser. Export non_ignored_descendents and suspect_inadmissible
so the analyser can use it.
Return the mode of a subterm in its origin. Make
give_up_subterm_tracking consider the mode of the subterm.
Check if the oracle knows the answer to a question when adding
children to the search space, or adding a new suspect at the top
of the search space. Also give better names to some variables in these
predicates.
browser/declarative_oracle.m:
Export answer_known/3 so that declarative_edt can call it.
tests/debugger/declarative/binary_search.exp:
tests/debugger/declarative/binary_search.exp2:
tests/debugger/declarative/binary_search.inp:
tests/debugger/declarative/binary_search.inp2:
tests/debugger/declarative/family.exp:
tests/debugger/declarative/family.inp:
These test cases now ask fewer questions, except for one dd session
in the binary_search test case. This, however, is a fix for the quirk
mentioned above where a binary search would be started if the
binding node is trusted. The new behaviour is more predictable
and preferable even if an extra question is asked.
trace/mercury_trace_declarative.c:
Fix a bug where the dd_dd command didn't work. This was introduced
by an earlier diff in which I cleaned up mercury_trace_declarative.c.
Estimated hours taken: 7
Branches: main
Improve the declarative debugger interface.
The two main changes are to use the mdb help system and not re-display
the question after the user issues a command which does not answer the
question. For example if the user issues an `info' command, then previously
the question would be redisplayed after the requested information and if the
question is big then the information would be scrolled off the screen.
browser/declarative_analyser.m:
Remove extra new line characters when printing info. These are
no longer necessary since the question is not redisplayed.
browser/declarative_debugger.m:
Pass the help system from mdb to the oracle state when
initialising the diagnoser.
browser/declarative_oracle.m:
Pass the help system to the user state when initialising the
oracle state.
browser/declarative_user.m:
Add two new fields to the user state: one to keep a reference to
the help system and one to indicate whether the current question
should be displayed when getting a user input.
Allow the user to redisplay the question by issuing a `print' command
with no arguments. If the question is not to be displayed the show
a "dd>" prompt.
Change the `abort' command to `quit'. This is more consistent
with the rest of mdb.
doc/commands:
Add a script to print all the commands in a section in the
user guide.
doc/generate_mdb_doc:
Generate help for the declarative debugger.
doc/mdb_categories:
Add a category, `decl', for commands that can be executed inside
the declarative debugger. Change the `dd' category to mdb_dd,
because 1) `help dd' used to show help about the `dd' category AND
the `dd' command and 2) `dd' is too general a category name now that we
have a `decl' category.
Add an item, `decl_debug' to the concepts category.
doc/user_guide.texi:
Document some dd commands which previously weren't documented here.
Add a short overview of the declarative debugger. This is
displayed when the user issues a `help' command from within the
dd.
Move the bit about the behaviour when no command is given to
before the list of commands. This is necessary so util/info_to_mdb.c
doesn't include this in the help of the last command in the list.
tests/debugger/declarative/app.exp:
tests/debugger/declarative/app.inp:
tests/debugger/declarative/browse_arg.exp:
tests/debugger/declarative/browse_arg.inp:
tests/debugger/declarative/browser_mode.exp:
tests/debugger/declarative/browser_mode.inp:
tests/debugger/declarative/confirm_abort.exp:
tests/debugger/declarative/confirm_abort.inp:
tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency.inp:
tests/debugger/declarative/find_origin.exp:
tests/debugger/declarative/find_origin.exp2:
tests/debugger/declarative/info.exp:
tests/debugger/declarative/info.inp:
tests/debugger/declarative/io_stream_test.exp:
tests/debugger/declarative/io_stream_test.exp2:
tests/debugger/declarative/mapinit.exp:
tests/debugger/declarative/mapinit.inp:
tests/debugger/declarative/output_term_dep.exp:
tests/debugger/declarative/output_term_dep.inp:
tests/debugger/declarative/resume.exp:
tests/debugger/declarative/resume.inp:
tests/debugger/declarative/skip.exp:
tests/debugger/declarative/skip.inp:
tests/debugger/declarative/solutions.exp3:
tests/debugger/declarative/tabled_read_decl.exp:
Update tests.
trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
trace/mercury_trace_help.h:
Pass the help system to the frontend.
Estimated hours taken: 15
Branches: main
Fix three bugs in the declarative debuggger.
The first two are to do with IO tabling in the declarative debugger:
The first bug was exposed when a new explicit supertree was built over a part
of the program that did IO. The starting IO action sequence number was not
being set correctly, causing some IO actions to be omitted from the resulting
IO action map. The fix is to set the starting IO action sequence number to
the IO action sequence number at the CALL event for the topmost node of the new
explicit supertree.
The second bug was exposed when a retry was done over a part of the program
whose IO was not tabled. This caused the building of the IO action map to
fail. Specifically the MR_trace_get_action C function would abort with a
message that the IO action number was out of range. The fix is to only record
tabled IO actions in the IO action map and then warn the user if a question is
asked where some of the IO actions for the atom haven't been tabled.
The third bug causes the declarative debugger to throw an exception when
an explicit subtree of depth 1 is requested. This was because MR_edt_depth
(the global which keeps track of the current depth of the EDT) was not being
set correctly.
browser/declarative_debugger.m:
Allow the IO actions for a final atom to be tabled or untabled.
browser/declarative_tree.m:
Extract a list of the tabled and untabled IO actions for a question
from the IO action map.
browser/declarative_user.m:
Bring module imports up to date with coding standards.
Only allow browsing and printing of tabled IO actions.
Print all the tabled IO actions for a question and print a warning if
there are any untabled IO actions for a question.
Use "tabled IO actions" instead of "io actions" when displaying how
many tabled IO actions there are for a question.
browser/io_action.m:
Add a type to record if an IO action is tabled or not.
Bring module imports up to date with coding standards.
Only record tabled IO actions in the IO action map used by the
declarative debugger.
runtime/mercury_trace_base.[ch]:
Make MR_trace_get_action return true or false depending on whether
the requested IO action was tabled or not, so that we can easily
detect this in io_action.m above.
tests/debugger/declarative/io_stream_test.exp2:
Update expected output.
tests/debugger/declarative/tabled_read_decl.{exp,inp,m}:
Add regression tests for all three bugs.
trace/mercury_trace.[ch]:
Allow the message printed by the retry command, when it is about to
retry over untabled IO, to be customised. This allows the declarative
debugger to print a different message when it needs to do a retry
over untabled IO. Previously the message seemed unrelated to the
declarative debugging session.
Get MR_trace_retry to report if it did an unsafe retry over
untabled IO.
trace/mercury_trace_declarative.c:
Print a friendlier message when attempting to retry over untabled IO.
Set the initial IO action sequence number to the IO action sequence
number at the time of the CALL event of the topmost node of the new
explicit supertree.
Initialise MR_edt_depth to -1, instead of 0, since it will be
subsequently made 0.
When building an explicit supertree, only ask the user once if a
retry can be done over untabled IO.
Because of this rename MR_trace_retry_max to MR_trace_retry_supertree,
since it should now only be used when building a supertree.
When checking if we are at the final event for the top of the new
explicit supertree, add the depth_check_adjustment. This ensures
that the final event has the same depth as the corresponding call
event.
Add an argument to MR_decl_diagnosis to tell it whether a new tree
was generated, or to resume a previous session. Previously the resume
option was implied by a null tree, which made the code less readable.
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
Pass the new extra arguments to MR_trace_retry.
trace/mercury_trace_readline.c:
If a readline prompt spans multiple lines then the display gets messed
up when the user starts typing (not sure if this is a bug in readline
or not). Fix this by only passing the last line of a prompt to
readline and just fprintf'ing any previous lines.
trace/mercury_trace_vars.c:
Handle the new MR_bool return value of MR_trace_get_action.
Estimated hours taken: 6
Branches: main
Add a new declarative debugger response, `info', which shows some information
about the current question and the state of the bug search.
browser/declarative_analyser.m
Add the show_info predicate.
browser/declarative_debugger.m
Handle the oracle show_info response.
browser/declarative_edt.m
Add a new method to the mercury_edt typeclass, edt_context,
which returns the filename and line number of the predicate for
a node.
browser/declarative_execution.m
Instead of recording the goal path of a call in its parent, record
the return label. The goal path and the parent context can then
be derived from the return label.
Add a function to get the goal path from a return label.
Add a function to get the context of a label.
Modify the exported predicates used to build the annotated trace
to take a return label instead of the goal path.
browser/declarative_oracle.m
Add a `show_info' oracle response.
browser/declarative_tree.m
Implement trace_context which returns the filename and line number
of the predicate that corresponds with a node in the annotated trace.
Derive a call's goal path in its caller from the return label where
necessary.
browser/declarative_user.m
Add and document the user response `info'.
browser/dice.m
Fix a line that was over 79 characters.
doc/user_guide.texi
Document the info command.
Say that the --resume option can be used to resume an aborted or pd'd
session.
tests/debugger/declarative/Mmakefile
tests/debugger/declarative/info.exp
tests/debugger/declarative/info.inp
tests/debugger/declarative/info.m
Test the new response.
trace/mercury_trace_declarative.c
Pass the return label when constructing the annotated trace.
Estimated hours taken: 25
Branches: main
Add --resume option to `dd' command. This resumes the previous declarative
debugging session and allows the user to switch between the procedural and
declarative debuggers freely.
browser/declarative_analyser.m
Add analysis_type type which is used to tell the analyser whether
it must start a new session or resume a previous session.
browser/declarative_debugger.m
Add two versions of the exported diagnosis predicate: one to
resume a previous session and one to start a new session.
browser/declarative_user.m
Print usage message to the correct output stream.
doc/user_guide.texi
Document the new option.
runtime/mercury_stack_trace.c
runtime/mercury_stack_trace.h
Add a function to find the first call on the stack whose event
number is less than or equal to a given event number or whose
call sequence number is less than or equal to a given call sequence
number.
Since this new function uses some code very similar to existing
code in the function that prints the stack, separate this code into
a new function called MR_call_details_are_valid.
trace/mercury_trace_declarative.c
trace/mercury_trace_declarative.h
Previously it could be safely assumed that the current event would
be somewhere inside the materialized portion of the annotated trace,
so it was sufficient to record the topmost node of the annotated
trace and retry to there whenever we needed to build a new subtree
(and to the topmost node plus some extra for a supertree).
Now, however, the user may go to any event in the program before
resuming the previous dd session. We could just retry to the call
event for main/2, but this would be far from optimal, especially if the
user is debugging code deep down in the program's call tree.
Instead we retry to the first call on the stack whose event number
is less than or equal to the call event number of the node we
want to build a subtree for and then start forward execution from
there. When building a supertree we retry to the first call on the
stack whose event number is less than or equal to the event number of
the call at the top of the currently materialized portion of the
annotated trace. Then when we get to the call at the top of the
currently materialized portion of the annotated trace through forward
execution, we do a retry to the desired depth and start building the
new supertree.
Desribe the function of some of the global variables in more detail.
Remove the global MR_edt_topmost_call_depth since it is no longer
needed.
Fix an inconsistency where the depth limit was being set to
MR_edt_depth_step_size when starting a dd session, but to
MR_edt_depth_step_size + 1 when building an additional portion of the
annotated trace.
Don't update the saved event details from the global event
number/seqno/depth variables at the start of MR_decl_diagnosis. The
globals could have been updated by a previous call to Mercury code and
could have incorrect values.
tests/debugger/declarative/Mmakefile
tests/debugger/declarative/resume.exp
tests/debugger/declarative/resume.inp
tests/debugger/declarative/resume.m
Test the --resume option. Specifically test the creation of a
supertree and subtree from a resumed session where the user
has gone to an event before and after the materialized portion
of the annotated trace.
trace/mercury_trace_internal.c
Handle the --resume option.
Estimated hours taken: 7
Branches: main
Record label layouts in the annotated trace. This does away with the need
to store goal path strings and proc_layouts in the annotated trace, since
both can be obtained from the label layout (we still however need to store the
goal path of a call in its parent for subterm dependency tracking).
The label layouts will be used for displaying more detailed information
in declarative debugging sessions (such as line numbers) and also for
for slicing and dicing in the declarative debugger.
browser/declarative_execution.m
Add label_layout foreign types and some useful functions on this type.
Add label_layout field to each event in an annotated trace.
Record just the arguments of an atom for call and exit events in the
annotated trace. The complete atom can be constructed from the
label_layout and the arguments.
When recording argument values add them to the front of the
argument list instead of inserting them in a specified position in the
argument list. This means the arguments must be added in reverse order
in trace/mercury_trace_declarative.c.
Adjust the predicates for building the annotated trace to also accept
a label_layout.
browser/declarative_debugger.m
Get the proc_layout from the label_layout.
browser/declarative_tree.m
Make adjustments for the extra field.
trace/mercury_trace_declarative.c
Pass the label_layout when constructing pieces of the annotated trace.
Construct only the atom's arguments. Also when adding the arguments
add them in reverse order, because of the change in
browser/declarative_execution mentioned above.
Estimated hours taken: 4
Branches: main
Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
defined in mdb.declarative_execution and delete proc_id, since these data
structures are almost identical.
browser/declarative_execution.m
Remove proc_id and flat_module_name types. Use
mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead.
browser/declarative_debugger.m
browser/declarative_oracle.m
browser/declarative_tree.m
browser/declarative_user.m
Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name
instead of mdb.declarative_execution.proc_id and
mdb.declarative_execution.module_name.
mdbcomp/prim_data.m
compiler/prog_out.m
Move sym_name_to_string from prog_out to prim_data.
Fix comment for prog_out.sym_name_and_arity_to_string.
compiler/bytecode.m
compiler/check_typeclass.m
compiler/code_gen.m
compiler/deforest.m
compiler/higher_order.m
compiler/hlds_code_util.m
compiler/hlds_error_util.m
compiler/hlds_module.m
compiler/hlds_out.m
compiler/intermod.m
compiler/layout_out.m
compiler/make.module_target.m
compiler/make_hlds.m
compiler/mercury_compile.m
compiler/mercury_to_mercury.m
compiler/ml_elim_nested.m
compiler/mlds_to_c.m
compiler/mlds_to_gcc.m
compiler/mlds_to_il.m
compiler/mlds_to_java.m
compiler/mlds_to_managed.m
compiler/modes.m
compiler/modules.m
compiler/opt_debug.m
compiler/options_file.m
compiler/polymorphism.m
compiler/prog_io.m
compiler/prog_rep.m
compiler/rl.m
compiler/rl_exprn.m
compiler/rl_gen.m
compiler/rl_info.m
compiler/rl_out.pp
compiler/rtti.m
compiler/rtti_out.m
compiler/rtti_to_mlds.m
compiler/source_file_map.m
compiler/table_gen.m
compiler/trans_opt.m
compiler/unify_gen.m
compiler/unique_modes.m
compiler/unused_args.m
Use mdbcomp.prim_data.sym_name_to_string instead of
prog_out.sym_name_to_string.
Estimated hours taken: 1.2
Branches: main
In the declarative debugger: use predmode syntax where appropriate; use `.'
as a module qualifier instead of `__'; use state variables for IO instead of
DCGs; use `io' instead of `io.state'.
browser/declarative_debugger.m
browser/declarative_execution.m
browser/declarative_oracle.m
browser/declarative_test.m
browser/declarative_tree.m
browser/declarative_user.m
Apply the above mentioned changes.
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.