Commit Graph

15 Commits

Author SHA1 Message Date
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
Simon Taylor
9ba3b14098 Make all the modules in the browser library sub-modules of
Estimated hours taken: 1

Make all the modules in the browser library sub-modules of
module `mdb', to avoid link errors when users use module names
such as `parse'.

browser/Mmakefile:
browser/browser_library.m:
browser/mdb.m:
	Rename browser_library.m to mdb.m.
	Change `:- import_module' declarations to
	`:- include_module' declarations.

browser/Mmakefile:
	Remove the special case rule for `mer_browser.init' --
	it doesn't work when the file names are not the same
	as the module name. Instead, the default rule for `mdb.init'
	is used and the output is copied to `mer_browser.init'.

browser/.cvsignore:
	Rename header files, etc.

browser/*.m:
	Add a `mdb__' prefix to the names of modules in the browser library
	in `:- module' and `:- import_module' declarations.

trace/*.c:
	Rename the header files for the browser library in
	`#include' statements.

tests/hard_coded/Mmakefile:
tests/hard_coded/parse.m:
tests/hard_coded/parse.exp:
	Test case.
2000-02-04 03:45:53 +00:00
Mark Brown
9179be5e15 Implement a new data structure for declarative debugging.
Estimated hours taken: 160

Implement a new data structure for declarative debugging.  The
major differences between this and the old implementation are:
	- The data structure is implemented in Mercury.  The definition
	  of the type, and procedures for constructing values of that
	  type, have been moved from trace/mercury_trace_declarative.{c,h}
	  to browser/declarative_execution.m (which is a new module).
	- The front end no longer needs to call the back end via an
	  indirect pointer---the front end does not call the back end at
	  all.
	- The data structure is not specifically for wrong answer
	  analysis, it is intended to be used for any sort of analysis.
	- The data structure represents execution at a lower level---the
	  new front end defines a more abstract view in terms of this
	  data structure.

Implement a test harness for debugging the front end code.  This allows
the front end to run as a stand-alone program, which can then be
debugged using `mdb'.

The code in the front end does not currently handle the new structure
very nicely.  This is because that code is about to undergo some major
structural changes, so there is little point cleaning it up now.
Consequently:
	- Some of the code in the front end is incorrect (eg. the
	  user interface does not print missing answer nodes
	  properly).
	- The tests have not been reinstated.
These things will be fixed in subsequent changes.

Likewise the compiler still reserves two stack slots, even though
only one is required.  After this change the algorithm should be able
to get away with using no stack slots, so modifications to the compiler
will be postponed until then.

browser/declarative_execution.m:
	New module.  Implement the execution_tree typeclass, which
	represents the execution of a Mercury program.  Implement
	two instances of this typeclass, one for normal use and one for
	testing purposes.

browser/declarative_test.m:
	New module.  A test harness that can be compiled as a
	stand-alone program, enabling the front end to be debugged.

trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
	- Remove the definition of the old data structure.
	- Add some macros which enable the new Mercury data structure
	  to be destructively updated by C code.
	- Change the interface to this module so that it reflects more
	  general diagnosis, not just wrong answer analysis.
	- Implement the new algorithm.
	- Call an alternative front end if in test mode.
	- Update comments.

trace/mercury_trace_internal.h:
	Add a new mode for debugging the declarative debugger.

trace/mercury_trace_internal.c:
	Change the command from `dd_wrong' to `dd', since it is not
	specifically for wrong answer analysis.  Add a new command
	`dd_dd' which calls the alternative front end used for testing.

runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
	Remove any reference to `MR_edt_root_node', since it is no
	longer used.

browser/declarative_debugger.m:
	- Add a case for missing answer nodes to `edt_node'.
	- Change the `evaluation_tree' typeclass into `mercury_edt'
	  typeclass.  This is to make it more distinct from the new
	  `execution_tree' typeclass, which is a lower level concept.
	- New interface to the diagnoser: types `diagnoser_response'
	  and `diagnoser_state', and procedure `diagnosis'.
	- Define an instance of `mercury_edt' from an instance of
	  `execution_tree'.
	- Updates to the analyser to get it to compile---further changes
	  will be forthcoming.

browser/declarative_user.m:
	- Updates to the user interface to get it to compile---further
	  changes will be forthcoming.

browser/browser_library.m:
	Import the new module (declarative_execution.m).

browser/debugger_interface.m:
browser/util.m:
	Move the definitions of trace_port_type and goal_path_string
	to browser/util.m, since they are now used by more than just
	the external debugger.

browser/Mmakefile:
	Add the test harness as a `depend' target.

browser/browse_test.m:
	Use the correct interface to the browser.
1999-11-30 00:05:08 +00:00