Commit Graph

52 Commits

Author SHA1 Message Date
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
Zoltan Somogyi
74ce85d476 Provide a mechanism for collecting statistics about tabling operations,
Estimated hours taken: 60
Branches: main

Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.

Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.

Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.

Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.

To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.

Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.

runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
	Move the description of structure of tables from mercury_stack_layout.h
	to mercury_tabling.h, since we now need it for statistics even if
	execution tracing is not enabled.

	Modify those data structures to have room for the statistics.

	Don't distinguish "strict", "fast_loose" and "specified" memoing
	as separate eval methods; treat them as just different kinds
	of the same eval method: "memo".

	Remove underscores from the names of some types that the style guide
	says shouldn't be there.

runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
	Modify the approach we use for macros that implement the predicates
	of library/table_builtin.m. Instead of selecting between debug and
	nondebug based on whether MR_TABLE_DEBUG is defined or not, add
	an explicit argument controlling this to each debuggable macro.
	The advantage of the new arrangement is that it scales. Another
	argument controls whether we are computing statistics (and if yes,
	where do we put it), and a third argument controls whether we maintain
	back links in the tries and hash tables (this last argument is present
	but is ignored for now).

	Since the values of the arguments will be known when the .c files
	containing calls to these macros are compiled, we pay the space and
	time cost of debugging, statistics gathering and the maintenance of
	back links if and only we need the revelant functionality.

	Provide macros for limited backward compatibility with the old set
	of macros; these allow workspaces created by old compilers to work
	with the new macros in the runtime. The old macros followed the
	naming scheme MR_table_*, the new ones are named MR_tbl_*.

runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
	New files containing parts of the old mercury_tabling.c. Each of these
	files contains the body of the functions that used to be in
	mercury_tabling.c. The new mercury_tabling.c #includes each of these
	files more than once, to provide more than one variant of the old
	function. These variants differ in aspects such as whether debugging
	is enabled or statistics is being collected. Each variant therefore
	incurs only the time costs it needs to. (We pay the space cost of
	having all these variants all the time of course, but this cost
	is negligible.)

runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
	New files that serve as wrappers around the newly #included files,
	controlling how they handle statistics.

runtime/mercury_tabling.c:
	Delete functions now in the new files, and #include them instead.
	Delete the data structures that used to contain summary statistics;
	the new approach keeps statistics in compiler-generated,
	procedure-specific data structures.

runtime/mercury_trace_base.c:
	Use the new versions of the tabling macros to access the I/O table.

runtime/mercury_type_info.h:
	Update some documentation for the movement of code out of
	mercury_tabling.c.

runtime/mercury_types.h:
	Provide forward declarations of the identifiers denoting the new types
	in mercury_tabling.h.

runtime/mercury_grade.h:
	Increment the exec trace version number, since we have changed
	a part of the exec trace structure.

runtime/mercury_bootstrap.h:
	Fix some temporary issues that arise from some renames above.

runtime/mercury_hash_lookup_or_add_body.h:
	Fix comment.

runtime/Mmakefile:
	Mention the new files and the dependencies that involve them.

library/table_builtin.m:
	Provide a type for representing statistics and a predicate for
	printing statistics.

	Use the updated versions of the macros in
	runtime/mercury_tabling_preds.h.

compiler/prog_item.m:
	Change representation of tabling pragmas to allow room for the new
	attributes.

	Allow an item to be marked as being generated by the compiler
	as a result of a pragma memo attribute. We use this for the reset
	and statistics predicates.

compiler/mercury_to_mercury.m:
	Write out the new attributes of the tabling pragma.

compiler/prog_data.m:
compiler/hlds_data.m:
	Change the cons_id that used to refer to a procedure's call table root
	to refer to the entirety of the new data structure now containing it.
	The compiler now needs a way to refer to the other components of this
	new data structure, since it contains the statistics.

	As in the runtime, don't distinguish "strict", "fast_loose" and
	"specified" memoing as separate eval methods; treat them as just
	different kinds of the same eval method: "memo".

	Rename some of the uses of the function symbols "c", "java", "il".

compiler/hlds_pred.m:
	Add an extra field in proc_infos for storing any tabling attributes.

	Change the existing proc_info field that records information about
	the kinds of arguments of tabled procedures to record the information
	needed by the debugger too. This was needed to allow us to shift all
	the RTTI for procedure-specific tables (as opposed to the RTTI for
	the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
	without duplicating the data (which would be a maintenance problem).

	Reformat some comments to make them easier to read.

compiler/layout.m:
compiler/layout_out.m:
	Delete the part of the exec trace information that used to record
	RTTI for tables, since this information is not generated only as
	part of the debugger data structures anymore.

compiler/prog_io_pragma.m:
	Recognize the updated syntax for tabling pragmas.

compiler/add_pragma.m:
	When processing tabling pragmas for inclusion in the HLDS, create
	any reset and statistics predicates they ask for.

compiler/make_hlds_passes.m:
	Export a predicate now needed by add_pragma.m.

	Handle the new attributes on tabling pragmas

compiler/globals.m:
	Change the function symbols of the types describing backends and
	foreign languages to say what they are. Previously, both types (as well
	as several others) included the function symbol "c"; now, they are
	target_c and lang_c respectively.

compiler/table_gen.m:
	Implement the changes described at the top.

	When passing around varsets and vartypes, pass the arguments in the
	standard order.

compiler/goal_util.m:
compiler/hlds_goal.m:
	When passing around varsets and vartypes, pass the arguments in the
	standard order.

compiler/rtti.m:
	Provide types for representing the runtime's data structures for
	tabling (which are now significantly more complex than a single word)
	and predicates for manipulating them, for use by both the ml and ll
	backends.

compiler/llds.m:
	Replace the comp_gen_c_var type with the tabling_info_struct type,
	which contains the information needed to create the per-procedure
	tabling data structures.

	Replace references to call tables with references to the various
	components of the new tabling data structures.

compiler/llds_out.m:
	Add code to write out tabling_info_structs.

	Delete the code required for the old, hacky way of resetting tables.

	Reorder some code more logically.

compiler/proc_gen.m:
	Generate tabling_info_structs.

compiler/stack_layout.m:
	Don't generate the information now generated in proc_gen.m.

compiler/mlds.m:
	Give mlds_proc_labels their own function symbols, instead of using
	a pair. Rename some other function symbols to avoid ambiguity and add
	expressiveness.

	Provide for the representation of references to the various components
	of the new tabling data structures, and for the representation of their
	types.

compiler/ml_code_gen.m:
	When generating code for a tabled procedure, generate also the data
	structures required for its table.

compiler/rtti_to_mlds.m:
compiler/ml_util.m:
	Move some predicates from rtti_to_mlds.m to ml_util.m, since we
	now also want to call them from ml_code_gen.m.

compiler/name_mangle.m:
	Add some utility predicates.

compiler/options.m:
	Delete the old --allow-table-reset option.

	Add the new --table-debug option.

	Comment out an implementor-only option.

compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
	Conform to the changes above, and/or improve some comments.

mdbcomp/prim_data.m:
	Make the names of the function symbols of the proc_label type more
	expressive and less ambiguous.

mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
	Use . instead of __ as module qualifier.

	Conform to the change to prim_data.m.

browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
	Conform the change to mdbcomp/prim_data.m.

tests/debugger/Mercury.options:
	Don't specify --allow-table-reset for fib.m, since that option
	doesn't exist anymore.

tests/debugger/fib.m:
	Use the new mechanism for resetting the table.

tests/debugger/print_table.m:
	Use the new syntax for pragma memo attributes.

tests/invalid/specified.{m,err_exp}:
	Use to the new syntax and reset method for pragma memo attributes.
	Test the handling of errors in the new attribute syntax.

tests/tabling/Mercury.options:
	Don't specify --allow-table-reset for specified.m, since that option
	doesn't exist anymore.

tests/tabling/specified.m:
	Use the new syntax for pragma memo attributes, and use the new
	mechanism for resetting tables. We could also use this test case
	for testing the printing of statistics, but the format of that
	output is still not final.

tests/tabling/fast_loose.m:
	Use the new syntax for pragma memo attributes, and use the new
	mechanism for resetting tables.

trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
	Conform to the changes in the RTTI data structures regarding tabling.

	Remove underscores from the names of some types that the style guide
	says shouldn't be there.

library/robdd.m:
	Comment out the tabling pragma until this change is bootstrapped.
	Without this, the conflict between the old calls to macros generated
	by the existing compiler and the new definition of those macros
	in the runtime would cause errors from the C compiler.
2006-06-08 08:20:17 +00:00
Julien Fischer
49faf8152a Fix a bunch of typos and some formatting.
Estimated hours taken: 0.5
Branches: main

browser/*.m:
	Fix a bunch of typos and some formatting.
2006-06-06 02:27:16 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
7822554732 Replace __ with . as the module qualifier everywhere in all the modules
Estimated hours taken: 2
Branches: main

browser/*.m:
	Replace __ with . as the module qualifier everywhere in all the modules
	of the browser directory. Convert the currently tab-indented modules
	to four-space indentation. Delete some unnecessary module
	qualifications. Change some type names and function symbols to avoid
	ambiguities. Replace a bunch of uses of DCGs with state variable
	notation.
2006-03-10 06:31:06 +00:00
Zoltan Somogyi
869dadb221 Minor style cleanups.
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Minor style cleanups.
2005-11-04 07:27:24 +00:00
Zoltan Somogyi
d609181cb9 Consider types of the form
Estimated hours taken: 30
Branches: main

Consider types of the form

	:- type x ---> f.

to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for dummy types.

runtime/mercury_tabling.h:
	Add a representation for "tabled" dummy types, which don't actually
	have a level in the trie, so that the runtime system can handle that
	fact.

runtime/mercury_ml_expand_body.h:
	When deconstructing a value of a dummy type, ignore the actual value
	(since it will contain garbage) and instead return the only possible
	value of the type.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
	Handle the type_ctor_rep of dummy types.

runtime/mercury_builtin_types.c:
	Provide a place to record profiling information about unifications and
	comparisons for dummy types.

runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
	Add a new type_ctor_rep for dummy types, and fix some previous
	discrepancies in type_ctor_reps.

mdbcomp/prim_data.m:
	Move a bunch of predicates for manipulating special_pred_ids here from
	the browser and compiler directories.

	Rename the function symbols of the special_pred_id type to avoid the
	need to parenthesize the old `initialise' function symbol.

	Convert to four-space indentation.

mdbcomp/rtti_access.m:
	Don't hardcode the names of special preds: use the predicates in
	prim_data.m.

	Convert to four-space indentation.

browser/declarative_execution.m:
	Delete some predicates whose functionality is now in
	mdbcomp/prim_data.m.

compiler/hlds_data.m:
	Replace the part of du type that says whether a type an enum, which
	used to be a bool, with something that also says whether the type is a
	dummy type.

	Convert to four-space indentation.

compiler/make_tags.m:
	Compute the value for the new field of du type definitions.

compiler/hlds_out.m:
	Write out the new field of du type definitions.

compiler/rtti.m:
	Modify the data structures we use to create type_ctor_infos to allow
	for dummy types.

	Convert to four-space indentation.

compiler/type_ctor_info.m:
	Modify the code that generates type_ctor_infos to handle dummy types.

compiler/type_util.m:
	Provide predicates for recognizing dummy types.

	Convert to four-space indentation.

compiler/unify_proc.m:
	Generate the unify and compare predicates of dummy types using a new
	code scheme that avoids referencing arguments that contain garbage.

	When generating code for unifying or comparing other types, ignore
	any arguments of function symbols that are dummy types.

	Don't use DCG style access predicates.

compiler/higher_order.m:
	Specialize the unification and comparison of values of dummy types.

	Break up an excessively large predicate, and factor out common code
	from the conditions of a chain of if-then-elses.

compiler/llds.m:
	For each input and output of a foreign_proc, include a field saying
	whether the value is of a dummy type.

compiler/pragma_c_gen.m:
	Fill in the new fields in foreign_proc arguments.

compiler/hlds_goal.m:
	Rename some predicates for constructing unifications to avoid
	unnecessary ad-hoc overloading. Clarify their documentation.

	Rename a predicate to make clear the restriction on its use,
	and document the restriction.

	Add a predicate for creating simple tests.

	Add a utility predicate for setting the context of a goal directly.

compiler/modules.m:
	Include dummy types interface files, even if they are private to the
	module. This is necessary because with the MLDS backend, the generated
	code inside the module and outside the module must agree whether a
	function returning a value of the type returns a real value or a void
	value, and this requires them to agree on whether the type is dummy
	or not.

	The impact on interface files is minimal, since very few types are
	dummy types, and changing a type from a dummy type to a non-dummy type
	or vice versa is an ever rarer change.

compiler/hlds_pred.m:
	Provide a representation in the compiler of the trie step for dummy
	types.

compiler/layout_out.m:
	Print the trie step for dummy types.

compiler/table_gen.m:
	Don't table values of dummy types, and record the fact that we don't
	by including a dummy trie step in the list of trie steps.

compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
	Conform to the changes above.

compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
	Conform to the changes above.

	Convert to four-space indentation.

compiler/mlds_to_java.m:
compiler/var_locn.m:
	Conform to the changes above, which requires threading the module_info
	through the module.

	Convert to four-space indentation.

compiler/mercury_compile.m:
	Pass the module_info to mlds_to_java.m.

compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
	Delete some previously missed references to the temporary types used
	to bootstrap the change to the type_info type's arity.

compiler/polymorphism.m:
	Turn back on an optimization that avoids passing parameters (such as
	type_infos) to foreign_procs if they are not actually referred to.

compiler/prog_data.m:
	Convert to four-space indentation.

library/svvarset.m:
	Add a missing predicate.

trace/mercury_trace.c:
	Delete the unused function that used to check for dummy types.

tests/debugger/field_names.{m,inp,exp}:
	Add to this test case a test of the handling of dummy types. Check that
	their values can be printed out during normal execution, and that the
	debugger doesn't consider them live nondummy variables, just as it
	doesn't consider I/O states live nondummy variables.
2005-10-05 06:34:27 +00:00
Ian MacLarty
fef2d804cc Allow subterms to be tracked through partial unifications in the
Estimated hours taken: 4
Branches: main

Allow subterms to be tracked through partial unifications in the
declarative debugger.
This involves adding new types of atomic goals to the program representation
stored with the executable of programs compiled with `--trace rep'.

Remove the ``unsafe'' from the cast goal representation to bring the program
representation up to date with Mark's recent change.

browser/declarative_execution.m:
	Read partial unification atomic goals from bytecode.

browser/declarative_tree.m:
	Handle partial unifications when tracking a subterm.

compiler/prog_rep.m:
	If a construction or deconstruction unification is a partial
	unification then generate a partial construction or deconstruction
	goal type.

	Make atomic_goal_info_to_byte_list return the list of variables bound
	by the atomic goal so we can check if a deconstruction is a
	partial unification (the LHS will be in the list of bound variables).

	Wrap the arguments of the RHS of the partial unification in a maybe
	type, so that we can tell which were input.

mdbcomp/program_representation.m:
	Add a new atomic goal `unify_partial_rep' to represent partial
	unifications.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/partial.exp:
tests/debugger/declarative/partial.inp:
tests/debugger/declarative/partial.m:
	Test tracking of subterms through partial unifications.
2005-09-13 04:04:07 +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
8ac929888b In the declarative debugger, dynamically calculate the depth implicit subtrees
Estimated hours taken: 15
Branches: main

In the declarative debugger, dynamically calculate the depth implicit subtrees
need to be built to, to achieve a desired weight.

This is done by recording the number of events at each depth in each
implicit subtree.  The array used to record these depths need only be
as big as the desired weight divided by two, since the thinnest a tree can be
is a stick with two events at each depth (a CALL and an EXIT/FAIL/EXCP).

Initially the tree is built down to a predetermined, conservative depth.  At
the root of each implicit subtree in the newly materialized tree, we record
the depth the implicit subtree needs to be built to, to achieve the desired
weight (this is refered to as the ideal depth in the code).  This is done
everytime we materialize a new implicit subtree.

This results in about a 3.6% slowdown when the declarative debugger reexecutes
a portion of the program.  However, this also reduces the number of
reexecutions of the program, since we needn't be conservative about how deep to
build subtrees to anymore.  We also avoid adding too many nodes to the
annotated trace if the tree has a large branching factor, so we are able to
control memory usage more easily.

I also added a progress indicator which is activated if a reexecution continues
for more than a second.

I added some macros to optionally print benchmarking information when
building a new portion of the annotated trace.

browser/declarative_debugger.m:
 	Pass the ideal depth of a subtree to the backend.

browser/declarative_edt.m:
	Handle the case where edt_dependency says an explicit subtree is
	required.

browser/declarative_execution.m:
	Record the ideal depth at the CALL event corresponding to the root
	of an implicit subtree.

	Add predicates to get and set this value from the backend.

browser/declarative_tree.m:
	Export a new predicate, trace_implicit_tree_info, which is used to
	get the info stored at the root of an implicit root.

	Make trace_dependency respond that an explicit subtree is required
	if it needs to explore the children of an implicit subtree.  Previously
	we made this situation impossible by requiring the backend to
	always generate the children of nodes at the depth limit.  This,
	however, complicated the backend code unnecessarily.

doc/user_guide.texi:
	Change the --depth-step-size dd option to just --depth which is now
	only used as the initial depth to build the subtree to.  Comment out
	the --depth option, since it requires knowledge of the internal
	workings of the declarative debugger.

	Document the new dd option, --nodes, which controls how many nodes
	to build in the annotated trace at a time.

library/gc.m:
	Export garbage_collect so it can be called from the backend when
	printing out benchmarking information.

tests/debugger/declarative/*.{inp*, exp*}
	For the tests set the --nodes and --depth options to a low value, so
	that we exercise the code that builds new portions of the annotated
	trace.

trace/mercury_trace_declarative.[ch]:
	Move the MR_DECL_UNTABLED_IO_RETRY_MESSAGE macro to
	mercury_trace_declarative.h.

	Add some macros and functions which print benchmarking information
	if the MR_DD_PRINT_EDT_STATS macro is defined.

	Add an overview of the backend.

	Show progress if the tree takes more than a second to generate.

	Count the events at each depth in each implicit subtree.
	Calculate the ideal depth when exiting an implicit subtree and store
	this in the annotated trace.

	Add the depth limit as an argument to MR_trace_restart_decl_debug
	instead of using the value of the global MR_edt_depth_step_size
	(which no longer exists).

	Do not materialize the children of nodes at the depth limit, since
	this is no longer necessary.

trace/mercury_trace_internal.c:
	Add and handle the --nodes dd option.  Rename the --depth-step-size
	option to --depth.
2005-05-20 05:40:37 +00:00
Ian MacLarty
78fc863efa Reduce the size of the bytecode representations of procedures (generated with
Estimated hours taken: 10
Branches: main

Reduce the size of the bytecode representations of procedures (generated with
the --trace rep option) by applying two optimizations.

The first optimization is to store strings in the existing global string table
and just keep the offsets in the bytecode representation.  This reduces the
size of the procedure representation bytecode for mercury_compile by 15.46% and
the total size of the executable by 2.34%.

The second optimization is to use a single byte to store variable numbers
where the biggest variable number in a procedure is less than or equal to 255.
An extra byte is stored at the beginning of the procedure to indicate whether
variable numbers are stored as bytes or shorts.  This optimization reduces the
size of the procedure representation bytecode for mercury_compile by 11.34% and
the total size of the executable by 1.75%.

browser/declarative_execution.m:
	Pass the label_layout for a call to any predicates than need to
	look up strings in the bytecode.  The global string table is accessable
	via the label_layout.

	Pass the representation used for variable numbers (byte or short) to
	any predicates that need to look up variable numbers in the bytecode.

compiler/c_util.m:
	Escape (') characters in the C representation of the string table.

compiler/prog_rep.m:
	Update the global string table when converting a string to bytecode.

	Determine the maximum variable number in a procedure and use a byte
	to represent the variable numbers if this is less than 256.

compiler/stack_layout.m:
	Export the predicate that adds a string to the global string table.
	Export an abstract version of the stack_layout_info type that the
	above predicate operates on.

	Pass the stack_layout_info to the predicate that constructs the
	bytecodes for a procedure, so it can update the global string
	table.

mdbcomp/program_representation.m:
	Add a predicate to convert the byte indicating whether bytes or shorts
	are used to represent variable numbers to a Mercury value.

trace/mercury_trace_internal.c:
	Pass the label layout when reading a procedure from the bytecode, so
	that strings can be looked up in the global string table.
2005-04-12 01:53:56 +00:00
Ian MacLarty
a789c0bbfc Include the reason why a question was asked in the information provided by the
Estimated hours taken: 14
Branches: main

Include the reason why a question was asked in the information provided by the
`info' command.  This includes the place where a marked subterm was bound if
the user marked a subterm in the previous question.

browser/declarative_analyser.m
	Add a new type to record the reason why a question was asked.  Keep
	this information with the last question asked in the analyser state, in
	case the user issues an `info' command.  Display the reason when the
	user issues an `info' command.

	Change the behaviour of subterm dependency tracking slightly: if the
	binding node was previously skipped then ask about it anyway.
	The user can then see in which node the subterm was bound, which may
	help them in answering the previously skipped question.

browser/declarative_edt.m
	Add two new methods to the mercury_edt typeclass.  One to get the
	proc_label of a node and the other to convert an arg_pos to a
	user argument number with respect to an atom in a node.  These
	are needed to display the question reason to the user in
	mdb.declarative_analyser.

	Add a new type to record the primitive operation that bound a subterm.

browser/declarative_execution.m
	Add a predicate to convert an arg_pos into a user arg number.

browser/declarative_oracle.m
	Fix a faulty comment.

browser/declarative_tree.m
	Implement the new methods added to the mercury_edt typeclass.

	Return the type of primitive operation that bound a subterm.

doc/user_guide.texi
	Document the fact that the reason is now also displayed when the
	`info' command is issued.

tests/debugger/declarative/dependency.exp
tests/debugger/declarative/dependency2.exp
	The type of primitive operation is now shown in the debugging output.

tests/debugger/declarative/info.exp
tests/debugger/declarative/info.inp
tests/debugger/declarative/info.m
	Test the info command more thoroughly.
2005-04-11 06:43:35 +00:00
Zoltan Somogyi
309910d736 Change the mechanism we use to transmit a representation of procedure bodies
Estimated hours taken: 16
Branches: main

Change the mechanism we use to transmit a representation of procedure bodies
from the compiler to the declarative debugger from Mercury terms to a bytecode.
This achieves two objectives.

First, the code for Mercury terms worked only as long as the compiler used
the same data representation as the program being compiled; it generated
incorrect term representations when e.g. the compiler generating code in
reserve tag grades.

Second, the new representation is significantly smaller. The total size of the
.c files in the compiler directory in grade asm_fast.gc.decldebug.tr is now
only 213 Mb compared with 313 Mb previously (a reduction of almost one third).
The executable file size of a compiler compiled in asm_fast.gc.decldebug.tr is
now only 59 Mb, compare with 64 Mb previously (a reduction of almost 8%, and
there is room for further reductions). The overhead of the decldebug grade
when compared with a plain debug grade now only about 25%, compared to
about 36% before.

The downside is that the procedure body representation must now be constructed
by the declarative debugger from the bytecode instead of being available
directly. We minimize this effect by using a cache to ensure that each
procedure's body representation is constructed at most once.

browser/declarative_execution.m:
	Do not include the procedure representation in call nodes. This should
	make the annotated trace somewhat smaller and quicker to construct.
	Since this code will be executed many more times than the number of
	procedures whose bodies are needed by subterm dependency tracking,
	the overall effect of this change on speed should be positive.

	Instead, add code to construct procedure body representations on demand
	from bytecode, which is reachable indirectly through the call's node
	label label structure.

browser/declarative_tree.m:
	Conform to the new structure of call nodes.

compiler/prog_rep.m:
	Replace the code that generated the term representation of procedure
	bodies with code that generates a bytecode representation of procedure
	bodies.

compiler/static_term.m:
	Delete this file, since it is no longer needed.

compiler/notes/compiler_design.html:
	Document the deletion of static_term.m.

mdbcomp/program_representation.m:
	Add the definitions related to the structure of the bytecode that are
	shared by the compiler and the declarative debugger. This includes
	the representations of determinisms.

compiler/code_model.m:
	To prevent requiring double maintenance, use the facilities now in
	mdbcomp/program_representation.m to encode determinisms.

runtime/mercury_stack_layout.h:
compiler/layout.m:
compiler/layout_out.m:
compiler/opt_debug.m:
compiler/stack_layout.m:
	Replace the proc layout field holding the procedure representation term
	with the field holding the procedure representation bytecode.

runtime/mercury_grade.h:
	Record the breaking of backward compatibility in debug grades.

compiler/options.m:
	Add an option for use by compiler implementors while implementing
	changes like this.

runtime/mercury_trace_base.[ch]:
	Add the hash table that caches the results of bytecode translations.

trace/mercury_trace_declarative.c:
	Do not include procedure representations when constructing call nodes,
	since it is no longer necessary.

trace/mercury_trace_internal.c:
	Update the code that deals with procedure bodies to use the bytecode
	representation.
2005-03-31 04:44: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
3ee6e024fe Record label layouts in the annotated trace.
Estimated hours taken: 7
Branches: main

Record label layouts in the annotated trace.  This does away with the need
to store goal path strings and proc_layouts in the annotated trace, since
both can be obtained from the label layout (we still however need to store the
goal path of a call in its parent for subterm dependency tracking).

The label layouts will be used for displaying more detailed information
in declarative debugging sessions (such as line numbers) and also for
for slicing and dicing in the declarative debugger.

browser/declarative_execution.m
	Add label_layout foreign types and some useful functions on this type.

	Add label_layout field to each event in an annotated trace.

	Record just the arguments of an atom for call and exit events in the
	annotated trace.  The complete atom can be constructed from the
	label_layout and the arguments.

	When recording argument values add them to the front of the
	argument list instead of inserting them in a specified position in the
	argument list.  This means the arguments must be added in reverse order
	in trace/mercury_trace_declarative.c.

	Adjust the predicates for building the annotated trace to also accept
	a label_layout.

browser/declarative_debugger.m
	Get the proc_layout from the label_layout.

browser/declarative_tree.m
	Make adjustments for the extra field.

trace/mercury_trace_declarative.c
	Pass the label_layout when constructing pieces of the annotated trace.

	Construct only the atom's arguments.  Also when adding the arguments
	add them in reverse order, because of the change in
	browser/declarative_execution mentioned above.
2005-02-22 05:17:29 +00:00
Julien Fischer
4aa7104e19 Replace deprecated mode and inst syntax.
Estimated hours taken: 0.1
Branches: main, release

browser/declarative_execution.m:
browser/declarative_tree.m:
compiler/mode_constraints.m:
compiler/prog_io.m:
compiler/rl_file.pp:
	Replace deprecated mode and inst syntax.
2005-02-07 11:41:05 +00:00
Ian MacLarty
4970242093 Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
Estimated hours taken: 4
Branches: main

Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
defined in mdb.declarative_execution and delete proc_id, since these data
structures are almost identical.

browser/declarative_execution.m
	Remove proc_id and flat_module_name types.  Use
	mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead.

browser/declarative_debugger.m
browser/declarative_oracle.m
browser/declarative_tree.m
browser/declarative_user.m
	Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name
	instead of mdb.declarative_execution.proc_id and
	mdb.declarative_execution.module_name.

mdbcomp/prim_data.m
compiler/prog_out.m
	Move sym_name_to_string from prog_out to prim_data.
	Fix comment for prog_out.sym_name_and_arity_to_string.

compiler/bytecode.m
compiler/check_typeclass.m
compiler/code_gen.m
compiler/deforest.m
compiler/higher_order.m
compiler/hlds_code_util.m
compiler/hlds_error_util.m
compiler/hlds_module.m
compiler/hlds_out.m
compiler/intermod.m
compiler/layout_out.m
compiler/make.module_target.m
compiler/make_hlds.m
compiler/mercury_compile.m
compiler/mercury_to_mercury.m
compiler/ml_elim_nested.m
compiler/mlds_to_c.m
compiler/mlds_to_gcc.m
compiler/mlds_to_il.m
compiler/mlds_to_java.m
compiler/mlds_to_managed.m
compiler/modes.m
compiler/modules.m
compiler/opt_debug.m
compiler/options_file.m
compiler/polymorphism.m
compiler/prog_io.m
compiler/prog_rep.m
compiler/rl.m
compiler/rl_exprn.m
compiler/rl_gen.m
compiler/rl_info.m
compiler/rl_out.pp
compiler/rtti.m
compiler/rtti_out.m
compiler/rtti_to_mlds.m
compiler/source_file_map.m
compiler/table_gen.m
compiler/trans_opt.m
compiler/unify_gen.m
compiler/unique_modes.m
compiler/unused_args.m
	Use mdbcomp.prim_data.sym_name_to_string instead of
	prog_out.sym_name_to_string.
2005-02-01 07:11:42 +00:00
Ian MacLarty
aa1e562a09 In the declarative debugger: use predmode syntax where appropriate; use `.'
Estimated hours taken: 1.2
Branches: main

In the declarative debugger: use predmode syntax where appropriate; use `.'
as a module qualifier instead of `__'; use state variables for IO instead of
DCGs; use `io' instead of `io.state'.

browser/declarative_debugger.m
browser/declarative_execution.m
browser/declarative_oracle.m
browser/declarative_test.m
browser/declarative_tree.m
browser/declarative_user.m
	Apply the above mentioned changes.
2005-01-28 00:56:06 +00:00
Zoltan Somogyi
67895b0b65 Fix the current mixture of __ and . to module qualify module names
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Fix the current mixture of __ and . to module qualify module names
	by standardizing on the latter.
2005-01-24 07:41:05 +00:00
Julien Fischer
f58b8a4041 The namespace cleanliness check in the browser directory
Estimated hours taken: 1
Branches: main

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

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

browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/declarative_user.m:
	Conform to the above change.
2005-01-21 14:54:47 +00:00
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
85dff41b45 Add divide and query search strategy to declarative debugger.
Estimated hours taken: 80
Branches: main

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

browser/declarative_analyser.m
	Implement divide and query search.

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

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

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

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

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

	Recalculate the weights when a node is revised.

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

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

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

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

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

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

	Put @samp{} around CALL.

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

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

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

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

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

	Use readline completion for `dd' command options.
2005-01-09 01:14:09 +00:00
Ian MacLarty
c511bd8b3e Allow the declarative debugger to search nodes above the node where the initial
Estimated hours taken: 20
Branches: main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	Remove duplicate save command documentation.

	Add a comment about new functionality.

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

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

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

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

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

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

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

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

The main changes to the declarative debugger are:

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

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

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

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

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

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

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

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

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

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

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

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

browser/mdb.m
	Added mdb.declarative_edt.

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

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

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

doc/user_guide.texi
	Updated with new features.

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

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

tests/debugger/declarative/binary_search.exp
tests/debugger/declarative/binary_search.exp2
tests/debugger/declarative/binary_search.inp
tests/debugger/declarative/binary_search.inp2
tests/debugger/declarative/binary_search.m
tests/debugger/declarative/binary_search_1.m
	Test binary search.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

trace/mercury_trace_declarative.c
	Made the depth step size used when deciding which events to put in
	the annotated trace a variable so that it can be dynamically adjusted
	in the future.
	The EDT depth is now calculated independently instead of using
	event_info->MR_call_depth (which is not always consistent with
	the EDT depth).
	When generating an annotated trace for an explicit subtree the
	first event's preceeding event now points to the correct event in the
	existing annotated trace (instead of NULL).  This allows the parent of
	the root of the new explicit subtree to be calculated.
	Made changes so that all the interface events of child calls of a call
	are included in the annotated trace, so that contours are built
	correctly.
2004-11-19 11:54:46 +00:00
Fergus Henderson
d0228c4489 Some work towards getting the "browser" directory to build in grade java.
Estimated hours taken: 24
Branches: main

Some work towards getting the "browser" directory to build in grade java.

In particular, this is a step towards fixing a problem in the Java
back-end with sub-modules.  When compiling code that uses sub-modules,
we run up against a Java restriction that a class which is in a package
is not allowed to have the same name as the package.  The work-around
is to use names starting with an uppercase letter for Java class names,
and names starting with a lower-case letter for Java package names.

XXX This diff is a partial step: it uses names starting with an
uppercase letter for Java class names that correspond to Mercury types.
It does not yet use an uppercase letter for Java classes that correspond
to Mercury modules.

XXX With this diff, we just flip the case of the initial letter,
which just works around the problem by avoiding the clashing cases,
rather than eliminating them.  We should use a more complicated mangling
that eliminates the problem completely, e.g. map lowercase Mercury names
to uppercase, map uppercase Mercury names to "U_" followed by the name.

compiler/mlds_to_java.m:
	Output type names with an initial uppercase letter.

compiler/mlds.m:
	Add a new enumeration type qual_kind, with values type_qual
	and module_qual.
	Add a qual_kind field to the fully_qualified_type type.
	Add a qual_kind argument to the append_class_qualifier function,
	and if the qual_kind is module_qual, adjust the case of the
	qualifier appropriately for the back-end.

compiler/ml*.m:
compiler/rtti_to_mlds.m:
	Fill in the new qual_kind field, and pass qual_kind to
	append_class_qualifier.

library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
library/io.m:
library/rtti_implementation.m:
	Use type names with an initial uppercase letter.

browser/Mmakefile:
	Work around problems where Java compilers don't like the file names
	generated by mmc for code using sub-modules.

	For IL and Java, build with --allow-stubs --no-warn-stubs.

browser/declarative_execution.m:
	Give a Java definition for the "proc_layout" type.
	This is needed to avoid compilation errors in grade java.
2004-08-02 08:30:17 +00:00
Julien Fischer
1e62e29b2e Replace deprecated syntax for :- inst and :- mode
Estimated hours taken: 0.2
Branches: main

browser/declarative_execution.m:
browser/declarative_tree.m:
browser/tree234_cc.m:
	Replace deprecated syntax for :- inst and :- mode
	declarations.
2004-07-21 07:25:12 +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
Peter Ross
6f1f7f0083 Add Mercury versions of code which has been defined only as
Estimated hours taken: 1
Branches: main

browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/interactive_query.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
	Add Mercury versions of code which has been defined only as
	foreign procs so as to allow this directory to compile for
	the non-C backends.
	The Mercury versions just call private_builtin__sorry.
2003-02-06 13:37:08 +00:00
Mark Brown
f302f534fd Move the code that defines an instance of mercury_edt/2 from
Estimated hours taken: 1
Branches: main

Move the code that defines an instance of mercury_edt/2 from
browser/declarative_debugger.m into a module of its own.  This section
of code is large and reasonably self-contained, so it makes sense for it
to have its own module.  Moreover, declarative_debugger.m contains the
main declarative debugging definitions and the upper levels of code for
the front end, and the mercury_edt/2 instance doesn't fit into either of
these categories.

Add an exception handler to the front end, so that if declarative debugging
fails for whatever reason, the debugging session can at least continue using
the procedural debugger.  Rather than calling error in the front end, throw
exceptions that are of a type specific to the front end (so we know which
errors are ours and which aren't).

browser/declarative_debugger.m:
	Add a new type, diagnoser_exception/0.  Handle these exceptions
	but rethrow any other kind.

browser/declarative_debugger.m:
browser/declarative_tree.m:
	Move the mercury_edt/2 instance to the new module.

browser/mdb.m:
	Add the new module to the mdb library.

browser/declarative_*.m:
	Call throw/1 instead of error/1.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/catch.exp:
tests/debugger/declarative/catch.inp:
tests/debugger/declarative/catch.m:
	A test case for debugging code that catches exceptions.  This sort
	of code is still not supported by the front end, but at least we
	now give a decent error message and allow debugging to resume.
2002-09-13 04:17:47 +00:00
Zoltan Somogyi
048f8357cf Until now, programmers could add `tabled_for_io' annotations to foreign_procs
Estimated hours taken: 12
Branches: main

Until now, programmers could add `tabled_for_io' annotations to foreign_procs
that do I/O, which asks the compiler to make those foreign_procs idempotent,
i.e. ensures that they are performed at most once even in the presence of a
retry operation in the debugger. This change adds a compiler option,
--trace-table-io-require, which generates an error if a foreign_proc that does
I/O does not have this annotation. Specifying this option thus ensures
that all I/O done by the program is idempotent.

In the future, we may want to have this option turned on in all debugging
grades. Until we decide about, the new option is not yet documented.

compiler/options.m:
	Add the new option --trace-table-io-require.

compiler/handle_options.m:
	Make --trace-table-io-require imply --trace-table-io.

compiler/table_gen.m:
	If --trace-table-io-require is enabled, require all I/O primitives
	to have the tabled_for_io annotation.

compiler/mercury_compile.m:
	Pass I/O states to table_gen.m, since it can now generate error
	messages.

trace/mercury_trace_util.h:
trace/mercury_trace_vars.c:
	When calling Mercury code from the trace directory, disable I/O
	tabling, since any I/O actions executed by Mercury code in the browser
	directory (or by library code called from there) should not be tabled,
	not being part of the user program.

	Due to the depth of nesting, make mercury_trace_vars.c use four-space
	indentation.

browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
compiler/gcc.m:
compiler/mercury_compile.m:
compiler/passes_aux.m:
compiler/process_util.m:
compiler/stack_layout.m:
library/io.m:
library/time.m:
tests/debugger/declarative/tabled_read_decl.m:
	Add a whole lot of tabled_for_io annotations, to enable the compiler to
	bootstrap with --trace-table-io-require enabled.

	In many cases, this required turning old-style pragma c_code into
	pragma foreign_proc. While doing that, I standardized the layouts
	of pragma foreign_procs.

browser/util.m:
	Turn an impure semidet predicate into a pure det predicate with I/O
	states, to allow it to be tabled. Make it return a Mercury bool
	to indicate success or failure.

library/bool.m:
	Add functions that allow C code to get their hands on the constants
	`yes' and `no', for communication with Mercury code.

library/table_builtin.m:
	Add debugging code to the main primitive of I/O tabling. This is
	controlled both by the macro for retry debugging and a boolean global.

library/mercury_trace_base.[ch]:
	Add the boolean global variable to switch the new debugging code in
	table_builtin.m on and off.

library/mercury_trace_internal.c:
	When starting I/O tabling with retry debug enabled, turn on the switch.

tests/debugger/queens.exp3:
	New expected output file that applies when the library is compiled with
	--trace-table-io-require.
2002-07-22 07:13:14 +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
Mark Brown
03a8cad379 Document the type variable naming conventions for mercury_edt.
Estimated hours taken: 0.1
Branches: main

browser/declarative_analyser.m:
	Document the type variable naming conventions for mercury_edt.

browser/declarative_execution.m:
	Document the type variable naming conventions for annotated_trace.

browser/declarative_debugger.m:
	Document the type edt_node/1.
2002-04-24 17:43:56 +00:00
Zoltan Somogyi
700e5cc1b6 Redesign the way the declarative debugger tracks dependencies, to avoid bugs
Estimated hours taken: 60
Branches: main

Redesign the way the declarative debugger tracks dependencies, to avoid bugs
and make the code comprehensible. This required tackling an issue we could
ignore before: the typeinfos added to procedure arguments by the compiler.

browsers/declarative_debugger.m:
	Rewrite the dependency algorithm from scratch. It now has three phases:
	materializing the contour leading up to the relevent point in the
	procedure body, using that contour to construct a list of the conjoined
	primitive operations executed up to that point by the procedure body,
	and tracking the source of the marked subterm in this list of
	primitives.

	Add a mechanism to print out the result of the dependency tracking
	algorithm if a flag is set, for testing and debugging.

browsers/declarative_analyser.m:
	Transmit the result of the dependency tracking algorithm to where
	it may be printed out.

browsers/declarative_user.m:
	Update the user interface to make it switchable between viewing atoms
	from the user's perspective (with compiler-generated arguments hidden)
	and the implementor's perspective (with compiler-generated arguments
	visible). The default view is the user view.

browsers/declarative_execution.m:
	Add the immediate parent's goal path to the representation of call
	events; this allows us to place the call in the body of its parent.

	Expand the representation of atom arguments to include their HLDS
	variable numbers, and a boolean that says whether the argument
	is a programmer-visible headvar.

	Use this extra information to add support for indexing lists of
	arguments from either the user view or the implementor view.

	Add field names to several types.

browsers/program_representation.m:
	Add a field to plain calls, giving the name of the module defining
	the called procedure. This is necessary to reliably distinguish
	the builtin unify and compare procedures, calls to which must be
	handled specially because they generate no events. (They don't need to,
	since they are correct by construction.)

	Add mechanisms for converting goal paths from strings to structured
	terms, for use by the dependency tracking code.

	Add tests on atomic goals, for use by the dependency tracking code.

	Add a mechanism to let C code retrieve the types of proc_reps as well
	as goal_reps.

compiler/prog_rep.m:
	Fill in the module name field in plain calls.

trace/mercury_trace_vars.[ch]:
	Add functions to get information about a variable specified by HLDS
	number.

trace/mercury_trace_declarative.c:
	Include typeinfos in the atoms constructed at interface events.
	(The same code will work for typeclassinfos as well, once they
	become deconstructable and hence printable.)

	Fill in the extra slot in call events, and the extra slots in
	representations of atom arguments.

trace/mercury_trace_internal.c:
	Fix a bug in the implementation of the proc_body command: the
	type of the proc_rep slot is proc_rep, not goal_rep.

tests/debugger/declarative/dependency.{m,inp,exp}:
	A new test case to exercise dependency tracking. It cooperates with
	instrumentation code in the browser directory to print out the result
	of each trace_dependency operation.

	The test case also tests the proc_body command.

tests/debugger/declarative/Mmakefile:
	Enable the new test case.
2002-04-23 08:52:46 +00:00
Zoltan Somogyi
d6fbaa2161 Add two pieces of information that will be needed to an upcoming change
Estimated hours taken: 2
Branches: main

Add two pieces of information that will be needed to an upcoming change
to the representation of procedure bodies in the declarative debugger.
The first piece is the full list of head vars. This is needed now because the
debugger no longer ignores variables of type type_info, and thus the Nth
headvar is no longer guaranteed to be variable number N. The second piece
is a cut/no_cut indicator in `some' goals. This is needed to allow us to
reconstruct goal paths exactly as we traverse goal representations.

browser/program_representation.m:
	Make the two data structure changes described above.

browser/*.m:
	Trivial changes to conform to the new data structures.

compiler/prog_rep.m:
	Create the updated data procedure representation.

compiler/*.m:
	Record and transmit the information needed by the updated procedure
	representation.

runtime/mercury_stack_layout.h:
	Update the documentation of the relevant field in proc_layouts.
2002-04-04 06:00:12 +00:00
Mark Brown
0b062bc60f This is the first part of a change to support term dependency analysis
Estimated hours taken: 80

This is the first part of a change to support term dependency analysis
in the declarative debugger.  A method is added to the mercury_edt
typeclass which finds the origin of a selected subterm in an EDT node,
somewhere in the body of the call or in the body of the parent.  The
other parts of the change required before this can be useful are to
modify the search strategy (in browser/declarative_analyser.m) to make
use of the new information, and to modify the user interface to allow
a subterm to be selected.  They will be committed as separate changes.

The typeclass method first traverses one or more contours, matching the
contour events up with goals in a procedure representation.  This matching
process requires a left to right traversal, because we need to know which
disjunct/arm/branch was taken before we can match subgoals, and the
DISJ/SWTCH/THEN/ELSE events which tell us this information occur at the
left edge of the subgoals to which they apply.  But we must always start
from the right hand side of the contour being traversed, so this means
that a right to left traversal is required before the matching can start.

Using the contour matched up with the atomic goals, we track the location
of a subterm by looking at which variables are bound, while scanning right
to left along the contour.  Because this must happen after the matching,
this must be a separate right to left traversal than the earlier one.
Therefore the algorithm implemented here requires two passes over the
contours in order to find the origin of the selected subterm.

browser/declarative_execution.m:
	Add a maybe(goal_rep) to call nodes in the annotated trace.  This
	is `no' if the relevant module was compiled below trace level `rep'.

trace/mercury_trace_declarative.c:
	If the information is available, fill in the goal_rep when
	constructing call nodes.

browser/declarative_analyser.m:
	Add the new method to the mercury_edt typeclass.

browser/declarative_debugger.m:
	Implement the new method.  Update for the changed call nodes.

browser/program_representation.m:
	Add a version of goal_paths to be used by the declarative debugger,
	and a predicate to parse these from goal_path_strings.  Add the
	types arg_pos and term_path to represent a subterm of a call or exit.

browser/program_representation.m:
compiler/prog_rep.m:
	No longer store conjunctions in reverse order in the goal_rep; we now
	store them in the same order as in the HLDS.

	Although we search conjunctions in reverse order, we need to match
	them up with contour events before doing that.  This can only be
	done in the forwards direction, so it turns out that there is no
	advantage in storing them in reverse order.

compiler/hlds_goal.m:
compiler/trace.m:
	Add comments to the existing definitions of goal_path and
	path_step_to_string.
2001-01-16 15:44:25 +00:00
Zoltan Somogyi
1c8cb6faf2 Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.
Estimated hours taken: 2

Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.

compiler/c_util.m:
compiler/rtti_out.m:
	Add MR_ prefixes to various type names in generated code.

compiler/*.m:
browser/*.m:
library/*.m:
	Add MR_prefixes to various type and function names in pragma C code.

runtime/*.[ch]:
trace/*.[ch]:
	Add MR_prefixes to various type and function names in
	hand-written code.
2000-10-16 01:34:14 +00:00
Mark Brown
954aad1dce Distinguish between predicates and functions in the declarative debugger.
Estimated hours taken: 2.5

Distinguish between predicates and functions in the declarative debugger.

browser/declarative_execution.m:
	Add a pred_or_func field to trace_atom.

trace/mercury_trace_declarative.c:
	Construct trace atoms with the extra field.

browser/declarative_user.m:
	Print function call results using function syntax.

browser/debugger_interface.m:
browser/util.m:
	Move the definition of type pred_or_func to util.m, so it can
	be used by the declarative debugger as well as the external debugger.

runtime/mercury_stack_layout.h:
	Update a reference to the location of type pred_or_func.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/func_call.{m,inp,exp}:
	Test case for the new feature.

tests/debugger/declarative/*.exp:
tests/debugger/declarative/*.exp2:
	Update expected output from tests.
2000-10-01 03:13:43 +00:00
Mark Brown
c5de0d5b0c Implement declarative debugging of code that throws exceptions.
Estimated hours taken: 8

Implement declarative debugging of code that throws exceptions.

This aborts if used on code that handles exceptions.  There is no point
dealing with this yet, since the oracle won't handle the higher order
argument to try/2.

browser/declarative_debugger.m:
	Add "unexpected exception" questions and "unhandled exception" bugs,
	and generate these from EXCP events.  Handle the exception case
	in various switches.

	Add a predicate unexpected_exception_children/4, analogous to
	{wrong,missing}_answer_children/4.

browser/declarative_execution.m:
	Add excp/5 nodes to the event trace, and export a C function to
	construct them.  Handle these nodes in various switches.

	Allow contours to extend beyond NEGE events, if the status is
	`undecided'.  Such events have no matching NEGS or NEGF event,
	so they do not mark the boundary of a separate context.

browser/declarative_oracle.m:
	Store information about which exceptions should/shouldn't be thrown
	from various calls, and use this information to answer questions
	where possible.

browser/declarative_user.m:
	Handle the new questions and bugs.

trace/mercury_trace_declarative.c:
	Add a function to deal with EXCP events.

trace/mercury_trace_internal.c:
	Allow declarative debugging to be started from EXCP events.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/throw.m:
tests/debugger/declarative/throw.inp:
tests/debugger/declarative/throw.exp:
tests/debugger/declarative/throw.exp2:
	A test case for this feature.

tests/debugger/declarative/queens.exp:
	Update the output from this test.
2000-08-10 05:51:29 +00:00
Mark Brown
efb9e1e546 Fix a bug in the handling of implicit subtrees: the debugger was not
Estimated hours taken: 8

Fix a bug in the handling of implicit subtrees: the debugger was not
always skipping gaps in the contours properly.  The fix is to find an
earlier contour when a dead end is reached (at FAIL, REDO and NEGF events).

The bug was in step_left_in_contour/2, but the same bug appeared in
wrong_answer_children/4 which was doing essentially the same work.
To avoid problems like this in future, the latter has been rewritten
in terms of the former.  Similarly, missing_answer_children/4 has been
rewritten in terms of a new function step_in_stratum/2.

browser/declarative_debugger.m:
	Rewrite {wrong,missing}_answer_children in terms of the
	step functions.

browser/declarative_execution.m:
	Export the step functions for use in the mercury_edt instance;
	this means that they must be polymorphic (the previous monomorphic
	versions are now called *_store).  step_left_in_contour/2
	is the same as before except that it also handles REDO nodes,
	and the clauses are grouped together logically (for readibility).
	step_in_stratum/2 is a new function.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/untraced_subgoal.m:
tests/debugger/declarative/untraced_subgoal_sub.m:
tests/debugger/declarative/untraced_subgoal.inp:
tests/debugger/declarative/untraced_subgoal.exp:
	A test case for this change.  This test is only effective if
	there are no events from the sub-module, so it is disabled in
	debug grades.
2000-07-14 07:02:11 +00:00
Mark Brown
a5eb54cc51 Make the code consistent with the terminology in the DD paper.
Estimated hours taken: 0.2

Make the code consistent with the terminology in the DD paper.

browser/declarative_execution.m:
trace/mercury_trace_declarative.c:
	s/step_left_in_context/step_left_in_contour/g
2000-06-14 15:40:07 +00:00
Mark Brown
1c587d56af Implement the expanding of implicit subtrees in the declarative debugger.
Estimated hours taken: 40

Implement the expanding of implicit subtrees in the declarative debugger.
When the maximum depth is reached by the front end, it now returns to
the back end a request for the missing subtree.  If the back end receives
such a request, it restarts declarative debugging with a different
topmost call and a deeper depth bound.

The EDT instance needs to know when to request expansion, so CALL nodes
need a flag to indicate whether they were at the maximum depth.  The
front end needs to be able to point out the bug and/or subtree to the
back end, so CALL, EXIT and FAIL nodes need to record the event number.

browser/declarative_execution.m:
	- Store the event number in CALL, EXIT and FAIL nodes.
	- Store a bool in CALL nodes which indicates whether the event
	  was at the maximum depth or not.

browser/declarative_debugger.m:
	- Store the event number of the buggy event in the reported bug,
	  and pass this event number to the back end so it can go back
	  to that event.
	- Add a case for expanding an implicit tree to the
	  diagnoser_response type, and handle this response properly.
	- Export procedures to C that allow acces to the diagnoser_response
	  type.
	- Accommodate the changes to the trace_node type.

browser/declarative_analyser.m:
	- Store the list of previous prime suspects in the analyser state.
	  That way they don't have to be specially dealt with when
	  restarting analysis with an expanded subtree.
	- When starting analysis, assume the top node is wrong; this
	  is not an unreasonable assumption, and the strategy works better
	  for the case when a subtree is expanded.

browser/declarative_user.m:
	- Accommodate changes to the reported bug.

trace/mercury_trace_declarative.c:
	- Change the depth step size to a reasonable number, now that
	  it works.  This also has the effect of testing the change,
	  since some test cases go deeper than the new limit.
	- Filter events outside the topmost call.  Rather than keep
	  track of the minimum depth, we record the topmost call sequence
	  number and use a global to keep track of whether we have entered
	  or left this procedure.
	- Factor out code in the existing mechanism for starting
	  declarative debugging, so that it can be used to re-start
	  debugging as well.
	- Accommodate the changes to the trace_node type.
	- Output error messages if declarative debugging fails to start
	  properly.
	- Handle the reponse from the diagnoser, by jumping to the buggy
	  event (if a bug is found) or re-executing to expand a subtree
	  (if one is requested).
	- Add a new checkpoint for events which are filtered out of
	  the annotated trace.

trace/mercury_trace_internal.c:
	- Don't report error messages when declarative debugging fails
	  to start.  Errors are now reported by the declarative debugger
	  before returning.

tests/debugger/declarative/*.inp:
tests/debugger/declarative/*.exp:
tests/debugger/declarative/*.exp2:
	- Update to reflect the removed questions.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/filter.m:
tests/debugger/declarative/filter.inp:
tests/debugger/declarative/filter.exp:
	- New test case to cover the code which filters events which
	  are outside the topmost call.
2000-05-08 18:17:45 +00:00
Fergus Henderson
733f94a539 Change library/store.m to make use of existential types.
Estimated hours taken: 2

Change library/store.m to make use of existential types.

library/store.m:
	Add a new existentially predicate store__new/1, which is like the old
	store__init/1 but existentially typed.  This ensures safety,
	by preventing you from using a key from one store as an index
	into a different store.

	The unsafe store__init predicate is now declared `pragma obsolete'.
	The store__some_store_type type is now also documented as obsolete
	(unfortunately there is currently no equivalent to a `pragma obsolete'
	declaration for types).

browser/declarative_execution.m:
extras/trailed_update/samples/interpreter.m:
	Use store__new rather than the obsolete store__init.

tests/general/intermod_type2.m:
	Avoid using the obsolete type store__some_store_type.

extras/curses/user.m:
	Add a new predicate init_curse_store, and use that
	instead of the obsolete store__init.
	Also rename set_curse and get_curse as set_curse_store
	and get_curse_store respectively.

NEWS:
	Mention this change.
2000-04-13 10:05:42 +00:00
Mark Brown
134e188154 Represent bugs directly rather than with edt nodes.
Estimated hours taken: 10

Represent bugs directly rather than with edt nodes.  This makes the
interface to the analyser more consistent: bugs are now handled
in much the same way as questions.

browser/declarative_analyser.m:
	- In the mercury_edt/2 typeclass, change edt_root/3 to
	  edt_root_question/3 and add the method edt_root_e_bug/3.
	- Add the type prime_suspect/1 which keeps track of the
	  evidence (oracle answers) which implicates a particular
	  edt node.
	- Use the new bug representation.

browser/declarative_debugger.m:
browser/declarative_oracle.m:
	- Move oracle_confirmation to declarative_debugger.m, and
	  rename it decl_confirmation.

browser/declarative_debugger.m:
	- Change decl_bug/1 to decl_bug/0.  Instead of a bug being
	  represented by an edt node, decl_bug now represents
	  directly the different sorts of bugs possible.
	- Add an implementation for the new mercury_edt method.

browser/declarative_oracle.m:
browser/declarative_user.m:
	- Update the confirmation to use the new types.

tests/debugger/declarative/*.{exp,exp2}:
	- Update test results.
2000-03-01 04:17:27 +00:00
Mark Brown
cf8234fd6c Rename execution_tree to annotated_trace.
Estimated hours taken: 0.2

browser/declarative_debugger.m:
browser/declarative_execution.m:
	Rename execution_tree to annotated_trace.
2000-02-23 02:17:54 +00:00
Mark Brown
f49968a3ff Fix the user interface of the declarative debugger so that it
Estimated hours taken: 15

Fix the user interface of the declarative debugger so that it
produces more readable output; the representation of atoms
is updated so that it can handle non-ground arguments.

Ensure that all DD output goes through the correct stream, so that
the debugger works properly under emacs.

browser/declarative_debugger.m:
	Call a procedure in the oracle to handle bug confirmation
	(including printing out the bug), rather than handle
	it directly.

browser/declarative_execution.m:
	Update the trace_atom type so that it can handle both ground
	and free arguments.  Export to C some procedures for
	constructing trace atoms.

browser/declarative_oracle.m:
	Export a procedure which handles bug confirmation.  This calls
	the declarative_user module to do the interaction, and interprets
	the result.

browser/declarative_user.m:
	Export a procedure to handle bug confirmation by the user.
	Update to handle the changes to trace_atom.

trace/mercury_trace_declarative.c:
	Construct trace_atoms by calling the new Mercury procedures
	exported from browser/declarative_execution.m.

trace/mercury_trace_declarative.h:
	Remove the macro that had been used to construct old style atoms.

trace/mercury_trace_vars.{c,h}:
	Export a procedure to calculate the argument position of a
	head variable.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/args.{m,inp,exp,exp2}:
	New test case to test mixing bound and free arguments.

tests/debugger/declarative/*.inp:
tests/debugger/declarative/*.exp:
tests/debugger/declarative/*.exp2:
	Update test cases to reflect new output, and the extra question
	asked for bug confirmation.
2000-02-22 10:46:55 +00:00
Mark Brown
71a343d1bb Fix the problem of test cases failing in tests/debugger/declarative
Estimated hours taken: 1.2 (including 0.2 by fjh)

Fix the problem of test cases failing in tests/debugger/declarative
on the alphas.

browser/declarative_execution.m:
	Add Mercury procedures to do destructive update on trace nodes.

trace/mercury_trace_declarative.h:
	Remove C macros that did the destructive update.

trace/mercury_trace_declarative.c:
	Use the Mercury procedures rather than the old macros.
2000-02-17 12:04:37 +00:00
Mark Brown
0166fe7510 Bring the implementation up to date with the algorithm that is
Estimated hours taken: 25 (plus ? by zs)

Bring the implementation up to date with the algorithm that is
described in the paper (papers/decl_debug).  Add some debugging
infrastructure to the back end, which was used to debug this
change.

browser/declarative_execution.m:
	- Store the call sequence number in call nodes.
	- Store the previous redo (if there is one) in fail nodes.
	- Use a functor specifically for switches.
	- Use a pointer to the first disj event, instead of a pointer
	  to the event before it.
	- Export two new predicates for dereferencing disj node ids.
	- Export (to C) a procedure for accessing the call sequence number,
	  and a procedure for getting to the first disj event.
	- Split the scan_backwards function into two: step_left_in_context
	  and find_prev_contour.

browser/declarative_debugger.m:
trace/mercury_trace_declarative.c:
	- Use the updated data structure.

runtime/mercury_conf_param.h:
	- Add the configuration parameter MR_USE_DECL_STACK_SLOT, which
	  makes the declarative debugger use stack slots reserved by
	  the compiler to cache the location of the call node.

trace/mercury_trace_declarative.h:
trace/mercury_trace_declarative.c:
	- Use stack slot only if MR_USE_DECL_STACK_SLOT is defined.
	- If not using stack slot, use the new algorithm to search
	  for a matching call or exit event.
	- Avoid using a global by passing the previous node to
	  MR_trace_decl_* and returning the new node.
	- Rename MR_trace_call_node_answer to
	  MR_trace_call_node_last_interface.
	- Update comments.

browser/declarative_execution.m:
trace/mercury_trace_declarative.c:
	- Added debugging output for various events of interest
	  in the back end.  It is activated when MR_DEBUG_DD_BACK_END
	  is set.

tests/debugger/declarative/aadebug.m:
tests/debugger/declarative/aadebug.inp:
tests/debugger/declarative/aadebug.exp:
tests/debugger/declarative/aadebug.exp2:
	- Update this test to match the example in the paper.

tests/debugger/declarative/propositional.inp:
tests/debugger/declarative/propositional.exp:
tests/debugger/declarative/propositional.exp2:
	- Update this test case so it gives a similar result in
	  debugging grades to non-debugging grades.

tests/debugger/declarative/app.exp2:
tests/debugger/declarative/if_then_else.exp2:
	- Update test case results.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/backtrack.m:
tests/debugger/declarative/backtrack.inp:
tests/debugger/declarative/backtrack.exp:
	- New test case.
2000-02-17 06:48:18 +00:00