mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-27 07:14:20 +00:00
Estimated hours taken: 20 Branches: main Allow the declarative debugger to search nodes above the node where the initial `dd' command was given. If the user asserts that the node at which the `dd' command was given is correct or inadmissible then the declarative debugger will ask questions about ancestors of the node at which the `dd' command was given. The declarative debugger will only say it cannot find a bug if the user asserts that the main/2 (or whatever the topmost traced call is) call is correct or inadmissible. This is useful when you've found an inadmissible node in the procedural debugger, but you're not sure where the erroneous ancestor is. Fix bug in sub-term dependency tracking when tracking an input sub-term: If the sub-term was bound by a primitive operation then the next question was about the child of the node in which the sub-term was bound, instead of the node itself. Add --depth-step-size option to mdb `dd' command. This allows the user to specify the depth of each materialized portion of the EDT. browser/declarative_analyser.m Allow analyser to request an explicit supertree from the diagnoser and respond correctly once an explicit subtree has been generated. When the primitive operation that binds a sub-term is found, the suspect_id of the node containing the primitive op is now returned, so handle this by asking the next question about the node containing the primitive op if its status is unknown. Stop tracking the sub-term if it is an input and we encounter an erroneous node. Remove previous_roots field from analyser_state. It is not needed because this information is now kept in the search space. browser/declarative_debugger.m Add new diagnoser response to tell backend to generate an explicit supertree. browser/declarative_edt.m Add methods to mercury_edt typeclass to get the parent of an EDT node, tell if two nodes refer to the same event and tell if a node is the topmost node (usually the 1st call to main/2). Make find_subterm_origin return the suspect in which a primitive operation was executed. Add predicate to incorporate a new explicit supertree into the search space. Add predicate to tell the analyser when it's okay to stop tracking a sub-term. Fix bug in find_subterm_origin so it doesn't report a child as the binding node when it should be the parent. Also replace duplicated code in find_subterm_origin with new predicate resolve_origin. Add extend_search_space_upwards predicate which attempts to add an extra node to the top of the search space. If a status is changed from erroneous to correct or vica versa then mark the suspects which were eliminated from the search space by the original status as unknown. browser/declarative_execution.m Rename call_last_exit_redo to call_last_interface, since excp and fail nodes can also go here. browser/declarative_tree.m Add implementations for new methods from mercury_edt typeclass. doc/user_guide.texi Document --depth-step-size dd option. Remove duplicate save command documentation. Add a comment about new functionality. tests/debugger/declarative/Mmakefile tests/debugger/declarative/mapinit.exp tests/debugger/declarative/mapinit.inp Use standardized event printing for mapinit test. tests/debugger/declarative/app.exp tests/debugger/declarative/app.inp tests/debugger/declarative/revise_2.exp tests/debugger/declarative/revise_2.inp Changed expected output and input because the bug search now continues in the ancestors of the node the original `dd' command was given in. tests/debugger/declarative/catch.exp Now also get a "reached unknown label" warning after the (expected) error "no support for code that catches exceptions", since now a retry is done so we can return to the original event in the mdb session. tests/debugger/declarative/explicit_subtree.exp tests/debugger/declarative/explicit_subtree.exp2 tests/debugger/declarative/explicit_subtree.inp tests/debugger/declarative/explicit_subtree.inp2 tests/debugger/declarative/explicit_subtree.m Modify this test to also test generation of an explicit supertree. trace/mercury_trace_declarative.c If requested to generate a supertree then retry to a node above the current top most node and collect events down to the current top most node. Interactively retry across IO when building the annotated trace. This is more user friendly than simply aborting if untabled IO is encountered. trace/mercury_trace_declarative.h Export MR_edt_depth_step_size so it can be set with the --depth-step-size dd option. trace/mercury_trace_internal.c Add --depth-step-size option for `dd' command.
70 lines
932 B
Mathematica
70 lines
932 B
Mathematica
% Test the tracking of a subterm through an explicit supertree.
|
|
|
|
:- module explicit_subtree.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int, exception.
|
|
|
|
main(!IO) :-
|
|
p1(10, Q),
|
|
write_int(Q, !IO),
|
|
nl(!IO).
|
|
|
|
:- pred p1(int::in, int::out) is det.
|
|
:- pred p2(int::in, int::out) is det.
|
|
:- pred p3(int::in, int::out) is det.
|
|
|
|
p1(X, Y) :- p2(X, Y).
|
|
p2(X, Y) :- p3(X, Y).
|
|
p3(X, Y) :- calc(X, Y).
|
|
|
|
:- pred calc(int::in, int::out) is det.
|
|
|
|
calc(X, Y) :-
|
|
(
|
|
X > 0
|
|
->
|
|
a(Z)
|
|
;
|
|
b(Z)
|
|
),
|
|
divide2(X, Z, Y).
|
|
|
|
:- pred divide2(int::in, int::in, int::out) is det.
|
|
|
|
divide2(N, D, Q) :-
|
|
(
|
|
D = 0
|
|
->
|
|
throw("zero denominator")
|
|
;
|
|
Q = N // D
|
|
).
|
|
|
|
:- pred b(int::out) is det.
|
|
|
|
b(-1).
|
|
|
|
:- pred a(int::out) is det.
|
|
|
|
a(X + Y - 100) :-
|
|
q(49, 0, X), q(51, 0, Y).
|
|
|
|
:- pred q(int::in, int::in, int::out) is det.
|
|
|
|
q(A, B, C) :-
|
|
(
|
|
A =< 0
|
|
->
|
|
B = C
|
|
;
|
|
q(A-1, B+1, C)
|
|
).
|