Commit Graph

68 Commits

Author SHA1 Message Date
Zoltan Somogyi
de0ff762d8 Convert some if-then-elses to switches.
Estimated hours taken: 2
Branches: main

analysis/analysis.file.m:
analysis/analysis.m:
browser/declarative_execution.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/interactive_query.m:
browser/parse.m:
browser/sized_pretty.m:
	Convert some if-then-elses to switches.
2007-12-30 11:11:06 +00:00
Zoltan Somogyi
b56885be93 Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.
Estimated hours taken: 12
Branches: main

Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.

The problem was not in lco.m, but in follow_code.m. In some cases,
(specifically, the LCMC version of insert_2 in sparse_bitset.m),
follow_code.m moved an impure goal (store_at_ref) into the arms of an
if-then-else without marking those arms, or the if-then-else, as impure.
The next pass, simplify, then deleted the entire if-then-else, since it
had no outputs. (The store_at_ref that originally appeared after the
if-then-else was the only consumer of its only output.)

The fix is to get follow_code.m to make branched control structures such as
if-then-elses, as well as their arms, semipure or impure if a goal being moved
into them is semipure or impure, or if they came from an semipure or impure
conjunction.

Improve the optimization of the LCMC version of sparse_bitset.insert_2, which
had a foreign_proc invocation of bits_per_int in it: replace such invocations
with a unification of the bits_per_int constant if not cross compiling.

Add a new option, --optimize-constructor-last-call-null. When set, LCMC will
assign NULLs to the fields not yet filled in, to avoid any junk happens to be
there from being followed by the garbage collector's mark phase.

This diff also makes several other changes that helped me to track down
the bug above.

compiler/follow_code.m:
	Make the fix described above.

	Delete all the provisions for --prev-code; it won't be implemented.

	Don't export a predicate that is not now used anywhere else.

compiler/simplify.m:
	Make the optimization described above.

compiler/lco.m:
	Make sure that the LCMC specialized procedure is a predicate, not a
	function: having a function with the mode LCMC_insert_2(in, in) = in
	looks wrong.

	To avoid name collisions when a function and a predicate with the same
	name and arity have LCMC applied to them, include the predicate vs
	function status of the original procedure included in the name of the
	new procedure.

	Update the sym_name of calls to LCMC variants, not just the pred_id,
	because without that, the HLDS dump looks misleading.

compiler/pred_table.m:
	Don't have optimizations like LCMC insert new predicates at the front
	of the list of predicates. Maintain the list of predicates in the
	module as a two part list, to allow efficient addition of new pred_ids
	at the (logical) end without using O(N^2) algorithms. Having predicates
	in chronological order makes it easier to look at HLDS dumps and
	.c files.

compiler/hlds_module.m:
	Make module_info_predids return a module_info that is physically
	updated though logically unchanged.

compiler/options.m:
	Add --optimize-constructor-last-call-null.

	Make the options --dump-hlds-pred-id, --debug-opt-pred-id and
	--debug-opt-pred-name into accumulating options, to allow the user
	to specify more than one predicate to be dumped (e.g. insert_2 and
	its LCMC variant).

	Delete --prev-code.

doc/user_guide.texi:
	Document the changes in options.m.

compiler/code_info.m:
	Record the value of --optimize-constructor-last-call-null in the
	code_info, to avoid lookup at every cell construction.

compiler/unify_gen.m:
compiler/var_locn.m:
	When deciding whether a cell can be static or not, make sure that
	we never make static a cell that has some fields initialized with
	dummy zeros, to be filled in for real later.

compiler/hlds_out.m:
	For goals that are semipure or impure, note this fact. This info was
	lost when I changed the representation of impurity from markers to a
	field.

mdbcomp/prim_data.m:
	Rename some ambiguous function symbols.

compiler/intermod.m:
compiler/trans_opt.m:
	Rename the main predicates (and some function symbols) of these modules
	to avoid ambiguity and to make them more expressive.

compiler/llds.m:
	Don't print line numbers for foreign_code fragments if the user has
	specified --no-line-numbers.

compiler/make.dependencies.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.usage.m:
	Don't use io.write to write out information to files we may need to
	parse again, because this is vulnerable to changes to the names of
	function symbols (e.g. the one to mdbcomp/prim_data.m).

	The compiler still contains some uses of io.write, but they are
	for debugging. I added an item to the todo list of the one exception,
	ilasm.m.

compiler/recompilation.m:
	Rename a misleading function symbol name.

compiler/parse_tree.m:
	Don't import recompilation.m here. It is not needed (all the components
	of parse_tree that need recompilation.m already import it themselves),
	and deleting the import avoids recompiling almost everything when
	recompilation.m changes.

compiler/*.m:
	Conform to the changes above.

compiler/*.m:
browser/*.m:
slice/*.m:
	Conform to the change to mdbcomp.

library/sparse_bitset.m:
	Use some better variable names.
2007-01-19 07:05:06 +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
Zoltan Somogyi
f9cac21e3e Get rid of a bunch more ambiguities by renaming predicates, mostly
Estimated hours taken: 8
Branches: main

Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.

In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).

NEWS:
	Mention that the names of some library functions have changed.

library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
	Make the changes mentioned above, and conform to them.

test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
	Conform to the above changes.
2006-09-20 09:42:28 +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
f387b99b2a Fix a bug that was causing debugger/declarative/browse_arg to fail.
Estimated hours taken: 5
Branches: main, release

Fix a bug that was causing debugger/declarative/browse_arg to fail.  The
problem was that the default format command in the the declarative debugger
was setting format for the browser rather than for the print command.

browser/browser_info.m:
	If a format command with no options is issued at the dd> prompt make
	sure we update the correct set of params.  The existing code was
	written in such a way that it would _always_ update the params for the
	browser regardless of where the format command was invoked.

borwser/declarative_user.m:
	The default format command at the dd> prompt should change the
	settings for the print command, not the browser.

browser/RESERVED_MACRO_NAMES:
	s/polution/pollution/

tests/debugger/declarative/browse_arg.exp:
	Update the expected output for this test case to match the current
	input.
2006-06-06 07:37:37 +00:00
Julien Fischer
fc79e1f63c Fix two bugs in the declarative debugger's command handling.
Estimated hours taken: 2
Branches: main, release.

Fix two bugs in the declarative debugger's command handling.  The `params'
command wasn't being parsed and the code to handle the `actions' command
expected it to be called `num_io_actions'.

browser/declarative_user.m:
	Fix the command handler for `actions'.

	Add a command handler for the `params' command.

	Fix a typo: s/supress/suppress/

browser/parse.m:
browser/browser_info.m:
	Fix some formatting.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/dd_params.m:
tests/debugger/declarative/dd_params.inp:
tests/debugger/declarative/dd_params.exp:
	Test case for the above.
2006-06-05 07:03:01 +00:00
Zoltan Somogyi
dd44e0ef62 Replace the "set" command of mdb with a bunch of commands: the `format',
Estimated hours taken: 16
Branches: main, release

Replace the "set" command of mdb with a bunch of commands: the `format',
`format_param', `list_context_lines', `list_path', `xml_browser_cmd',
`xml_tmp_filename', `fail_trace_counts', `pass_trace_counts' and
`max_io_actions' commands. Each of these set just one parameter
or one of set of closely related parameters.

Move all these commands, and some existing commands that set parameters
that were elsewhere, to the "parameter" command category.

Extend some of these commands so that if given no arguments, they report
the current values of the parameters they would otherwise set.

Replace the "set" commands of the mdb browser and of the declarative debugger
with a bunch of commands: "format", "depth", "size", "width", "lines",
"actions" and "params" (the last prints the current value of the parameters).

For each category of mdb commands, create files mercury_trace_cmd_<cat>.[ch],
and move the functions dealing with that category of commands there from
mercury_trace_internal.c. Give each of these new files a logical structure
that was sometimes missing from the relevant parts of mercury_trace_internal.c.

NEWS:
	Mention these changes.

doc/mdb_categories:
	Document these changes.

doc/user_guide.texi:
	Document these changes.

	Fix an old documentation bug: you couldn't set listing paramaters
	from a declarative debugger command.

	Fix an old documentation bug: the description of the goal_path step
	for scopes was obsolete.

	Fix some obsolete references to : as module qualifier.

browser/parse.m:
	Update the browser command set along the lines at the top.

browser/declarative_user.m:
	Update the declarative debugger command set along the lines at the top.

	Move the declaration for the type representing declarative debugger
	commands to near the top of the file.

browser/browser_info.m:
	Provide some access predicates.

	Update the predicate that generates mdb commands to save the persistent
	state of the debugger to generate the new forms of parameter commands.

	Move types and predicates for dealing with browser parameters from
	browse.m to here, so that declarative_user.m can use them too.

browser/browse.m:
	Delete the code moved to browser_info.m, and conform to the other
	changes in the other modules.

browser/listing.m:
	Provide a predicate to return the type of listing paths.

scripts/mdbrc.in:
	Update the commands that set the XML parameters.

scripts/Mmakefile:
	Get mmake to rebuild mdbrc from mdbrc.in when mdbrc.in changes.

trace/mercury_trace_internal.c:
trace/mercury_trace_cmds.h:
trace/mercury_trace_cmd_*.[ch]:
	Implement the changes described at the top.

	Fix an old bug: the commands that update the search path for the "list"
	command don't make the search path term permanent, which is needed in
	non-conservative-gc grades.

trace/mercury_trace_spy.c:
	Fix some obsolete references to : as module qualifier.

trace/mercury_trace_browse.[ch]:
	Delete the functionality now moved to mercury_trace_cmd_parameter.c.

tests/debugger/mdb_command_test.inp:
	Update the set of commands being tested.

tests/debugger/save.{inp,exp}:
	Update the parameter commands in this test case.
2006-04-04 07:37:31 +00:00
Zoltan Somogyi
892bf00ce2 XXX: the change to the mdb "set" command is not yet documented; that will be
Estimated hours taken: 3
Branches: main

XXX: the change to the mdb "set" command is not yet documented; that will be
addressed in the next change.

Fix the debugger's save command so that it saves everything it should save
(with one unavoidable exception). Rename the "save_to_file" command to "dump",
as we agreed.

NEWS:
doc/user_guide.texi:
doc/mdb_categories:
	Document these facts.

browser/browser_info.m:
	Provide a predicate to save the entire persistent state of the browser.

	Provide a predicate to set the number of I/O actions printed by the
	declarative debugger.

	Check that the XML browser command and temp file name being set aren't
	empty, since those are not meaningful.

	Rename predicates to avoid ambiguities and excessively long names.
	Simplify some code.

browser/browse.m:
	Generate better error messages if the user tries to use XML browsing
	without setting it up.

browser/browse.m:
browser/declarative_user.m:
	Conform to the changes in browser_info.m

browser/listing.m:
	Use the correct prefix on global C symbols.

trace/mercury_trace_internal.c:
	Change the save command to save everything of the persistent debugger
	state that can be saved.

	Allow the set command to set the number of I/O actions printed by the
	declarative debugger. Without this, there would be no way to restore
	this part of the debugger persistent state, since a source command
	cannot start the declarative debugger.

	Rename save_to_file as dump.

	Use the correct prefix on global C symbols.

	Avoid misleading capitalization.

trace/mercury_trace_spy.c:
	Extend the code that saves the state of breakpoints to save conditions
	on breakpoints as well.

trace/mercury_trace_browser.[ch]:
	Add a utility function for saving the persistent browser state.

	Conform to the changes in browser/browser_info.m.

trace/mercury_trace_alias.[ch]
	Convert to four-space indentation.

tests/debugger/browser_test.{inp,exp}:
tests/debugger/mdb_command_test.inp:
	Use dump instead of save_to_file.

tests/debugger/save.{m,inp,exp}:
	New test case to test the new behavior of the save command.

tests/debugger/Mmakefile:
	Enable the new test case.
2006-03-31 05:12:19 +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
Ian MacLarty
11042e060c Allow field names to be used in the paths used with subterm dependency
Estimated hours taken: 5
Branches: main

Allow field names to be used in the paths used with subterm dependency
tracking.

Allow the user to cd to the return value of a function by giving the
number of arguments plus one as an argument to the `cd' command.

browser/browse.m:
	Export the predicate that removed ".." from paths.
	Make the return value of this predicate a subtype, so we can be
	sure the simplification has been applied to the path.

	Allow the user to do `cd N', where N is the number of arguments of
	a function plus one.  This will cd to the return value of the function.

	Add some more aliases for the directory name of the return value of a
	function.

browser/browser_info.m:
	Use the new simplified_dirs inst.
	When converting a list of directories to a term path, look at the
	value the path applies to to resolve field names in the path.

browser/declarative_user.m:
	Report an error if the user tries to track an I/O action.
	Call the new version of convert_dirs_to_term_path which handles
	field names in the path.

browser/term_rep.m:
	Add predicates to lookup a subterm in a term representation and
	also to look up a named field in a term representation.

tests/debugger/declarative/Mercury.options:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/named_fields.exp:
tests/debugger/declarative/named_fields.inp:
tests/debugger/declarative/named_fields.m:
	Test tracking of subterms using a path with a field name.

tests/debugger/polymorphic_output.exp*
	The output of this test has changed, because cd's to the return value
	of a function, using a number, are now allowed.
2006-02-08 21:48:36 +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
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
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
b4b2807529 Allow an XML term browser to be called from the declarative debugger.
Estimated hours taken: 6
Branches: main

Allow an XML term browser to be called from the declarative debugger.

browser/browse.m
	Add a predicate to save a term to an XML file and then launch an
	XML browser.

	Add a predicate that saves a term to an XML file and doesn't print
	any error messages, but just returns an io.res result.  Use this
	in save_term_to_file_xml and the predicate mentioned above.

browser/browser_info.m
	Add two fields to the browser's persistent state - one to record the
	temporary filename to use when saving a term to an XML file and one
	to hold the command to launch the XML browser.  Previously these were
	stored in C global variables which were not accessible from the
	declarative debugger.

	Export the browser_persistent_state type so the field access functions
	can be used from browse.m.

browser/declarative_user.m
	Allow the user to give an -x or --xml option to the browse command from
	within the declarative debugger.

	Reformat the user_command type and add a new functor: browse_xml_arg/1.

	Describe the -x or --xml browse option in the help message and reformat
	the trust command help message as it was looking a bit untidy.

tests/debugger/browser_test.exp
tests/debugger/browser_test.inp
	Test the --xml option from within the declarative debugger.

trace/mercury_trace_browse.c
trace/mercury_trace_browse.h
trace/mercury_trace_internal.c
	Move MR_trace_save_and_invoke_xml_browser from mercury_trace_internal.c
	to mercury_trace_browse.c so it can call the new Mercury code in
	browser/browse.m.

	Handle the `set xml_browser_cmd' and `set xml_tmp_filename' commands by
	calling Mercury code to set the appropriate fields in the persistent
	browser state.
2005-02-22 22:27:50 +00:00
Ian MacLarty
81b4dab4a3 Print "Found unhandled or incorrect exception" instead of just "Found unhandled
Estimated hours taken: 0.5
Branches: main and 0.12

Print "Found unhandled or incorrect exception" instead of just "Found unhandled
exception" when a bug node that throws an exception is found by the declarative
debugger.  This is because the user may intend that an exception is thrown, but
the bug is that the wrong one is being thrown.

browser/declarative_user.m
	Print the new message.

tests/debugger/declarative/catch.exp
tests/debugger/declarative/exceptions.exp
tests/debugger/declarative/ho5.exp
tests/debugger/declarative/ho5.exp2
tests/debugger/declarative/ho5.exp3
tests/debugger/declarative/throw.exp
tests/debugger/declarative/throw.exp2
tests/debugger/declarative/throw.exp3
	Update the expected output.
2005-02-10 04:41:44 +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
Ian MacLarty
4f2a8bf27d In the declarative debugger print "Unsatisfiable?" instead of
Estimated hours taken: 0.5
Branches: main

In the declarative debugger print "Unsatisfiable?" instead of
"No Solutions. Complete?" when asking questions about goals that failed with no
solutions.

browser/declarative_user.m
	Print "Unsatisfiable?" when there are no solutions to a goal.

tests/debugger/declarative/aadebug.exp
tests/debugger/declarative/backtrack.exp
tests/debugger/declarative/backtrack.exp2
tests/debugger/declarative/big.exp
tests/debugger/declarative/browser_mode.exp
tests/debugger/declarative/comp_gen.exp
tests/debugger/declarative/divide_and_query1.exp
tests/debugger/declarative/exeptions.exp
tests/debugger/declarative/exeptions.exp2
tests/debugger/declarative/explicit_subtree.exp2
tests/debugger/declarative/failed_cond.exp
tests/debugger/declarative/family.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/ho3.exp
tests/debugger/declarative/ho4.exp
tests/debugger/declarative/if_then_else.exp
tests/debugger/declarative/ite_2.exp
tests/debugger/declarative/ite_2.exp2
tests/debugger/declarative/neg_conj.exp
tests/debugger/declarative/neg_conj.exp2
tests/debugger/declarative/output_term_dep.exp
tests/debugger/declarative/queens.exp
	Expect "Unsatisfiable?" when the question is about a goal with no
	solutions.
2005-01-27 02:38:59 +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
Peter Wang
59d2d4a573 This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17
Branches: main

This adds a module mdbcomp__trace_counts that reads in the
.mercury_trace_counts files produced by the compiler's trace mechanism.
The format of said files was slightly changed.

As the new module is to be used by the compiler and the debugger, it is
placed in the mdbcomp module.  This required bringing some types from the
compiler into a new module within mdbcomp.

browser/trace_counts.m:
	New module for reading execution trace summaries.

browser/prim_data.m:
	New module holding types and predicates moved in from the compiler.
	Types:
		pred_or_func, sym_name, module_name, proc_label,
		special_pred_id, trace_port
	Predicates:
		string_to_sym_name, insert_module_qualifier

	The mode field of proc_label is now an int instead of a proc_id
	to avoid pulling proc_id into mdbcomp.

browser/mdbcomp.m:
	Add trace_counts and prim_data to the mdbcomp module.

browser/declarative_execution.m:
	Renamed mdb's definition of module_name to flat_module_name
	to avoid conflicts with the definition in mdbcomp__prim_data.

runtime/mercury_trace_base.c:
	In the format of .mercury_trace_counts, write module and predicate
	names now use quoted atom syntax so that names with spaces and
	non-printable characters can be machine-parsed.

browser/:
compiler/:
	Many changes to account for movement of types, and the change to
	proc_label.
2005-01-19 03:11:22 +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
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
dce0b465e1 Allow `trust' as declarative debugger question response.
Estimated hours taken: 1.5
Branches: main

Allow `trust' as declarative debugger question response.  The user may respond
with simply `trust' in which case the current predicate or function will be
trusted, or `trust module' in which case the module the current question
relates to will be trusted.

browser/declarative_oracle.m
	If the user response is trust_predicate or trust_module then
	add the predicate/function or module to the list of trusted objects
	and return an `ignore' response to the analyser.

browser/declarative_user.m
	Handle `trust' command and add it to the help messgae.

doc/user_guide.texi
	Document `trust' and `trust module' declarative debugger commands.

tests/debugger/declarative/trust.exp
tests/debugger/declarative/trust.inp
	Test the `trust' and `trust module' commands.
2005-01-05 12:25:56 +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
1974e66710 Make `set' mdb command work from within the declarative debugger.
Estimated hours taken: 2
Branches: main

Make `set' mdb command work from within the declarative debugger.

browser/browse.m
	Make set_browse_param call a new predicate set_param/5 in
	browser_info.m.

browser/browser_info.m
	Add set_param/5 to set browser parameters from an option table.

browser/declarative_user.m
	Add and handle `set' command.
	Add help text.

browser/parse.m
	Make parse/2 public so it can be called from the declarative debugger.

tests/debugger/declarative/browse_arg.exp
tests/debugger/declarative/browse_arg.inp
	Add test case.
2004-10-27 02:23:27 +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
Zoltan Somogyi
d48544ed7f Factor out common code in the handling of plain terms and synthetic terms.
Estimated hours taken: 2
Branches: main

Factor out common code in the handling of plain terms and synthetic terms.
We already had a mechanism (the browser_term type and operations on it) for
handling them in a unified manner, we just didn't use them everywhere we could.

browser/browser_term.m:
	Add this new module to hold the browser_term type and the operations
	on it, which previously were in two different modules (browser_info
	and browse respectively).

	Make the operations function, since that is their natural form.

browser/mdb.m:
	Add the new module.

browser/browser_into.m:
	Delete the type moved to browser_term.m.

browser/browse.m:
	Delete the operations moved to browser_term.m.

	Replace operation pairs on plain terms and synthetic terms with
	generalized operations on browser terms.

browser/declarative_user.m:
browser/io_action.m:
browser/sized_pretty.m:
trace/mercury_trace_browser.c:
	Conform to the changes listed above.
2004-08-09 03:05:23 +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
Ian MacLarty
8ea1dbc3b5 Added a `trust' command to mdb which tells the declarative debugger to assume
Estimated hours taken: 35
Branches: main

Added a `trust' command to mdb which tells the declarative debugger to assume
all procedures in a given module are correct.

browser/declarative_debugger.m
	Added function which finds out the atom a given	question relates to.
	Exported a add_trusted_module predicate so modules can be added from
	c code (used by trace/mercury_trace_declarative.c).

browser/declarative_execution.m
	Add module_name field to the atom constructor for the trace_atom type.
	Made necessary changes to predicates that expected 3 fields for the
	atom constructor for the trace_atom type.

browser/declarative_oracle.m
	Added a set of trusted module names to the oracle_state type.

browser/declarative_tree.m
	Updated various predicates that expected the atom constructor to have
	3 fields where now it has 4.

browser/declarative_user.m
	Updated various predicates that expected the atom constructor to have
	3 fields where now it has 4.

trace/mercury_trace_declarative.h
	Added MR_decl_add_trusted_module function to add a module to the set of
	trusted modules for the currect diagnoser.

trace/mercury_trace_declarative.c
	Implemented the MR_decl_add_trusted_module function.  This calls
	MR_trace_decl_ensure_init to make sure the diagnoser is initialised
	first.

	Changed the MR_decl_make_atom function to include the module name
	when constructing an atom.

	Added MR_decl_atom_name_and_module function which extracts the proc
	name and module from a MR_Proc_Layout.  This replaces the
	MR_decl_atom_name function which just extracted the name.  This
	function will also extract the name and module of user defined equality
	and comparison predicates.

trace/mercury_trace_internal.c
	Added MR_trace_cmd_trust function to add a trusted module to the
	current diagnoser when the user issues a `trust' command.

doc/mdb_categories
	Added `trust' command to misc category (will need to make a declarative
	category when there are more commands).

doc/user_guide.texi
	Added some help text for the `trust' command.

tests/debugger/mdb_command_test.inp
	Added `trust' command to list of tests.

tests/debugger/declarative/Mmakefile
	Added calls to the trust.m program to test the `trust' command.

tests/debugger/declarative/trust.m
	Test program for the `trust' command.  This imports 2 modules in the
	and calls a user-defined comparison predicate from the one module and
	a normal predicate from the other.

tests/debugger/declarative/trust_1.m
	Imported by trust.m.  Defines a new type and a user-defined comparison
	predicate on the type.

tests/debugger/declarative/trust_2.m
	Also imported by trust.m.  Defines a predicate using the type defined
	in trust_1.m.

tests/debugger/declarative/trust.inp
	Input to mdb to test the `trust' command.  Contains commands to tell
	mdb to trust the trust_1 and trust_2 modules.

tests/debugger/declarative/trust.exp
	Expected output of mdb when running trust with trust.inp as input.
2004-06-15 05:35:13 +00:00
Zoltan Somogyi
ecdc285bc7 Split the existing browser library into two libraries, by making the
Estimated hours taken: 10
Branches: main

Split the existing browser library into two libraries, by making the
program_representation module into its own library. This is useful because
the compiler refers to program_representation.m, whose code thus needs to be
linked into compiler executables even if the compiler isn't compiled with
debugging enabled. By creating a new library for this module, we avoid any
chance of the linker dragging in the rest of the modules in the browser
library. (This is a problem with an upcoming diff.).

The name of the new library is "mdbcomp", because the intention is that it
contain code that is shared between the debugger and the compiler. This means
mostly the definitions of data structures that the compiler generates for the
debugger, and the predicates that operate on them.

Mmake.common.in:
	Allow MDB_COMP_ as a prefix for symbol names in the browser directory.

Mmake.workspace:
	Add a make variable holding for the name of the new library, and
	add the name to the relevant lists of libraries.

	Avoid duplicating the lists of filenames that need to be updated
	when adding new libraries or changing their names.

Mmakefile:
	Use make variables to refer to library names.

browser/mdbcomp.m:
browser/mer_mdbcomp.m:
	Add these files as the top modules of the new library.

browser/program_representation.m:
	Make program_representation.m a submodule of mdbcomp, not mdb.

browser/program_representation.m:
browser/browser_info.m:
	Move a predicate from program_representation.m to browser_info.m
	to avoid the mdbcomp library depend on the browser library, since
	this would negate the point of the exercise.

browser/mdb.m:
	Delete program_representation.m from the list of submodules.

browser/Mmakefile:
	Update this file to handle the new module.

browser/Mercury.options:
	Mention the new module.

browser/*.m:
	Update the lists of imported modules. Import only one browser module
	per line.

compiler/notes/overall_design.html:
	Document the new library.

compiler/compile_target_code.m:
	Add the mdbcomp library to the list of libraries we need to link with.

compiler/prog_rep.m:
trace/mercury_trace_internal.c:
	Import program_representation.m by its new name.

scripts/c2init.in:
	Centralize knowledge about which files need to be updated when the list
	of libraries changes here.

scripts/c2init.in:
scripts/ml.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/linear:
tools/lml:
	Update the list of libraries programs are linked with.
2003-10-27 06:00:50 +00:00
Zoltan Somogyi
bed904e722 Make browsing in the debugger more flexible by adding options to the "ls",
Estimated hours taken: 8
Branches: main

Make browsing in the debugger more flexible by adding options to the "ls",
"print" and "set" commands of the browser. Make browsing in the debugger less
confusing by making the "set" command by default set the parameters used
not just by the "ls" command but also by the "print" command, both inside and
outside the browser. This is done by making "ls" and "print" synonyms inside
the term browser.

browser/parse.m:
	Replace the commands ls/0, ls/1 and print/1 with a single command,
	print/2. The arguments of print/2 specify

	- the presence or absence of options controlling which formatter to
	  use, and
	- the path to the subterm to look at (which the "ls" command had,
	  but not the "print" command).

	Change the set/1 command into the set/2 command, adding a field
	specifying the presence or absence of options controlling which
	caller type and/or which formatter parameters to set. The set/2
	command within the browser prompt now functions the same as the "set"
	command from the mdb prompt, because they now call the same code
	to update the parameter sets.

	Change the parsing infrastructure to allow the use of getopt to
	process the options, by keeping around the word structure even after
	tokenization.

	Comment out code that isn't called, but may be needed later
	for debugging.

	Update the block comment documenting the command syntax.

browser/browse.m:
	Conform to the change in the type of commands.

	Change the implementation of the "set" command. Instead of the default
	being to change only the parameter set used by the "ls" command, make
	the default the application of the change to all the parameter sets.
	If users want to restrict the change to apply only to the "ls" command,
	they can specify the -B option.

	Change the implementation of the set/0 command to report not just one
	set of parameters, but all of them, since they can now all be changed
	by the set/2 command.

	Update the help message, to show the new options and to group related
	commands together.

browser/browser_info.m:
	Provide variants of the predicates for changing settings that are
	specialized for the requirements of mdb and of the term browser.

	Change the default format for the browser to "flat", to match the
	default for the mdb "print" command. This was the default for the
	browser's print command as well. This changes the default behavior
	of the browser's "ls" command. Since "print" and "ls" had different
	defaults but are now synonyms, we had to break backward compatibility
	for one or the other. (Preserving different defaults for these two
	browser commands would create an unnecessarily complicated user
	interface with respect to the meaning of their options.)

browser/declarative_user.m:
	Make it possible to switch the parameter set used to by the declarative
	debugger to print atoms quickly yet consistently.

trace/mercury_trace_browse.c:
	Call the C versions of the parameter setting predicates. (The versions
	for use from within the term browser specify the parameters a different
	way).

tests/debugger/browser_test.exp:
tests/debugger/exception_value.exp:
tests/debugger/polymorphic_output.exp:
tests/debugger/declarative/browse_arg.exp:
	Update the expected outputs to comply with the changes above.
2003-10-13 08:02:18 +00:00
Mark Brown
c9563335ef Allow users of the declarative debugger to revise answers that they
Estimated hours taken: 60
Branches: main

Allow users of the declarative debugger to revise answers that they
have given previously.  We do this by modifying the user interface
to allow a default answer to be shown as part of the question; the
default answer will always be some answer the user has given previously,
which they can choose to either change or accept as is.  Initially no
questions will be candidates for revision, but if the user ever rejects
a diagnosis, some or all of the questions leading directly to the bug in
question will be asked again.

Add an empty command to the user_command type, for when the user just
presses return.  If there is a default answer, the empty command is
interpreted as that answer.  If there is no default answer, the empty
command is interpreted as the skip command, which allows the user to
cycle through all the available questions by repeatedly pressing return.

browser/declarative_debugger.m:
	Define the type decl_evidence which represents the evidence
	collected against a particular suspect.

	Pass the evidence to the oracle as required.

	Ensure the analyser is updated after the user rejects a diagnosis.

browser/declarative_analyser.m:
	Collect the evidence against the prime suspect as the answers are
	processed, and include this evidence when the analyser response
	is a bug.

	Export the predicate revise_analysis/4 which updates the
	analyser state after the user has rejected a diagnosis.

	Pass the IO action map to prime_suspect_get_evidence so that
	edt_root_question can be called.

browser/declarative_oracle.m:
	When the user rejects a bug, retract from the oracle's knowledge
	base any of the evidence which implicated that bug.  Rather than
	throw this information away, we assert it in a secondary knowledge
	base which is consulted when we want to know if there should be
	a default answer provided to the user.

	Update the oracle_state to reflect the above change, and remove
	all the get_* and set_* predicates for the oracle state.  That
	functionality is provided by labelled fields, so maintaining the
	get_* and set_* predicates is no longer worth the trouble.

	Add the predicate retract_oracle_kb/3 to remove information from
	a knowledge base.

	Use the correct (equivalence) type for exceptions.

browser/declarative_user.m:
	Add the type user_question, which may be a plain decl_question or
	may be a decl_question with a default answer.  Use this type in
	query_user* instead of decl_question.

	Write the command handling switch as a separate predicate.  This
	makes it easier for one command to emulate others (e.g. the empty
	command).

	If the question has a default answer, print it as part of the
	prompt.

	Parse the empty command.

doc/user_guide.texi:
	Update the documentation to reflect the changes.

library/list.m:
	Add a cc_multi version of list__map.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/empty_command.exp:
tests/debugger/declarative/empty_command.inp:
tests/debugger/declarative/empty_command.m:
tests/debugger/declarative/revise.exp:
tests/debugger/declarative/revise.inp:
tests/debugger/declarative/revise.m:
tests/debugger/declarative/revise_2.exp:
tests/debugger/declarative/revise_2.inp:
tests/debugger/declarative/revise_2.m:
	Test cases for the new features.
2003-02-03 05:19:32 +00:00
Zoltan Somogyi
2040556da6 Make it easier to print and browse I/O actions in the declarative debugger.
Estimated hours taken: 6
Branches: main

Make it easier to print and browse I/O actions in the declarative debugger.

browser/browser_info.m:
	Add a new component to the debugger's permanent state to record the
	user's preference as to how many I/O actions can be printed with each
	atom. If an atom has this many I/O actions or fewer, they are printed.
	If it has more, only a notice about too many I/O actions to show is
	printed, and the user has to look up the actions manually.

browser/browse.m:
	Update the help message and the printing of the current settings
	accordingly.

browser/parse.m:
	Add a new piece of functionality to the "set" browser command,
	"set num_io_actions <n>", that allows the user to set the value
	of this new parameter.

browser/declarative_user.m:
	Delete the old, undocumented command "io <action_num>". Replace with
	two new command forms, "print io <from_action_num>[-<to_action_num>]"
	and "browse io <action_num>". "browse io" does what the old "io"
	command did, but using this to print many I/O actions is clumsy;
	that's what "print io" is for.

	For symmetry, also add "print <from_arg_num>[-<to_arg_num>]".

	Respect the new, user-configurable limit on the number of I/O actions
	printed with each atom.

tests/debugger/declarative/tabled_read_decl.{inp,exp}:
	Add some tests of the new functionality.
2002-11-01 07:45:04 +00:00
Mark Brown
2fe0dfa705 Change the declarative debugger so it always prints syntactically
Estimated hours taken: 1.5
Branches: main

Change the declarative debugger so it always prints syntactically
correct goals.

browser/declarative_user.m:
	Print atoms using browse__print_synthetic. This means that goals
	will always be syntactically correct, even if they are printed
	in the multi-line form.

	Make the predicates write_decl{_init,_final,}_atom take an argument
	of type browse_caller_type.  When printing a single goal use the
	caller type "print", and when printing a sequence of goals use
	"print_all".

browser/browse.m:
	When writing out a synthetic term using io__write_univ, check for
	arguments with type util__unbound.  Print such values as a single
	unquoted underscore (io__write_univ would print an underscore in
	single quotes, which means something different).

browser/util.m:
	Export functions is_predicate and is_function to convert values of
	type pred_or_func to values of type bool.

tests/debugger/print_goal.exp:
tests/debugger/queens_rep.exp:
	Update the output of these tests after the change to browse.m.

tests/debugger/declarative/app.exp:
tests/debugger/declarative/app.exp2:
tests/debugger/declarative/filter.exp:
tests/debugger/declarative/filter.exp2:
tests/debugger/declarative/input_term_dep.exp:
tests/debugger/declarative/input_term_dep.exp2:
tests/debugger/declarative/output_term_dep.exp:
tests/debugger/declarative/output_term_dep.exp2:
tests/debugger/declarative/queens.exp:
tests/debugger/declarative/tabled_read_decl.exp:
tests/debugger/declarative/tabled_read_decl.exp2:
	Update the output of these test cases.
2002-10-16 03:15:33 +00:00
Mark Brown
5cbec33da5 Add the command 'pd' to the declarative debugger.
Estimated hours taken: 1
Branches: main

Add the command 'pd' to the declarative debugger.  This command returns
to the procedural debugger at the event corresponding to the current
question; it is notionally the inverse of the 'dd' command in the
procedural debugger.

browser/declarative_user.m:
	Handle the new command, and add a new alternative to the
	user_response type.

browser/declarative_oracle.m:
	Handle the new user response, and add a new alternative to the
	oracle_response type.

browser/declarative_debugger.m:
	Handle the new oracle response, and add a new alternative to the
	diagnoser_response type.

	Export some procedures to C so that the back end can interpret the
	new diagnoser response.

	Update an old comment.

trace/mercury_trace_declarative.c:
	Handle the new diagnoser response.  Rename the function
	MR_decl_handle_bug_found, since it now also handles the case
	where a symptom has been found.

	Interpret the diagnoser response using something like a switch,
	rather than something like an if-then-else.  This gives better
	error messages if the diagnoser response type is changed.

doc/user_guide.texi:
	Document the new command.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/pd.exp:
tests/debugger/declarative/pd.inp:
tests/debugger/declarative/pd.m:
	Test the new feature.
2002-10-03 07:34:43 +00:00
Zoltan Somogyi
985b13ed3f Make I/O actions known to the declarative debugger.
Estimated hours taken: 48
Branches: main

Make I/O actions known to the declarative debugger. The debugger doesn't do
anything with them yet beyond asking about their correctness.

browser/io_action.m:
	New module for representing I/O actions, and for constructing the map
	from I/O action numbers to the actions themselves.

browser/mdb.m:
	Include the new module.

browser/declarative_analysis.m:
	Make the map from I/O action numbers to the actions themselves part
	of the analyzer state, since conversions from annotated trace nodes
	to EDT nodes may now require this information. This information is
	stored in the analyzer state because only the analyser needs this
	information (when converting annotated trace nodes to EDT tree nodes).
	It is not stored in the trace node store because its lifetime is
	different: its contents does not change during a tree deepening
	operation.

browser/declarative_execution.m:
	Store the current value of the I/O action counter with each call and
	exit node. The list of I/O actions associated with the atom of the exit
	node is given by the I/O actions whose counters lie between these two
	values (initial inclusive, final exclusive).

browser/declarative_debugger.m:
browser/declarative_oracle.m:
	Distinguish atoms associated with exit nodes from atoms associated with
	call nodes, since the former, but not the latter, now have a list of
	I/O actions associated with them.

browser/declarative_user.m:
	Add mechanisms for printing and browsing the I/O actions associated
	with EDT nodes and bugs.

runtime/mercury_trace_base.[ch]:
	Move the code for finding an I/O action here from the file
	mercury_trace_declarative.c, for use by browser/io_action.m.

runtime/mercury_layout_util.[ch]:
	Move a utility function here from mercury_trace_declarative.c,
	for use by the code moved to mercury_trace_base.c.

trace/mercury_trace_declarative.c:
	When invoking the front end, pass to it the boundaries of the required
	I/O action map. Cache these boundaries, so we can tell the front end
	when reinvocation of the back end by the front end (to materialize
	previously virtual parts of the annotated trace) does not require
	the reconstruction of the I/O action map.

trace/mercury_trace_vars.[ch]:
	Separate out the code for finding an I/O action from the code for
	browsing it, for use in mercury_trace_declarative.c.

	Note places where the implementation does not live up to the
	documentation.

trace/mercury_trace.[ch]:
	Add a parameter to MR_trace_retry that allows retries to cross I/O
	actions without asking the user if this is OK.

trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
	Pass MR_FALSE as this new parameter to MR_trace_retry.

tests/debugger/declarative/tabled_read_decl.{m,inp,exp}:
	A slightly modified copy of the tests/debugger/tabled_read_decl test
	case, to check the declarative debugger's handling of goals with I/O
	actions.

tests/debugger/declarative/Mmakefile:
	Enable the new test case.
2002-05-15 11:24:21 +00:00
Zoltan Somogyi
3f5b8a33f8 Require users to either type commands in full or to write the minimum
Estimated hours taken: 1
Branches: main

browser/declarative_user.m:
	Require users to either type commands in full or to write the minimum
	abbreviation. Typing nonsense commands that happen to start with the
	same initial letter as a command will no longer "work". This is
	necessary because later changes will add more commands.

	Make the parsing of user commands higher level and more easily
	maintainable.
2002-05-06 08:01:47 +00:00