Files
mercury/tests/debugger/declarative/throw.m
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

78 lines
793 B
Mathematica

:- module throw.
:- interface.
:- import_module io.
:- pred main(io__state, io__state).
:- mode main(di, uo) is cc_multi.
:- implementation.
:- import_module int, exception.
main -->
{ try(p, X) },
io__write(X),
io__nl,
{ try(q, Y) },
io__write(Y),
io__nl.
:- pred p(int::out) is cc_nondet.
p(X) :-
a(A),
b(A, X),
X < 0.
:- pred a(int::out) is multi.
a(2).
a(3).
:- pred b(int::in, int::out) is multi.
b(A, B) :-
(
B = A * 3
;
B = A * 4
),
(
B > 10
->
throw("Too big")
;
true
).
:- pred q(int::out) is semidet.
q(1) :-
not (
a2(A),
not (
b2(A, 0)
),
A < 0
).
:- pred a2(int::out) is multi.
a2(2).
a2(3).
:- pred b2(int::in, int::out) is multi.
b2(A, B) :-
(
B = A * 3
;
B = A * 4
),
(
B > 10
->
throw("Too big")
;
true
).