mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-26 23:04:15 +00:00
Estimated hours taken: 16 Branches: main Make the declarative debugger more flexible with how it interprets trace event sequences. This makes the declarative debugger "smarter": it is now able to handle code that makes use of solutions/2 and its variants, and it is not confused if it misses some events due to shallow tracing. It does, however, ask more questions than it would with full tracing; this is unavoidable because it doesn't have the information about backtracking that it would normally use to prune questions away. (Later we will be able to get the information we need by using "hidden" events.) This version should (almost, see the XXX) be able to handle any of the proposals that have recently been made on mercury-developers mailing list regarding "interface" tracing. The requirements on trace event sequences are: 1) if there are any events from a certain class (e.g. interface events, negation events, disj events) then we require all events of that class; 2) if there are any disj events, we require all negation events and if-then-else events. XXX At the moment, there is another requirement: 3) the depth limiting part of the code that constructs annotated traces requires that the depths of consecutive events differ by no greater than one. This limitation shouldn't be difficult to remove, but that will come in a later change. browser/declarative_debugger.m: Document the assuptions the front end makes about trace sequences. Instead of detecting the start of a contour or stratum by looking for a particular type of event, get the caller to pass in the identity of the event at the start. If a fail event is encountered when stepping left on a contour, this indicates that some internal events were not seen. Treat the entire failed call (as well as any later conjuncts) as being in a negated context; that is, call missing_answer_children on this section of the tree, with the start of the "context" being the event before the call event corresponding to the fail we encountered. Similarly, if a neg_fail event is encountered when stepping left on a contour don't assume that it must have been backtracked over. That assumption is currently valid, but may not be in future depending on what we decide to do with hidden events. tests/debugger/declarative/Mmakefile: Enable the tests 'solutions' and 'shallow'. tests/debugger/declarative/untraced_subgoal.exp: tests/debugger/declarative/untraced_subgoal.inp: Update the input and output of this test to allow for the extra questions. tests/debugger/declarative/untraced_subgoal.m: Improve some comments. tests/debugger/declarative/shallow.exp: tests/debugger/declarative/shallow.inp: Provide correct input and expected output for this test. tests/debugger/declarative/shallow_2.m: Fix some incorrect comments. tests/debugger/declarative/solutions.exp: tests/debugger/declarative/solutions.inp: tests/debugger/declarative/solutions.exp2: tests/debugger/declarative/solutions.inp2: New files. Provide input and expected output for this test. We need an alternative input file for debug grades because these produce interface events for the library predicate solutions/2, hence extra questions are generated.
55 lines
716 B
Mathematica
55 lines
716 B
Mathematica
:- module shallow_2.
|
|
:- interface.
|
|
|
|
:- pred p(string::in, int::in, int::out) is det.
|
|
:- pred q(string::in, int::in, int::out) is det.
|
|
:- pred r(string::in, int::in, int::out) is det.
|
|
|
|
:- implementation.
|
|
:- import_module shallow_3.
|
|
|
|
p(S, M, N) :-
|
|
(
|
|
pp(S, 1, M)
|
|
->
|
|
N = 1
|
|
;
|
|
N = -11
|
|
).
|
|
|
|
:- pred pp(string::in, int::in, int::out) is multi.
|
|
|
|
pp(S, M, N) :- a(S, M, N).
|
|
pp(S, M, N) :- b(S, M, N).
|
|
|
|
q(S, M, N) :-
|
|
(
|
|
a(S, M, -1)
|
|
->
|
|
N = 11
|
|
;
|
|
N = 2
|
|
).
|
|
|
|
r(S, M, N) :-
|
|
(
|
|
\+ a(S, M, -3),
|
|
b(S, M, 5)
|
|
->
|
|
N = 23
|
|
;
|
|
N = 0
|
|
).
|
|
|
|
% shallow_3 defines:
|
|
%
|
|
% :- pred a(string::in, int::in, int::out) is multi.
|
|
%
|
|
% a(_, X, X).
|
|
% a(_, _, 0).
|
|
%
|
|
% :- pred b(string::in, int::in, int::out) is det.
|
|
%
|
|
% b(_, _, 5).
|
|
|