Estimated hours taken: 120
Implement the new architecture for the front end of the
declarative debugger. Disable declarative debugging if conservative
GC is not being used since this change relies on it. The benefits
of declarative debugging in non-GC grades are not worth the extra
maintenance required to support it, since even small examples require
a large amount of memory.
browser/declarative_analyser.m:
New module which handles the analysis of EDTs, which was
previously done in browser/declarative_debugger.m.
browser/declarative_debugger.m:
- Change the interface according to the new design.
- Export types of the form decl_*, rather than edt_*.
- Move the EDT analysis to the new module.
- Handle the interaction between the analyser and the oracle.
- Don't interact directly with the user, but go via the oracle.
- New diagnoser state type.
- Update the EDT instance to conform to the other changes.
browser/declarative_oracle.m:
- Replace oracle_answer type with oracle_response.
- Allow the oracle to work with a queue of questions rather
than one at a time.
- Add new predicates to manipulate the knowledge base.
browser/declarative_user.m:
- Export the user_state type.
- Handle some user commands in this module.
- Handle questions properly (apart from printing atoms).
browser/browser_library.m:
Add the new module.
trace/mercury_trace_declarative.c:
- Initialise the front end state just once per session.
- Make the step size much larger, since implicit subtrees
are not fully supported yet.
- Correct the types in a format specifier.
trace/mercury_trace_declarative.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
- Disable declarative debugging unless conservative GC is used.
Estimated hours taken: 0.2
trace/mercury_trace_declarative.c:
Fix a compiler warning: to print out values of
type `Unsigned', cast them to `unsigned long' and
print them using `%ul' rather than `%d'.
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.
Estimated hours taken: 8
Reorganize the routines for allocating and deallocating memory:
runtime/mercury_std.h:
runtime/mercury_misc.c:
runtime/mercury_memory.h:
runtime/mercury_memory.c:
- Put the routines in the proper place.
Previously the declarations and definitions of the memory
allocation/deallocation routines were spread amoungst
all four of these files; I moved the ones in mercury_std.h
and mercury_misc.c so that they are now all defined
in mercury_memory.{h,c}
- Avoid unnecessary duplication
The following routines did exactly the same thing,
modulo bugs(!):
allocate_bytes() and newmem()
deallocate_bytes() and oldmem()
make() and allocate_object()
make_many() and allocate_array()
- Use appropriate names.
I added `MR_' prefixes, and ensured that macros that are not
function-like macros use all uppercase. I also used a more
consistent naming scheme.
Previously the names used were
(1) checked_malloc, checked_realloc
(2a) allocate_bytes, deallocate_bytes, reallocate_bytes,
allocate_object, allocate_array, resize_array
(2b) newmem, oldmem, resizemem,
make, make_many, resize_many
The new names are
(1) MR_malloc, MR_free, MR_realloc,
MR_NEW, MR_NEW_ARRAY, MR_RESIZE_ARRAY
(2) MR_GC_malloc, MR_GC_free, MR_GC_realloc,
MR_GC_NEW, MR_GC_NEW_ARRAY, MR_GC_RESIZE_ARRAY
runtime/*.[ch]:
trace/*.[ch]:
library/array.m:
library/benchmarking.m:
library/io.m:
library/std_util.m:
extras/odbc/odbc.m:
extras/aditi/aditi.m:
Use the new names.
Estimated hours taken: 6
trace/mercury_trace_declarative.c:
Deep copy some data to the global heap, as it may need to be
used after being backtracked over.
tests/debugger/declarative/Mmakefile:
Re-enable the test that was failing due to this bug.
Estimated hours taken: 1
trace/mercury_trace_declarative.c:
Bring the declarative debugging back end up to date with the
recent changes to stack layouts. Specifically, use the new
access macros instead of inspecting the data directly.
Estimated hours taken: 12
Clean up the declarative debugger.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
- Add a new type, oracle_data, to store the oracle database.
- Thread an oracle database through a single call to the
front end.
- Replace `unknown' with a less overloaded name in
some type definitions.
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
browser/declarative_debugger.m:
- Improve documentation.
browser/declarative_debugger.m:
- Export new type, edt_truth.
- Improve the interface to the oracle.
- Add a new typeclass, evaluation_tree, and update the
previous interface to reflect this.
- Make declarative_bug a polymorphic type, and change the
constructor for buggy nodes from `wrong' to `e_bug'.
Estimated hours taken: 2
Add the option `--enable-decl-debug' to configure, which enables
declarative debugging support in the internal debugger.
configure.in:
Add the option to configure.
browser/declarative_debugger.m:
runtime/mercury_wrapper.c:
Avoid using MR_address_of_edt_root_node unless configured
for declarative debugging.
runtime/mercury_conf.h.in:
runtime/mercury_conf_param.h:
Move the configuration macro to mercury_conf.h.in.
trace/mercury_trace_declarative.c:
Define MR_edt_root_node only if configured for declarative
debugging, thereby undoing a previous change.
Estimated hours taken: 3
Fix a bug causing the debugger tests to get link errors.
browser/declarative_debugger.m:
Call MR_edt_root_node indirectly via MR_address_of_edt_root_node.
runtime/mercury_wrapper.{c,h}:
Add a global function pointer, MR_address_of_edt_root_node.
util/mkinit.c:
Make sure MR_address_of_edt_root_node is initialized.
trace/mercury_trace_declarative.c:
Define MR_edt_root_node even if the declarative debugger is not
used.
Estimated hours taken: 80
Add a front end to the declarative debugger, written in Mercury. Modify
the back end to call this whenever an EDT is built. Also, various
bug fixes and improvements.
browser/declarative_debugger.m:
New module. This is a first implementation of the front end of
the declarative debugger. It uses a simple top-down algorithm
to search the EDT for a buggy node. The results are printed
in a simple format to the output stream. It is called from the
back end, in trace/mercury_trace_declarative.c.
browser/declarative_oracle.m:
New module. This is a first implementation of an oracle for the
declarative debugger. It simply passes all queries directly
on to the user.
browser/browser_library.m:
Import the new modules.
trace/mercury_trace_declarative.c:
- Various fixes/improvements of comments.
- Fix bugs where `int' is used instead of `Unsigned'.
- Pass the event_info structure to MR_trace_decl_update_path,
rather than passing various components of it.
- Use the copy of MR_trace_event_number in the event_info structure
rather than referring to the global variable directly.
- Remove the EDT printing functions, as they have been superseded by
the new front end. Call the new front end instead of these old
functions.
- Provide an interface to the EDT nodes that is imported by the
front end.
- Ensure that, after diagnosis, we end up at the same event we
started at.
- Fix a bug where it was assumed all procedures had at least one
argument.
- Ensure that the user is notified if the dd_wrong operation cannot
be started due to MR_trace_retry failing.
trace/mercury_trace_declarative.h:
- Move a #include to the correct place.
- Declare the interface to the EDT nodes.
trace/mercury_trace_internal.c:
Fix a bug introduced earlier.
runtime/mercury_conf_param.h:
Add a new configuration macro, MR_DEBUG_DD_BACK_END. When defined
this causes information about the declarative debugger back end
to be printed out during operation.
Estimated hours taken: 6
Pass around event information for the tracing system in an
MR_Event_Info struct instead of passing each item as a separate
argument. Use Unsigned consistently for the type of the call
depth and call sequence number.
trace/mercury_trace.h:
Add the new MR_Event_Info structure.
trace/mercury_trace.{c,h}:
trace/mercury_trace_declarative.{c,h}:
trace/mercury_trace_external.{c,h}:
trace/mercury_trace_internal.{c,h}:
Use the new structure.
runtime/mercury_trace_base.c:
Use Unsigned as the type of the call depth and sequence number.
Estimated hours taken: 220
Changes to the internal tracer to implement a declarative
debugging back end.
runtime/mercury_conf_param.h:
Document the new MR_USE_DECLARATIVE_DEBUGGER configuration
parameter.
trace/mercury_trace_internal.{c,h}:
Declare a global variable, MR_trace_decl_mode, that stores the
current mode of the internal debugger, and an enum listing the
possible modes.
Move MR_Event_Details and MR_trace_retry into
mercury_trace_internal.h, and make the latter extern, so that
the declarative debugger back end can use them.
trace/mercury_trace_internal.c:
Call the back end in mercury_trace_declarative.c.
Add a new command, dd_wrong, to start wrong answer analysis.
trace/Mmakefile:
Add mercury_trace_declarative.{c,h} to the dependencies.
trace/mercury_trace_declarative.{c,h}:
The declarative debugging back end (new files).