mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-21 00:39:37 +00:00
ba2c9002e48e28516affe83093d38e46934a67ed
32 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ba2c9002e4 |
Add `mode' command to interactive term browser to display the mode of a
Estimated hours taken: 5 Branches: main Add `mode' command to interactive term browser to display the mode of a sub-term. At the moment this command only works when the term browser is invoked from inside the declarative debugger. browser/browser_info.m Allow a function to be passed to the browser which it can call to work out the mode of a sub-term. browser/browse.m Export versions of the browser invocation predicates that don't accept a mode function. Handle the `mode' browser command by calling the supplied function if it's present. Document the `mode' command in the browser help message. browser/declarative_debugger.m To determine the mode of a sub-term we compare the state of instantiation of the sub-term at the CALL event and at the EXIT, FAIL or EXCP event. To do this we need the initial and final atoms for incorrect contour bugs and wrong answer nodes (for other nodes the initial and final atoms are the same). browser/declarative_oracle.m Conform to the fact that wrong answers now also have the initial atom. browser/declarative_tree.m Export trace_atom_subterm_is_ground/3 for use in declarative_user.m. Include the initial atom in wrong answer nodes and incorrect contour bugs. browser/declarative_user.m Add function arg_num_to_arg_pos to replace some duplicated code. Alter the edt_node_trace_atom predicate to find the initial and the final atoms for a question. Add a function to find the mode of a sub-term given the path to the sub-term and the initial and final atoms. Pass this function to the browser so it can work out the mode of a sub-term. browser/parse.m Parse `mode' command. tests/debugger/declarative/Mmakefile tests/debugger/declarative/browser_mode.exp tests/debugger/declarative/browser_mode.inp tests/debugger/declarative/browser_mode.m Test the `mode' command. |
||
|
|
dce0b465e1 |
Allow `trust' as declarative debugger question response.
Estimated hours taken: 1.5 Branches: main Allow `trust' as declarative debugger question response. The user may respond with simply `trust' in which case the current predicate or function will be trusted, or `trust module' in which case the module the current question relates to will be trusted. browser/declarative_oracle.m If the user response is trust_predicate or trust_module then add the predicate/function or module to the list of trusted objects and return an `ignore' response to the analyser. browser/declarative_user.m Handle `trust' command and add it to the help messgae. doc/user_guide.texi Document `trust' and `trust module' declarative debugger commands. tests/debugger/declarative/trust.exp tests/debugger/declarative/trust.inp Test the `trust' and `trust module' commands. |
||
|
|
51419029ee |
Do not store all modes for inadmissible or erroneous atoms in the knowledge
Estimated hours taken: 0.2 Branches: main Do not store all modes for inadmissible or erroneous atoms in the knowledge base, since an atom may be erroneous with respect to one mode, but inadmissible with respect to another. browser/declarative_oracle.m Only store all modes in the knowledge base when the atom is correct. |
||
|
|
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. |
||
|
|
e7d6509c95 |
Trust modules in the Mercury standard library by default in the declarative
Estimated hours taken: 6 Branches: main Trust modules in the Mercury standard library by default in the declarative debugger. Make trusted object id's returned by `trusted' command persistent. Previously each trusted object was identified by its position in the ordered list of trusted objects. This meant that if an object was removed all objects after the removed object in the ordered list of trusted objects would have their ids decremented, so if the user wanted to then delete another object they'd have to issue another `trusted' command to get the new id first. The behaviour is now consistent with the behaviour of breakpoint ids which keep their id for the life of the breakpoint. Put the mdb declarative debugger commands in their own section, instead of in misc to be consistent with the mdb online help categories and so the online help for the mdb declarative debugger commands is generated properly (the dd help category wasn't getting any online documentation generated for it). browser/declarative_debugger.m Add and export predicate to add the standard library to the set of trusted objects. browser/declarative_oracle.m Add predicate to add the standard library to the set of trusted objects. Use a bimap to represent the set of trusted objects along with each object's id (we need to look up objects both ways). Adjust comment formatting to conform to standard. Rename trusted_module_or_predicate type to trusted_object. Add constructor for standard_library to trusted_object type. Include standard library when initialising the set of trusted objects. Change predicates adding or removing trusted objects to use new persistent object id. If a module belongs to the standard library and the standard library is trusted then trust the module. compiler/modules.m library/library.m Move definition of mercury_std_library_module/1 from modules.m to library.m so it can be used by the debugger. Adjust comment accordingly. compiler/mlds.m Import library module since since mercury_std_library_module/1 now resides there. doc/generate_mdb_doc Generate declarative debugger commands documentation. doc/user_guide.texi Document `trust std lib' command. tests/debugger/declarative/catch.exp2 tests/debugger/declarative/catch.exp3 tests/debugger/declarative/catch.inp2 tests/debugger/declarative/solutions.exp2 tests/debugger/declarative/solutions.inp2 Untrust the standard library for these tests. tests/debugger/declarative/trust.inp tests/debugger/declarative/trust.exp Update test to reflect persistent trusted object ids and trusting of standard library. trace/mercury_trace_declarative.c trace/mercury_trace_declarative.h Add function to trust the standard library. trace/mercury_trace_internal.c Allow user to trust the standard library by issuing a `trust std lib' command. |
||
|
|
7015c4a436 |
Made the declarative debugger respect the format settings of the procedural
Estimated hours taken: 3 Branches: main Made the declarative debugger respect the format settings of the procedural debugger. The print format set in the procedural debugger will now be used when the declarative debugger asks questions and the browse format will now be used when browsing terms in the declarative debugger. If the user changes the browser format during a declarative debugging session the procedural debugger will respect these changes. This also means the declarative debugger will respect the settings in the .mdbrc file. browser/declarative_debugger.m Added term browser state arguments to main diagnosis predicate and initialisation predicate. browser/declarative_oracle.m Added predicates to get and set the term browser state. Set the term browser state in the initialisation prediciate for the oracle state. browser/declarative_user.m Added predicates to get and set the term browser state. Set the term browser state in the initialisation prediciate for the user state. tests/debugger/declarative/dependency.exp This test sets the print format in the procedural debugger, so the declarative debugger now uses this format. trace/mercury_trace_browse.c trace/mercury_trace_browse.h Exported the global variable which stores the state of the procedural debugger term browser and the function which initialises this state, so they can be used from mercury_trace_declarative.c. trace/mercury_trace_declarative.c Pass the procedural debugger term browser state to the declarative debugger and update the state when the declarative debugger is finished. |
||
|
|
0a99d27d66 |
Module qualify some calls to prevent ambiguous
Estimated hours taken: 0.1 Branches: main browser/declarative_oracle.m: Module qualify some calls to prevent ambiguous overloadings that were causing compilation errors when compiling the debugger with intermodule-optimization enabled. |
||
|
|
e6d82c9bd4 |
Added trusted' and untrust' commands. Also allowed individual predicates to
Estimated hours taken: 10 Branches: main Added `trusted' and `untrust' commands. Also allowed individual predicates to be trusted. browser/declarative_debugger.m Exported predicates to add a trusted predicate or function, remove a trusted object and return a list of the trusted objects. browser/declarative_oracle.m Changed trusted set so it can also contains individual predicates and functions. Added predicates to add a trusted predicate or function to the set, remove a trusted object from the set and return a list of the trusted objects. doc/mdb_categories Added dd category. doc/user_guide.texi Documented `untrust' and `trusted' commands. runtime/mercury_stack_trace.c runtime/mercury_stack_trace.h Added a print_mode argument to MR_print_proc_id_internal, so that printing of mode information can be turned on or off. When a list of matching predicates for the trust command is shown then mode information is superfluous, since a predicate/function is trusted, not a procedure. Added MR_print_pred_id to print predicate id - i.e. proc id without the mode info. tests/debugger/completion.exp New commands shown in completion list. tests/debugger/completion.inp Added a space, since a --More-- prompt is now displayed when showing all the commands. tests/debugger/mdb_command_test.inp untrust and trusted added. tests/debugger/declarative/trust.exp tests/debugger/declarative/trust.inp Testing of new commands. trace/mercury_trace_declarative.c trace/mercury_trace_declarative.h Added functions to add a trusted predicate and remove a trusted object. Also added a function to print a list of the trusted objects. These all call the predicates exported from declarative_debugger.m. trace/mercury_trace_internal.c Added handlers for `trusted' and `untrust' commands. trace/mercury_trace_tables.c trace/mercury_trace_tables.h Added a function to filter out only the user predicates and functions from a list of procedures. This filters out uci procs and also filters out all procs with a mode number > 0 (thus leaving one proc for each predicate/function). This is used when displaying the predicates matching an ambiguous proc-spec with a trust command. NEWS Updated NEWS file. |
||
|
|
5de0d4c27b |
Add a module qualification to work around a problem with intermodule
Estimated hours taken: 0.1 Branches: main browser/declarative_oracle.m: Add a module qualification to work around a problem with intermodule optimization. |
||
|
|
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. |
||
|
|
1752fcdb52 |
Work around a compiler bug that prevented installs on jupiter
Estimated hours taken: 0.1 Branches: main browser/declarative_oracle.m: Work around a compiler bug that prevented installs on jupiter with -O5 --intermodule-optimization --constraint-propagation --opt-space Apparently the compiler read in optimization interface files too early, and didn't know which member predicate (in set or in set_ordlist) we wanted. The fix is an explicit module qualification. |
||
|
|
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. |
||
|
|
e7c86a2342 |
Conform to the convention of importing only one browser module per
Estimated hours taken: 0.2 Branches: main browser/debugger_interface.m: browser/declarative_oracle.m: browser/interactive_query.m: browser/parse.m: Conform to the convention of importing only one browser module per line, and of importing browser modules before standard library modules. |
||
|
|
c9563335ef |
Allow users of the declarative debugger to revise answers that they
Estimated hours taken: 60 Branches: main Allow users of the declarative debugger to revise answers that they have given previously. We do this by modifying the user interface to allow a default answer to be shown as part of the question; the default answer will always be some answer the user has given previously, which they can choose to either change or accept as is. Initially no questions will be candidates for revision, but if the user ever rejects a diagnosis, some or all of the questions leading directly to the bug in question will be asked again. Add an empty command to the user_command type, for when the user just presses return. If there is a default answer, the empty command is interpreted as that answer. If there is no default answer, the empty command is interpreted as the skip command, which allows the user to cycle through all the available questions by repeatedly pressing return. browser/declarative_debugger.m: Define the type decl_evidence which represents the evidence collected against a particular suspect. Pass the evidence to the oracle as required. Ensure the analyser is updated after the user rejects a diagnosis. browser/declarative_analyser.m: Collect the evidence against the prime suspect as the answers are processed, and include this evidence when the analyser response is a bug. Export the predicate revise_analysis/4 which updates the analyser state after the user has rejected a diagnosis. Pass the IO action map to prime_suspect_get_evidence so that edt_root_question can be called. browser/declarative_oracle.m: When the user rejects a bug, retract from the oracle's knowledge base any of the evidence which implicated that bug. Rather than throw this information away, we assert it in a secondary knowledge base which is consulted when we want to know if there should be a default answer provided to the user. Update the oracle_state to reflect the above change, and remove all the get_* and set_* predicates for the oracle state. That functionality is provided by labelled fields, so maintaining the get_* and set_* predicates is no longer worth the trouble. Add the predicate retract_oracle_kb/3 to remove information from a knowledge base. Use the correct (equivalence) type for exceptions. browser/declarative_user.m: Add the type user_question, which may be a plain decl_question or may be a decl_question with a default answer. Use this type in query_user* instead of decl_question. Write the command handling switch as a separate predicate. This makes it easier for one command to emulate others (e.g. the empty command). If the question has a default answer, print it as part of the prompt. Parse the empty command. doc/user_guide.texi: Update the documentation to reflect the changes. library/list.m: Add a cc_multi version of list__map. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/empty_command.exp: tests/debugger/declarative/empty_command.inp: tests/debugger/declarative/empty_command.m: tests/debugger/declarative/revise.exp: tests/debugger/declarative/revise.inp: tests/debugger/declarative/revise.m: tests/debugger/declarative/revise_2.exp: tests/debugger/declarative/revise_2.inp: tests/debugger/declarative/revise_2.m: Test cases for the new features. |
||
|
|
fb27d22a8f |
Implement a committed choice version of the 'set' module, and use this in
Estimated hours taken: 1.5 Branches: main Implement a committed choice version of the 'set' module, and use this in the declarative debugging oracle. This implementation of sets avoids the use of builtin comparison, which would otherwise cause problems for the oracle. This fixes a bug that was causing test case 'ho5' to fail. browser/set_cc.m: The new module. This is mostly a wrapper around tree234_cc. browser/mdb.m: Make the new module a sub-module of mdb. browser/declarative_oracle.m: Use the new module instead of sets from the standard library. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/ho5.exp: tests/debugger/declarative/ho5.exp2: tests/debugger/declarative/ho5.inp: Enable this test case, and provide input and expected output. |
||
|
|
596bf09f7e |
The "complete" and "incomplete" maps in the declarative debugging oracle
Estimated hours taken: 2 Branches: main The "complete" and "incomplete" maps in the declarative debugging oracle can cause a runtime abort if higher order terms are present in the debuggee, because the maps use sets to represent the solutions to a goal, and sets make use of builtin comparison. This change fixes the problem by replacing the two maps with a single map from initial atom to truth value. The set of solutions is no longer stored explicitly. This change causes no loss of accuracy of the oracle, because we weren't really using the explicit knowledge about solutions anyway. The main drawback of this change is that if in future we implement support for "edit and continue" style debugging (e.g. by allowing previous answers to be saved in/restored from a file), we will lose some of the information pertaining to previous versions of the program, which will make the oracle slightly less effective at deducing new answers from previous ones. Since runtime aborts are a much more serious problem, we will have to live with this drawback for the moment. Another solution to this problem may have been to implement a 'set_cc' module, which would be to 'set' as 'tree234_cc' is to 'tree234'. Unfortunately, we would need to implement 'set_cc__intersect' but it appears not to be possible to implement a satisfactory committed choice version of intersection. browser/declarative_oracle.m: Replace the two maps with the new one, and update the code that accesses the knowledge base. tests/debugger/declarative/Mmakefile: Enable tests 'ho3' and 'ho4', which now work. tests/debugger/declarative/ho3.m: Fix a typo in the test case. It wasn't testing precisely the thing it was supposed to test. tests/debugger/declarative/ho3.exp: tests/debugger/declarative/ho3.inp: tests/debugger/declarative/ho4.exp: tests/debugger/declarative/ho4.inp: Input and expected output for the enabled tests. |
||
|
|
5cbec33da5 |
Add the command 'pd' to the declarative debugger.
Estimated hours taken: 1 Branches: main Add the command 'pd' to the declarative debugger. This command returns to the procedural debugger at the event corresponding to the current question; it is notionally the inverse of the 'dd' command in the procedural debugger. browser/declarative_user.m: Handle the new command, and add a new alternative to the user_response type. browser/declarative_oracle.m: Handle the new user response, and add a new alternative to the oracle_response type. browser/declarative_debugger.m: Handle the new oracle response, and add a new alternative to the diagnoser_response type. Export some procedures to C so that the back end can interpret the new diagnoser response. Update an old comment. trace/mercury_trace_declarative.c: Handle the new diagnoser response. Rename the function MR_decl_handle_bug_found, since it now also handles the case where a symptom has been found. Interpret the diagnoser response using something like a switch, rather than something like an if-then-else. This gives better error messages if the diagnoser response type is changed. doc/user_guide.texi: Document the new command. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/pd.exp: tests/debugger/declarative/pd.inp: tests/debugger/declarative/pd.m: Test the new feature. |
||
|
|
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. |
||
|
|
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.
|
||
|
|
68ebc7b53a |
Implement a committed choice version of 234-trees which uses
Estimated hours taken: 10 Branches: main Implement a committed choice version of 234-trees which uses compare_representation instead of builtin compare. Use this to implement the declarative debugger's oracle knowledge base, instead of the standard library map. We do this because the keys used by the oracle may contain non-canonical terms, which would cause a runtime abort if used as map keys. This completes the changes to the declarative debugger to support the debugging of higher order code. (There is still a problem in that the declarative debugger back end does not filter out external events for higher order calls. This means that the declarative debugger asks questions about what are effectively calls to call/N, which is not necessary since we assume that call/N is correct. This is a problem unrelated to this change, so I will deal with it separately.) browser/tree234_cc.m: The new sub-module of mdb, which implements the 234-trees. browser/declarative_oracle.m: Use the new module instead of library/map.m. Propagate the effect of the calls to committed choice code. browser/mdb.m: Include the new module. tests/debugger/declarative/Mmakefile: Enable two old test cases, higher_order and ite_2, that now work after this change. Add a new test case that tests closures with some arguments applied. tests/debugger/declarative/higher_order.exp: tests/debugger/declarative/higher_order.inp: tests/debugger/declarative/ite_2.exp: tests/debugger/declarative/ite_2.inp: Provide input and expected output for these tests. tests/debugger/declarative/ho2.exp: tests/debugger/declarative/ho2.inp: tests/debugger/declarative/ho2.m: New test case. |
||
|
|
14ceb68776 |
Change the definitions of decl_question and decl_answer in the declarative
Estimated hours taken: 24 Branches: main Change the definitions of decl_question and decl_answer in the declarative debugger. Each question now contains a reference to the EDT node that generated the question, and each answer contains the reference from the question it applies to. Previously, the answers referred to the questions themselves. This change means that the analyser no longer needs to unify questions to determine what to do with an answer. The reason we need to avoid this is that questions may contain higher order terms, and these will cause a runtime abort if unified. Also, by using our new approach it is possible to simplify the analyser in a number of ways. This is the first part of a larger change to support declarative debugging of higher order code. The main task remaining is to avoid using comparison of questions in the oracle. But this will require a different approach than the one taken here, because the oracle is interested in the value of the question, not just the identity of it. browser/declarative_*.m: Propagate the effect of the changes to decl_question and decl_answer. Fix some comments which are out of date, and elaborate on some others which don't give enough information. browser/declarative_analyser.m: Remove the definition of the suspect/1 type. Its main purpose was to associate a question with its EDT node, but this is no longer required. Update the places that used suspect(T) to instead use either decl_question(T) or just T, as appropriate. Separate out the code which calculates the analyser response. This requires adding some fields to the analyser state, but this in turn means that the processing of answers can be greatly simplified. This should also make implementing more sophisticated search strategies possible, which is something we want to do in the future. browser/declarative_debugger.m: Make the changes to the two exported types. Export a function which extracts the EDT node from the question. browser/declarative_oracle.m: browser/declarative_user.m: Add a type parameter to oracle_response and user_response, similarly to the change to the other types. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/dependency2.exp: tests/debugger/declarative/dependency2.inp: tests/debugger/declarative/dependency2.m: A test case, which tests for a bug I encountered when developing this change. tests/debugger/declarative/family.exp: Because of the change to the way the analyser matches up the answers with the EDT, a different but equally valid instance of the same bug is chosen in part of this test case. Update the expected output to reflect this. |
||
|
|
ed83014595 |
Make the debugger use the committed choice versions of the
Estimated hours taken: 2 Branches: main browser/*.m: Make the debugger use the committed choice versions of the deconstruction predicates, and propagate the committed choice environment up the call chain as far as necessary. |
||
|
|
75a2a90cbb |
This is the second part of a change to support term dependency analysis
Estimated hours taken: 40 Branches: main This is the second part of a change to support term dependency analysis in the declarative debugger. A `mark' command is implemented for the term browser, which allows a particular subterm to be selected and returned from the browser. The declarative debugger interprets this as a suspicious subterm, and tries to find a child or sibling node from which this subterm comes. This is used to determine the next question to be asked of the oracle. browser/browse.m: Update the browser interface to allow for marked subterms being returned from the browser. Implement and document the mark command. Rewrite run_command as a switch instead of a chain of if-then-elses. This forces all unimplemented commands to be explicitly listed, and gives better error checking. browser/browser_info.m: Add a maybe_mark field to the browser_info. It is initially `no', but is updated when the mark command is given. browser/declarative_analyser.m: Select which child or sibling node to ask about next by searching for the origin of the suspicious subterm. If the subterm has mode `out' we act as if the oracle had answered no, and if the subterm has mode `in' we act as if the oracle had answered yes. In future we may not wish to presume this -- we do so now mainly to keep the analysis algorithm simpler. browser/declarative_debugger.m: Add a functor for suspicious subterms to the decl_answer type. browser/declarative_oracle.m: Accommodate the changed answer type. The oracle does not try to store information about suspicious subterms in the knowledge base, because in principle this could lead to infinite loops (although currently this wouldn't be a problem since we don't ever use the information to move upward in the tree, so no cycle could be formed). browser/declarative_user.m: Accommodate the changed answer type, and interpret marked terms from the browser as suspicious subterms. browser/parse.m: Add the new command. browser/program_representation.m: Add a procedure to convert the browser's list(dir) to a term_path. Change atomic_goal_rep_is_call/2 so it fails for special predicates, which was originally intended. trace/mercury_trace_browse.c: Ignore the extra argument -- marked terms are not currently used in the main debugger. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/input_term_dep.*: tests/debugger/declarative/output_term_dep.*: tests/debugger/declarative/special_term_dep.*: New test cases. |
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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. |
||
|
|
3e065c040e |
Implement the new architecture for the front end of the
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. |
||
|
|
cc644fcf22 |
This change adds a more sophisticated oracle to the declarative
Estimated hours taken: 55
This change adds a more sophisticated oracle to the declarative
debugger. The oracle now tries to remember previous answers and uses
them if available, and only asks the user if there is no other
information.
browser/declarative_oracle.m:
- Add the type "oracle_assumption", which identifies an
internal assumption of the oracle.
- Add the type "oracle_answer", which the oracle returns to the
caller. This holds either the truth value, or a reason why
the truth value cannot be given yet.
- Implement a knowledge base to store the previous answers.
This data structure is designed to be able to store arbitrary
assertions, although at this stage only one kind of assertion
is used.
- Where possible, use the KB to answer questions, instead of
asking the user.
- Update comments.
browser/declarative_debugger.m:
- Use the new interface to the oracle. Handle "don't know"
answers in a simple way: either save the question and ask it
later or return without finding any bug.
- Move the debugger_command type to this module.
- Move the UI stuff to a new module.
browser/declarative_user.m:
New module to handle interaction between the debugger/oracle
and the user.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/oracle_db.{m,inp,exp}
Add a test case for the new feature.
|
||
|
|
07cad7c169 |
If calling from the internal debugger, use readline input for the
Estimated hours taken: 6 If calling from the internal debugger, use readline input for the interactive term browser and interactive queries. browser/browse.m: Change some if-then-elses to switches, which will help catch errors if a new functor is added to the debugger type. browser/parse.m: browser/util.m: Return a string from util__trace_getline/4 rather than a list of chars, which saves converting from a string to a list of chars and then back again. browser/util.m: Add a version of util__trace_getline that also takes I/O stream arguments. Pass these arguments to MR_trace_getline. browser/declarative_oracle.m: Call util__trace_getline/4 to do input via readline (if available). Improve error handling. browser/interactive_query.m: Call util__trace_getline to get user input, instead of standard library predicates. runtime/mercury_init.h: runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: trace/mercury_trace_internal.c: trace/mercury_trace_internal.h: Add two I/O stream arguments to MR_trace_getline. |
||
|
|
5d9569900b |
Clean up the declarative debugger.
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'. |
||
|
|
4fec7f6137 |
Add a front end to the declarative debugger, written in Mercury.
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. |