Commit Graph

87 Commits

Author SHA1 Message Date
Zoltan Somogyi
bb3ef7de5d Fix indentation. 2017-12-30 15:17:20 +11:00
Zoltan Somogyi
d9e576a2b2 Specify the type for inst definitions.
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.
2017-11-08 16:54:18 +11:00
Zoltan Somogyi
22eefb3c88 Shut up determinism warnings for "sorry" fallback clauses.
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.
2017-08-10 18:02:42 +02:00
Zoltan Somogyi
6ea8406ac8 Fix more warnings from --warn-inconsistent-pred-order-clauses.
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.
2017-04-29 14:08:50 +10:00
Julien Fischer
94535ec121 Fix spelling and formatting throughout the system.
configure.ac:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
ssdb/*.m:
runtime/mercury_conf.h.in:
runtime/*.[ch]:
scripts/Mmake.vars.in:
trace/*.[ch]:
util/*.c:
	Fix spelling and doubled-up words.

	Delete trailing whitespace.

	Convert tabs into spaces (where appropriate).
2015-12-02 18:46:14 +11:00
Zoltan Somogyi
ef6761f508 Bring the programming style of browser/*.m up-to-date. 2015-08-19 01:27:55 +10:00
Julien Fischer
07ce739d13 Update bug reporting details in declarative debugger.
browser/declarative_debugger.m:
	Update the details of where to send bug reports.
2014-09-25 16:21:36 +10:00
Zoltan Somogyi
500948d549 Break up mdbcomp/prim_data.m. The new modules have much better cohesion.
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.
2014-09-02 05:20:23 +02:00
Julien Fischer
c7fa6a1f53 Fix the decldebug grades with MSVC.
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.
2011-10-20 13:44:31 +00:00
Julien Fischer
78b0bf3c7f Use state variable field update syntax in more places.
Branches: main

Use state variable field update syntax in more places.

browser/*.m:
compiler/*.m:
deep_profiler/*.m:
	As above.
2011-05-05 07:11:52 +00:00
Ian MacLarty
2ddbac45bc When the declarative debugger is about to search in the
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.
2010-02-05 04:16:15 +00:00
Zoltan Somogyi
519d8f9508 Fix a bug in the handling of I/O actions by the debugger: the procedural
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.
2007-09-27 07:28:29 +00:00
Julien Fischer
977c445e00 Don't use the `!A ^ field :=' syntax yet.
browser/declarative_debugger.m:
	Don't use the `!A ^ field :=' syntax yet.
2007-06-08 15:43:15 +00:00
Ian MacLarty
5e7d665e9f Add a --reset-knowledge-base option to the mdb `dd' command. The new option
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.
2007-06-07 06:53:54 +00:00
Julien Fischer
b4c3bb1387 Clean up in unused module imports in the Mercury system detected
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.
2006-12-01 15:04:40 +00:00
Zoltan Somogyi
863874df85 Document my recent change implementing coverage testing.
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.
2006-10-02 05:21:44 +00:00
Julien Fischer
553fb3f7d9 Use pragma foreign_export' in preference to pragma export' throughout
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.
2006-08-31 11:09:54 +00:00
Zoltan Somogyi
00741b0162 This diff contains no algorithmic changes.
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.)
2006-08-22 05:04:29 +00:00
Julien Fischer
fc94027616 Fix the failure of debugger/declarative/sort.m.
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.
2006-06-13 06:48:56 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
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.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
7822554732 Replace __ with . as the module qualifier everywhere in all the modules
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.
2006-03-10 06:31:06 +00:00
Zoltan Somogyi
869dadb221 Minor style cleanups.
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Minor style cleanups.
2005-11-04 07:27:24 +00:00
Ian MacLarty
521967f39f Implement a second version of the subterm dependency tracking algorithm
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.
2005-11-02 14:02:16 +00:00
Ian MacLarty
fefcf468a0 Use dicing information in the declarative debugger.
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:
2005-08-24 09:07:14 +00:00
Ian MacLarty
cfa50105ba Allow the search mode to be changed from within the declarative debugger.
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.
2005-08-19 16:08:31 +00:00
Ian MacLarty
468b4d4945 Include a script to test the performance of the debugger in the tools
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.
2005-08-09 07:14:02 +00:00
Ian MacLarty
420272e7c4 Implement `undo' command in the declarative debugger.
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.
2005-07-28 06:44:11 +00:00
Zoltan Somogyi
a77588f6d2 Add two new capabilities to the debugger.
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".
2005-07-11 07:30:31 +00:00
Ian MacLarty
a9594132f2 Do not build an IO action map to pass around to predicates in the
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.
2005-06-19 02:14:17 +00:00
Ian MacLarty
8ac929888b In the declarative debugger, dynamically calculate the depth implicit subtrees
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.
2005-05-20 05:40:37 +00:00
Ian MacLarty
68587c5324 Look up atoms in the knowledge base as soon as they are added to the search
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.
2005-05-10 04:28:22 +00:00
Ian MacLarty
cabb22d14f Improve the declarative debugger interface.
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.
2005-05-02 04:21:19 +00:00
Ian MacLarty
c4cc27386e Fix three bugs in the declarative debuggger.
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.
2005-04-06 01:11:33 +00:00
Ian MacLarty
1a708a0ccc Add a new declarative debugger response, `info', which shows some information
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.
2005-03-12 04:46:33 +00:00
Ian MacLarty
436c5e6a6f Add --resume option to `dd' command. This resumes the previous declarative
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.
2005-03-02 01:20:23 +00:00
Ian MacLarty
3ee6e024fe Record label layouts in the annotated trace.
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.
2005-02-22 05:17:29 +00:00
Ian MacLarty
4970242093 Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
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.
2005-02-01 07:11:42 +00:00
Ian MacLarty
aa1e562a09 In the declarative debugger: use predmode syntax where appropriate; use `.'
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.
2005-01-28 00:56:06 +00:00
Zoltan Somogyi
67895b0b65 Fix the current mixture of __ and . to module qualify module names
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.
2005-01-24 07:41:05 +00:00
Julien Fischer
f58b8a4041 The namespace cleanliness check in the browser directory
Estimated hours taken: 1
Branches: main

The namespace cleanliness check in the browser directory
has been failing in the high-level C grades.  This is
because the symbols exported from term_rep did not have
one of the expected prefixes.  Fix this by making term_rep
part of the mdb package.

browser/mdb.m:
browser/term_rep.m:
	Make the term_rep module part of the mdb package.

browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/declarative_user.m:
	Conform to the above change.
2005-01-21 14:54:47 +00:00
Ian MacLarty
4e2e2c88ef Change the way atoms in the annotated trace are compared by constructing
Estimated hours taken: 4
Branches: main

Change the way atoms in the annotated trace are compared by constructing
a representation of the atom and then doing deterministic comparisons
on the representation, instead of calling compare_representation on
the actual atoms, which is cc_multi.

This will make looking up atoms in the knowledge base deterministic instead
of cc_multi, which is considerably easier to program with.

browser/declarative_debugger.m
	Define an exception as a term representation instead of a univ.

browser/declarative_execution.m
	In the annotated trace store atom arguments and exceptions as
	term_reps instead of univs.

	Make predicates that construct an atom argument and an exception
	cc_multi.

browser/declarative_oracle.m
	Remove the dependency on tree234_cc and set_cc - use map and set
	instead.

	Also make predicates that look up info in the knowledge base semidet
	instead of cc_multi.

browser/declarative_user.m
	Convert term_reps back to univs before printing them.

browser/term_rep.m
	New module implementing the term_rep type.

trace/mercury_trace_declarative.c
	Use new versions of procs to construct exceptions and atom
	arguments.
2005-01-19 02:43:38 +00:00
Ian MacLarty
ba2c9002e4 Add `mode' command to interactive term browser to display the mode of a
Estimated hours taken: 5
Branches: main

Add `mode' command to interactive term browser to display the mode of a
sub-term.  At the moment this command only works when the term browser is
invoked from inside the declarative debugger.

browser/browser_info.m
	Allow a function to be passed to the browser which it can call to
	work out the mode of a sub-term.

browser/browse.m
	Export versions of the browser invocation predicates that don't
	accept a mode function.

	Handle the `mode' browser command by calling the supplied function
	if it's present.

	Document the `mode' command in the browser help message.

browser/declarative_debugger.m
	To determine the mode of a sub-term we compare the state of
	instantiation of the sub-term at the CALL event and at the EXIT, FAIL
	or EXCP event.  To do this we need the initial and final
	atoms for incorrect contour bugs and wrong answer nodes (for
	other nodes the initial and final atoms are the same).

browser/declarative_oracle.m
	Conform to the fact that wrong answers now also have the
	initial atom.

browser/declarative_tree.m
	Export trace_atom_subterm_is_ground/3 for use in declarative_user.m.

	Include the initial atom in wrong answer nodes and incorrect contour
	bugs.

browser/declarative_user.m
	Add function arg_num_to_arg_pos to replace some duplicated code.

	Alter the edt_node_trace_atom predicate to find the initial and the
	final atoms for a question.

	Add a function to find the mode of a sub-term given the path to the
	sub-term and the initial and final atoms.  Pass this function to
	the browser so it can work out the mode of a sub-term.

browser/parse.m
	Parse `mode' command.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/browser_mode.exp
tests/debugger/declarative/browser_mode.inp
tests/debugger/declarative/browser_mode.m
	Test the `mode' command.
2005-01-18 03:56:53 +00:00
Ian MacLarty
85dff41b45 Add divide and query search strategy to declarative debugger.
Estimated hours taken: 80
Branches: main

Add divide and query search strategy to declarative debugger.  This version of
divide and query uses the number of descendent events as a weighting instead of
the number of descendent nodes, mainly because this is easy to compute when
portions of the annotated trace are not materialized.

browser/declarative_analyser.m
	Implement divide and query search.

	Introduce a default search mode which can be either top-down or
	divide and query.

browser/declarative_debugger.m
	Export predicates so the default search mode can be set with the
	`dd' command.

browser/declarative_edt.m
	Implement helper predicates for divide and query search.

	Maintain a weight field for each suspect and adjust this when
	suspects are asserted correct, inadmissible or ignored.

	Implement a check to make sure all suspects in the portion of the
	search space that could contain a bug have the correct weights.

	Recalculate the weights when a node is revised.

	Remove some code that will never be executed in
	assert_suspect_is_erroneous/3.  The code handles a case when
	a correct or inadmissible suspect is marked erroneous.  This can
	only happen when a search is being revised in which case the
	correct or erroneous suspect would be marked unknown.

	When marking suspects as in the complement of an erroneous subtree
	stop marking if a correct or inadmissible node is encountered since
	descendents of these will already have been removed from the bug
	search.

	Renamed the variable Leaves to StopSuspects in
	propagate_status_downwards, since the value of this variable is the
	list of the children of the lowest updated suspects which may or may
	not be leaves.

browser/declarative_execution.m
	Record REDO event numbers since these are used to calculate the
	number of descendent events for backtracked over calls.

browser/declarative_tree.m
	Implement predicate to calculate the number of descendent events
	for a node in the EDT.

doc/user_guide.texi
	Document divide and query and top-down search strategies and
	document the new --default-search-mode dd option.

	Put @samp{} around CALL.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/divide_and_query1.exp
tests/debugger/declarative/divide_and_query1.inp
tests/debugger/declarative/divide_and_query1.m
	Test divide and query search strategy.

trace/mercury_trace_declarative.h
trace/mercury_trace_declarative.c
	Record REDO event numbers.

	Add some functions to set the default search mode by calling the
	predicate exported from declarative_debugger.m

	Add a function to check that a search mode argument string is valid.

trace/mercury_trace_internal.c
	Add --default-search-mode option for `dd' command.

	Use readline completion for `dd' command options.
2005-01-09 01:14:09 +00:00
Ian MacLarty
ed3f7f6442 Print all atoms in a contour when an incorrect contour bug is found.
Estimated hours taken: 4
Branches: main

Print all atoms in a contour when an incorrect contour bug is found.

browser/declarative_debugger.m
	Define decl_contour type as a list of final atoms.

browser/declarative_tree.m
	Add function to find the exit atoms in a contour.  Include the contour
	in incorrect contour bugs.

browser/declarative_user.m
	Print exit atoms in contour when displaying incorrect contour bug.

doc/user_guide.texi
	Document new output for incorrect contour bugs.

tests/debugger/declarative/aadebug.exp
tests/debugger/declarative/app.exp
tests/debugger/declarative/args.exp
tests/debugger/declarative/big.exp
tests/debugger/declarative/binary_search.exp
tests/debugger/declarative/binary_search.exp2
tests/debugger/declarative/catch.exp
tests/debugger/declarative/catch.exp2
tests/debugger/declarative/empty_command.exp
tests/debugger/declarative/explicit_subtree.exp
tests/debugger/declarative/explicit_subtree.exp2
tests/debugger/declarative/filter.exp
tests/debugger/declarative/find_origin.exp
tests/debugger/declarative/find_origin.exp2
tests/debugger/declarative/func_call.exp
tests/debugger/declarative/func_call.exp2
tests/debugger/declarative/gcf.exp
tests/debugger/declarative/gcf.exp2
tests/debugger/declarative/higher_order.exp
tests/debugger/declarative/higher_order.exp2
tests/debugger/declarative/ho2.exp
tests/debugger/declarative/ho2.exp2
tests/debugger/declarative/if_then_else.exp
tests/debugger/declarative/ignore.exp
tests/debugger/declarative/ignore.exp2
tests/debugger/declarative/inadmissible.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/ite_2.exp
tests/debugger/declarative/ite_2.exp2
tests/debugger/declarative/lpe_example.exp
tests/debugger/declarative/lpe_example.exp2
tests/debugger/declarative/lpe_example.exp3
tests/debugger/declarative/oracle_db.exp
tests/debugger/declarative/output_term_dep.exp
tests/debugger/declarative/propositional.exp
tests/debugger/declarative/remember_modes.exp
tests/debugger/declarative/revise.exp
tests/debugger/declarative/shallow.exp
tests/debugger/declarative/skip.exp
tests/debugger/declarative/solutions.exp3
tests/debugger/declarative/special_term_dep.exp
tests/debugger/declarative/tabled_read_decl.exp
tests/debugger/declarative/trust.exp
tests/debugger/declarative/untraced_subgoal.exp
	Change expected output for test cases that print incorrect contour
	bugs.
2005-01-06 03:20:13 +00:00
Ian MacLarty
c511bd8b3e Allow the declarative debugger to search nodes above the node where the initial
Estimated hours taken: 20
Branches: main

Allow the declarative debugger to search nodes above the node where the initial
`dd' command was given.  If the user asserts that the node at which the `dd'
command was given is correct or inadmissible then the declarative debugger will
ask questions about ancestors of the node at which the `dd' command was given.
The declarative debugger will only say it cannot find a bug if the user asserts
that the main/2 (or whatever the topmost traced call is) call is correct or
inadmissible.

This is useful when you've found an inadmissible node in the procedural
debugger, but you're not sure where the erroneous ancestor is.

Fix bug in sub-term dependency tracking when tracking an input sub-term: If the
sub-term was bound by a primitive operation then the next question was about
the child of the node in which the sub-term was bound, instead of the node
itself.

Add --depth-step-size option to mdb `dd' command.  This allows the user to
specify the depth of each materialized portion of the EDT.

browser/declarative_analyser.m
	Allow analyser to request an explicit supertree from the diagnoser
	and respond correctly once an explicit subtree has been generated.

	When the primitive operation that binds a sub-term is found, the
	suspect_id of the node containing the primitive op is now returned, so
	handle this by asking the next question about the node containing the
	primitive op if its status is unknown.

	Stop tracking the sub-term if it is an input and we encounter an
	erroneous node.

	Remove previous_roots field from analyser_state.  It is not
	needed because this information is now kept in the search space.

browser/declarative_debugger.m
	Add new diagnoser response to tell backend to generate an explicit
	supertree.

browser/declarative_edt.m
	Add methods to mercury_edt typeclass to get the parent of an EDT node,
	tell if two nodes refer to the same event and tell if a node is the
	topmost node (usually the 1st call to main/2).

	Make find_subterm_origin return the suspect in which a primitive
	operation was executed.

	Add predicate to incorporate a new explicit supertree into the search
	space.

	Add predicate to tell the analyser when it's okay to stop tracking
	a sub-term.

	Fix bug in find_subterm_origin so it doesn't report a child as the
	binding node when it should be the parent.  Also replace duplicated
	code in find_subterm_origin with new predicate resolve_origin.

	Add extend_search_space_upwards predicate which attempts to add an
	extra node to the top of the search space.

	If a status is changed from erroneous to correct or vica versa then
	mark the suspects which were eliminated from the search space by
	the original status as unknown.

browser/declarative_execution.m
	Rename call_last_exit_redo to call_last_interface, since excp and fail
	nodes can also go here.

browser/declarative_tree.m
	Add implementations for new methods from mercury_edt typeclass.

doc/user_guide.texi
	Document --depth-step-size dd option.

	Remove duplicate save command documentation.

	Add a comment about new functionality.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/mapinit.exp
tests/debugger/declarative/mapinit.inp
	Use standardized event printing for mapinit test.

tests/debugger/declarative/app.exp
tests/debugger/declarative/app.inp
tests/debugger/declarative/revise_2.exp
tests/debugger/declarative/revise_2.inp
	Changed expected output and input because the bug search now continues
	in the ancestors of the node the original `dd' command was given in.

tests/debugger/declarative/catch.exp
	Now also get a "reached unknown label" warning after the (expected)
	error "no support for code that catches exceptions", since now a retry
	is done so we can return to the original event in the mdb session.

tests/debugger/declarative/explicit_subtree.exp
tests/debugger/declarative/explicit_subtree.exp2
tests/debugger/declarative/explicit_subtree.inp
tests/debugger/declarative/explicit_subtree.inp2
tests/debugger/declarative/explicit_subtree.m
	Modify this test to also test generation of an explicit supertree.

trace/mercury_trace_declarative.c
	If requested to generate a supertree then retry to a node
	above the current top most node and collect events down to the
	current top most node.

	Interactively retry across IO when building the annotated trace.
	This is more user friendly than simply aborting if untabled IO is
	encountered.

trace/mercury_trace_declarative.h
	Export MR_edt_depth_step_size so it can be set with the
	--depth-step-size dd option.

trace/mercury_trace_internal.c
	Add --depth-step-size option for `dd' command.
2004-12-16 00:12:41 +00:00
Ian MacLarty
732a892fe6 The main changes to the declarative debugger are:
Estimated hours taken: 200
Branches: main

The main changes to the declarative debugger are:

When you mark a subterm (using the term browser from within the DD), the
next question will be about the node that bound that subterm.  If that node is
correct then a binary search will be done between that node and the last
node you asserted was erroneous.

The declarative debugger is now a 3-valued debugger.  This means you can answer
inadmissible if a call's inputs violate some precondition of the call.  The
debugger will also infer a call is inadmissible if you mark one of its inputs
from the browser.

You don't have to give an argument number when invoking the term browser from
within the DD.  If an argument number is omitted then the whole call is
browsed as if it were a data term.

The subterm dependency tracking code now has the ability to track subterms of
closures, including subterms used when creating the closure by currying.
Subterm dependency tracking is also now more reliable when tracing information
is missing.

Lots of stuff in declarative_analyser.m has been redesigned to facilitate
future improvements, such as probabalistic debugging.

browser/declarative_analyser.m
	Transferred the definition of the mercury_edt type class to
	declarative_edt.m.  Added two new search algorithms: one to use
	suspicious subterm information to direct the bug search and one to do
	a binary search on a path in the EDT.

browser/declarative_debugger.m
	Added inadmissible as a truth value for the declarative debugger.
	Added ignore and skip responses.  Ignore responses are used when a
	call is to a trusted predicate.  Ignore tells the analyser that the
	node is not a bug itself, though it may have buggy children.  Skip
	means the oracle has skipped the question.

browser/declarative_edt.m
	Definition of the EDT type class and search_space type.  Search spaces
	are an extra layer on top of the EDT and provide useful services to
	the analyser such as keeping track of which nodes in the EDT might
	contain a bug.  In the future the search space will also be used to
	hold information like the probability that a node is buggy.
	Extended the mercury_edt type class with some useful methods.

browser/declarative_execution.m
	Added some utility predicates to extract information from a proc_id.

browser/declarative_oracle.m
	The oracle now only answers one question at a time.  This makes the
	implementation simpler.  I plan to get the oracle to tell the
	analyser everything it knows, without having to ask the user, whenever
	children are added to the search space, so that maximum information
	is always available to the search algorithms.
	Added a mechanism so the analyser can explicitly request that a
	question be re-asked of the user.
	Made some changes to handle inadmissible calls.

browser/declarative_tree.m
	Can now produce an i_bug as well as an e_bug.
	Made changes to handle dependency tracking of closure arguments.
	There are now two slightly different modes of subterm dependency
	tracking.  A fall-back mode where not all trace information is
	available and a "full" mode that assumes everything has been traced
	(which will be the case if compilation was with a debug grade).  The
	main difference is with higher order calls.  Because the id of the
	pred being called in a higher order call is not (easily) available,
	we can't safely match the HO call up with events on the contour if
	everything is not traced.  If everything is traced, then we can be sure
	the HO call's events will be where we expect them.
	Handled builtin calls which are treated as primitive ops.

browser/declarative_user.m
	User can now browse an entire call, instead of only one argument at
	a time.
	Allowed user to answer inadmissible.

browser/mdb.m
	Added mdb.declarative_edt.

browser/program_representation.m
	Added builtin_call_rep to represent builtin calls.
	Made plain calls to UCI predicates be treated as primitive ops.
	Added function to say if a goal generates internal events directly.
	Added a function to say whether an atomic goal is identifiable (i.e.
	whether we can get from its goal_rep its name, module and arity).

compiler/prog_rep.m
	Now creates builtin_call_rep atomic goal if the plain call was to
	a builtin.

compiler/trace_params.m
	Made minimum tracing for decldebug grade include program
	representations.  This is so the libraries compile with program
	representations, so we can do subterm dependency tracking through
	library calls.
	Trace level decl now includes the program representation.
	The default trace level for decldebug grade now includes the program
	representation.

doc/user_guide.texi
	Updated with new features.

tests/debugger/declarative/Mercury.options
	Removed superflous `--trace rep' options (since this is now implied by
	--trace decl).

tests/debugger/declarative/Mmakefile
	Added new tests.  Also made it possible to specify 3 different inputs:
	one for non-debugging grades, one for debug grades and one for
	decldebug grades.

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/binary_search.m
tests/debugger/declarative/binary_search_1.m
	Test binary search.

tests/debugger/declarative/builtin_call_rep.exp
tests/debugger/declarative/builtin_call_rep.inp
tests/debugger/declarative/builtin_call_rep.m
	Test that builtin_call_rep appears in the program representation
	for builtin calls.

tests/debugger/declarative/catch.exp
tests/debugger/declarative/catch.exp2
tests/debugger/declarative/catch.inp
	Use standardized output.

tests/debugger/declarative/closure_dependency.exp
tests/debugger/declarative/closure_dependency.exp2
tests/debugger/declarative/closure_dependency.inp
tests/debugger/declarative/closure_dependency.inp2
tests/debugger/declarative/closure_dependency.m
	Test dependency tracking through higher order calls.

tests/debugger/declarative/confirm_abort.exp
tests/debugger/declarative/confirm_abort.inp
	If the dd command is typed then the root node is now always asked as
	the first question even if the oracle knows the answer (except where
	the predicate is trusted).  Updated the test to reflect this change.

tests/debugger/declarative/dependency.exp
tests/debugger/declarative/dependency2.exp
	Arguments are now counted from the back (a change to get dependency
	tracking to work with higher order calls), so the debug messages
	printed in this test needed to be changed.

tests/debugger/declarative/explicit_subtree.exp
tests/debugger/declarative/explicit_subtree.exp2
tests/debugger/declarative/explicit_subtree.inp
tests/debugger/declarative/explicit_subtree.inp2
tests/debugger/declarative/explicit_subtree.m
	Test for a bug fixed with this diff.  The bug occured when the subtree
	for an implicit node was generated and then the explicit subtree for
	another implicit node to the left of the generated subtree was
	requested.  When building the new subtree execution proceeded from
	where execution stopped when the previous subtree was generated, so
	execution never passed through nodes to the left of the
	previous subtree and the requested subtree wasn't built.

tests/debugger/declarative/family.exp
tests/debugger/declarative/family.inp
	Some changes to event numbers to do with changes in the way explicit
	subtrees are generated (see comment for
	tests/debugger/declarative/explicit_subtree above).  Also some changes
	to do with the fact that the analyser now only asks the oracle one
	question at a time.

tests/debugger/declarative/find_origin.exp
tests/debugger/declarative/find_origin.exp2
tests/debugger/declarative/find_origin.exp3
tests/debugger/declarative/find_origin.inp
tests/debugger/declarative/find_origin.inp2
tests/debugger/declarative/find_origin.inp3
tests/debugger/declarative/find_origin.m
	Test sub-term dependency tracking.

tests/debugger/declarative/ho5.exp3
	Changes to do with the fact that the standard library is now
	compiled with deep tracing in the decldebug grade.

tests/debugger/declarative/ignore.exp
tests/debugger/declarative/ignore.exp2
tests/debugger/declarative/ignore.inp
tests/debugger/declarative/ignore.inp2
tests/debugger/declarative/ignore.m
tests/debugger/declarative/ignore_1.m
	Test `ignore' oracle response.

tests/debugger/declarative/inadmissible.exp
tests/debugger/declarative/inadmissible.inp
tests/debugger/declarative/inadmissible.m
	Test inadmissibility.

tests/debugger/declarative/input_term_dep.exp
tests/debugger/declarative/input_term_dep.inp
	Some of the bugs found are now inadmissible call bugs, since inputs
	were marked as incorrect.  Also made changes to do with the fact that
	incorrect sub-terms are now followed to where they're bound.

tests/debugger/declarative/lpe_example.exp3
	Added new expected output when in decldebug grade.  Event numbers and
	call depths are different now because of deep tracing in the standard
	library.

tests/debugger/declarative/mismatch_on_call.exp
tests/debugger/declarative/mismatch_on_call.exp2
tests/debugger/declarative/mismatch_on_call.inp
tests/debugger/declarative/mismatch_on_call.m
	This test used to cause an "mismatch on call" exception to be thrown
	by the dependency tracking routine.

tests/debugger/declarative/skip.exp
tests/debugger/declarative/skip.inp
tests/debugger/declarative/skip.m
	Test `skip' oracle response.

tests/debugger/declarative/solutions.exp3
tests/debugger/declarative/solutions.inp3
	Added new input and expected output for decldebug grade.
	Some standard modules need to be trusted since they are now deep traced
	in this grade.

tests/debugger/declarative/special_term_dep.exp
	A bug is now reported as an inadmissible call.

tests/debugger/declarative/throw.exp3
	Because the standard library in decldebug grade is now deep traced
	by default event numbers are different, parent contexts are printed
	and "reached label with no stack layout info" warnings are not
	encountered.

trace/mercury_trace_declarative.c
	Made the depth step size used when deciding which events to put in
	the annotated trace a variable so that it can be dynamically adjusted
	in the future.
	The EDT depth is now calculated independently instead of using
	event_info->MR_call_depth (which is not always consistent with
	the EDT depth).
	When generating an annotated trace for an explicit subtree the
	first event's preceeding event now points to the correct event in the
	existing annotated trace (instead of NULL).  This allows the parent of
	the root of the new explicit subtree to be calculated.
	Made changes so that all the interface events of child calls of a call
	are included in the annotated trace, so that contours are built
	correctly.
2004-11-19 11:54:46 +00:00
Ian MacLarty
e7d6509c95 Trust modules in the Mercury standard library by default in the declarative
Estimated hours taken: 6
Branches: main

Trust modules in the Mercury standard library by default in the declarative
debugger.

Make trusted object id's returned by `trusted' command persistent.  Previously
each trusted object was identified by its position in the ordered list of
trusted objects.  This meant that if an object was removed all objects after
the removed object in the ordered list of trusted objects would have their ids
decremented, so if the user wanted to then delete another object they'd have to
issue another `trusted' command to get the new id first.  The behaviour is now
consistent with the behaviour of breakpoint ids which keep their id for the
life of the breakpoint.

Put the mdb declarative debugger commands in their own section, instead of in
misc to be consistent with the mdb online help categories and so the online
help for the mdb declarative debugger commands is generated properly (the
dd help category wasn't getting any online documentation generated for it).

browser/declarative_debugger.m
	Add and export predicate to add the standard
	library to the set of trusted objects.

browser/declarative_oracle.m
	Add predicate to add the standard library to the set of trusted
	objects.

	Use a bimap to represent the set of trusted objects along with each
	object's id (we need to look up objects both ways).

	Adjust comment formatting to conform to standard.

	Rename trusted_module_or_predicate type to trusted_object.  Add
	constructor for standard_library to trusted_object type.  Include
	standard library when initialising the set of trusted objects.

	Change predicates adding or removing trusted objects to use new
	persistent object id.

	If a module belongs to the standard library and the standard library is
	trusted then trust the module.

compiler/modules.m
library/library.m
	Move definition of mercury_std_library_module/1 from modules.m to
	library.m so it can be used by the debugger.  Adjust comment
	accordingly.

compiler/mlds.m
	Import library module since since mercury_std_library_module/1 now
	resides there.

doc/generate_mdb_doc
	Generate declarative debugger commands documentation.

doc/user_guide.texi
	Document `trust std lib' command.

tests/debugger/declarative/catch.exp2
tests/debugger/declarative/catch.exp3
tests/debugger/declarative/catch.inp2
tests/debugger/declarative/solutions.exp2
tests/debugger/declarative/solutions.inp2
	Untrust the standard library for these tests.

tests/debugger/declarative/trust.inp
tests/debugger/declarative/trust.exp
	Update test to reflect persistent trusted object ids and trusting of
	standard library.

trace/mercury_trace_declarative.c
trace/mercury_trace_declarative.h
	Add function to trust the standard library.

trace/mercury_trace_internal.c
	Allow user to trust the standard library by issuing a `trust std lib'
	command.
2004-11-16 00:45:14 +00:00
Ian MacLarty
7015c4a436 Made the declarative debugger respect the format settings of the procedural
Estimated hours taken: 3
Branches: main

Made the declarative debugger respect the format settings of the procedural
debugger.  The print format set in the procedural debugger will now be used
when the declarative debugger asks questions and the browse format will now be
used when browsing terms in the declarative debugger.  If the user changes the
browser format during a declarative debugging session the procedural debugger
will respect these changes.

This also means the declarative debugger will respect the settings in the
.mdbrc file.

browser/declarative_debugger.m
	Added term browser state arguments to main diagnosis predicate and
	initialisation predicate.

browser/declarative_oracle.m
	Added predicates to get and set the term browser state.
	Set the term browser state in the initialisation prediciate for the
	oracle state.

browser/declarative_user.m
	Added predicates to get and set the term browser state.
	Set the term browser state in the initialisation prediciate for the
	user state.

tests/debugger/declarative/dependency.exp
	This test sets the print format in the procedural debugger, so
	the declarative debugger now uses this format.

trace/mercury_trace_browse.c
trace/mercury_trace_browse.h
	Exported the global variable which stores the state of the procedural
	debugger term browser and the function which initialises this state, so
	they can be used from mercury_trace_declarative.c.

trace/mercury_trace_declarative.c
	Pass the procedural debugger term browser state to the declarative
	debugger and update the state when the declarative debugger is
	finished.
2004-10-25 05:30:19 +00:00
Ian MacLarty
e6d82c9bd4 Added trusted' and untrust' commands. Also allowed individual predicates to
Estimated hours taken: 10
Branches: main

Added `trusted' and `untrust' commands.  Also allowed individual predicates to
be trusted.

browser/declarative_debugger.m
	Exported predicates to add a trusted predicate or function, remove
	a trusted object and return a list of the trusted objects.

browser/declarative_oracle.m
	Changed trusted set so it can also contains individual predicates and
	functions.  Added predicates to add a trusted predicate or function
	to the set, remove a trusted object from the set and return a list
	of the trusted objects.

doc/mdb_categories
	Added dd category.

doc/user_guide.texi
	Documented `untrust' and `trusted' commands.

runtime/mercury_stack_trace.c
runtime/mercury_stack_trace.h
	Added a print_mode argument to MR_print_proc_id_internal, so that
	printing of mode information can be turned on or off.  When a list
	of matching predicates for the trust command is shown then mode
	information is superfluous, since a predicate/function is trusted, not
	a procedure.
	Added MR_print_pred_id to print predicate id - i.e. proc id without
	the mode info.

tests/debugger/completion.exp
	New commands shown in completion list.

tests/debugger/completion.inp
	Added a space, since a --More-- prompt is now displayed when showing
	all the commands.

tests/debugger/mdb_command_test.inp
	untrust and trusted added.

tests/debugger/declarative/trust.exp
tests/debugger/declarative/trust.inp
	Testing of new commands.

trace/mercury_trace_declarative.c
trace/mercury_trace_declarative.h
	Added functions to add a trusted predicate and remove a trusted
	object.  Also added a function to print a list of the trusted objects.
	These all call the predicates exported from declarative_debugger.m.

trace/mercury_trace_internal.c
	Added handlers for `trusted' and `untrust' commands.

trace/mercury_trace_tables.c
trace/mercury_trace_tables.h
	Added a function to filter out only the user predicates and functions
	from a list of procedures.  This filters out uci procs and also
	filters out all procs with a mode number > 0 (thus leaving one proc
	for each predicate/function).  This is used when displaying the
	predicates matching an ambiguous proc-spec with a trust command.

NEWS
	Updated NEWS file.
2004-09-20 04:50:26 +00:00
Ian MacLarty
6b14f3921d The annotated trace used for declarative debugging now keeps a reference to the
Estimated hours taken: 5
Branches: main

The annotated trace used for declarative debugging now keeps a reference to the
proc layout for a predicate/function, instead of all the details of the
predicate/function.  This saves space and gives access to more information
about the predicate/function.

browser/declarative_debugger.m
	Changed write_origin to look up the proc name through the proc_layout.

browser/declarative_execution.m
	Info about the predicate like its name, module etc is now represented
	by a proc_layout type.  Changed the trace_atom type appropriately and
	added useful predicates and functions to manipulate proc_layouts -
	thanks to Zoltan.

browser/declarative_oracle.m
	Since proc_layouts are unique per mode, all modes must now be added to
	the knowledge base in assert_oracle_kb.

browser/declarative_tree.m
	Minor changes to predicate that expected four arguments to trace_atom
	type.

browser/declarative_user.m
	Minor changes to predicates that used the old trace_atom type.

tests/debugger/declarative/remember_modes.m
	Test to see that all modes of a predicate are added to the knowledge
	base of the oracle.

tests/debugger/declarative/Mmakefile
	Added remember_modes test.

tests/debugger/declarative/remember_modes.exp
	Expected results for remember_modes test.

tests/debugger/declarative/remember_modes.inp
	Input to remember_modes test.

tests/debugger/declarative/trust.m
	Removed superfluous import of trust_1 in interface.

trace/mercury_trace_declarative.c
	Removed MR_decl_atom_name_and_module which is no longer necessary
	since the debugger looks the name and module up in the proc_layout
	directly.
2004-07-07 05:26:17 +00:00