2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: debug.pl *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: YAP's debugger *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Debugging / creating spy points
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
2002-04-26 20:15:21 +01:00
|
|
|
'$!'(CP) :-
|
|
|
|
'$call'(!, CP, !,Mod).
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
:- op(900,fx,[spy,nospy]).
|
|
|
|
|
|
|
|
% First part : setting and reseting spy points
|
|
|
|
|
|
|
|
% $suspy does most of the work
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy'(V,S,M) :- var(V) , !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,M:spy(V,S)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy'((M:S),P,_) :- !,
|
|
|
|
'$suspy'(S,P,M).
|
|
|
|
'$suspy'([],_,_) :- !.
|
|
|
|
'$suspy'([F|L],S,M) :- !, ( '$suspy'(F,S,M) ; '$suspy'(L,S,M) ).
|
2002-06-01 02:46:06 +01:00
|
|
|
'$suspy'(F/N,S,M) :- !,
|
|
|
|
functor(T,F,N),
|
|
|
|
'$do_suspy'(S, F, N, T, M).
|
|
|
|
'$suspy'(A,S,M) :- atom(A), !,
|
|
|
|
'$suspy_predicates_by_name'(A,S,M).
|
|
|
|
'$suspy'(P,spy,M) :- !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(domain_error(predicate_spec,P),spy(M:P)).
|
2002-06-01 02:46:06 +01:00
|
|
|
'$suspy'(P,nospy,M) :-
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(domain_error(predicate_spec,P),nospy(M:P)).
|
2002-06-01 02:46:06 +01:00
|
|
|
|
|
|
|
'$suspy_predicates_by_name'(A,S,M) :-
|
|
|
|
% just check one such predicate exists
|
|
|
|
(
|
|
|
|
current_predicate(A,M:_)
|
|
|
|
;
|
|
|
|
'$recorded'('$import','$import'(EM,M,A,_),_)
|
|
|
|
),
|
|
|
|
!,
|
|
|
|
'$do_suspy_predicates_by_name'(A,S,M).
|
|
|
|
'$suspy_predicates_by_name'(A,spy,M) :- !,
|
|
|
|
'$print_message'(warning,no_match(spy(M:A))).
|
|
|
|
'$suspy_predicates_by_name'(A,nospy,M) :-
|
|
|
|
'$print_message'(warning,no_match(nospy(M:A))).
|
|
|
|
|
|
|
|
'$do_suspy_predicates_by_name'(A,S,M) :-
|
|
|
|
current_predicate(A,M:T),
|
|
|
|
functor(T,A,N),
|
|
|
|
'$do_suspy'(S, A, N, T, M).
|
|
|
|
'$do_suspy_predicates_by_name'(A, S, M) :-
|
2002-06-18 06:25:02 +01:00
|
|
|
'$recorded'('$import','$import'(EM,M,A,N),_),
|
2002-06-01 02:46:06 +01:00
|
|
|
functor(T,A,N),
|
|
|
|
'$do_suspy'(S, A, N, T, EM).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-06-01 02:46:06 +01:00
|
|
|
|
|
|
|
%
|
|
|
|
% protect against evil arguments.
|
|
|
|
%
|
|
|
|
'$do_suspy'(S, F, N, T, M) :-
|
|
|
|
'$recorded'('$import','$import'(EM,M,F,N),_), !,
|
|
|
|
'$do_suspy'(S, F, N, T, EM).
|
|
|
|
'$do_suspy'(S, F, N, T, M) :-
|
|
|
|
'$undefined'(T,M), !,
|
|
|
|
( S = spy ->
|
|
|
|
'$print_message'(warning,no_match(spy(M:F/N)))
|
|
|
|
;
|
|
|
|
'$print_message'(warning,no_match(nospy(M:F/N)))
|
|
|
|
).
|
|
|
|
'$do_suspy'(S, F, N, T, M) :-
|
|
|
|
'$system_predicate'(T,M),
|
|
|
|
( S = spy ->
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(permission_error(access,private_procedure,T),spy(M:F/N))
|
2002-06-01 02:46:06 +01:00
|
|
|
;
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(permission_error(access,private_procedure,T),nospy(M:F/N))
|
2002-06-01 02:46:06 +01:00
|
|
|
).
|
|
|
|
'$do_suspy'(S,F,N,T,M) :-
|
|
|
|
'$suspy2'(S,F,N,T,M).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy2'(spy,F,N,T,M) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$recorded'('$spy','$spy'(T,M),_), !,
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,breakp(bp(debugger,plain,M:T,M:F/N,N),add,already)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy2'(spy,F,N,T,M) :- !,
|
2001-04-09 20:54:03 +01:00
|
|
|
'$recorda'('$spy','$spy'(T,M),_),
|
|
|
|
'$set_value'('$spypoint_added', true),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$set_spy'(T,M),
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,breakp(bp(debugger,plain,M:T,M:F/N,N),add,ok)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy2'(nospy,F,N,T,M) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$recorded'('$spy','$spy'(T,M),R), !,
|
|
|
|
erase(R),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$rm_spy'(T,M),
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,breakp(bp(debugger,plain,M:T,M:F/N,N),remove,last)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy2'(nospy,F,N,_,M) :-
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,breakp(no,breakpoint_for,M:F/N)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$pred_being_spied'(G, M) :-
|
2001-10-30 16:42:05 +00:00
|
|
|
'$recorded'('$spy','$spy'(G,M),_), !.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-10-30 16:42:05 +00:00
|
|
|
spy _ :- '$set_value'('$spypoint_added', false), fail.
|
2001-11-15 00:01:43 +00:00
|
|
|
spy L :-
|
|
|
|
'$current_module'(M),
|
|
|
|
'$suspy'(L, spy, M), fail.
|
2001-10-30 16:42:05 +00:00
|
|
|
spy _ :- '$get_value'('$spypoint_added', false), !.
|
|
|
|
spy _ :- debug.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
nospy L :-
|
|
|
|
'$current_module'(M),
|
|
|
|
'$suspy'(L, nospy, M), fail.
|
2001-10-30 16:42:05 +00:00
|
|
|
nospy _.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
nospyall :-
|
|
|
|
'$recorded'('$spy','$spy'(T,M),_), functor(T,F,N), '$suspy'(F/N,nospy,M), fail.
|
2001-04-09 20:54:03 +01:00
|
|
|
nospyall.
|
|
|
|
|
|
|
|
% debug mode -> debug flag = 1
|
|
|
|
|
|
|
|
debug :- '$get_value'(debug,1), !.
|
2002-06-01 02:46:06 +01:00
|
|
|
debug :- '$set_value'(debug,1),
|
|
|
|
'$print_message'(informational,debug(debug)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
nodebug :- nospyall,
|
|
|
|
'$set_value'(debug,0),
|
2001-08-08 22:17:27 +01:00
|
|
|
'$set_value'('$trace',0),
|
2002-04-26 20:15:21 +01:00
|
|
|
'$set_yap_flags'(10,0),
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,debug(off)).
|
2001-08-08 22:17:27 +01:00
|
|
|
|
|
|
|
trace :- '$get_value'('$trace',1), !.
|
|
|
|
trace :-
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,debug(trace)),
|
2001-08-08 22:17:27 +01:00
|
|
|
'$set_value'('$trace',1),
|
|
|
|
'$set_value'(debug,1),
|
|
|
|
'$set_value'(spy_sl,0),
|
|
|
|
% start creep,
|
|
|
|
'$set_yap_flags'(10,1),
|
|
|
|
'$creep'.
|
|
|
|
|
|
|
|
notrace :-
|
|
|
|
'$set_value'('$trace',0),
|
|
|
|
'$set_value'(debug,0),
|
2002-06-01 02:46:06 +01:00
|
|
|
'$print_message'(informational,debug(off)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
leash
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
leash(X) :- var(X),
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,leash(X)).
|
2002-06-01 02:46:06 +01:00
|
|
|
leash(X) :-
|
|
|
|
'$leashcode'(X,Code),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_value'('$leash',Code),
|
2002-06-01 02:46:06 +01:00
|
|
|
'$show_leash'(informational,Code), !.
|
2001-04-09 20:54:03 +01:00
|
|
|
leash(X) :-
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(type_error(leash_mode,X),leash(X)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-06-01 02:46:06 +01:00
|
|
|
'$show_leash'(Msg,0) :-
|
|
|
|
'$print_message'(Msg,leash([])).
|
|
|
|
'$show_leash'(Msg,Code) :-
|
|
|
|
'$check_leash_bit'(Code,2'1000,L3,call,LF),
|
|
|
|
'$check_leash_bit'(Code,2'0100,L2,exit,L3),
|
|
|
|
'$check_leash_bit'(Code,2'0010,L1,redo,L2),
|
|
|
|
'$check_leash_bit'(Code,2'0001,[],fail,L1),
|
|
|
|
'$print_message'(Msg,leash(LF)).
|
|
|
|
|
|
|
|
'$check_leash_bit'(Code,Bit,L0,_,L0) :- Bit /\ Code =:= 0, !.
|
|
|
|
'$check_leash_bit'(_,_,L0,Name,[Name|L0]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$leashcode'(full,2'1111) :- !.
|
|
|
|
'$leashcode'(on,2'1111) :- !.
|
|
|
|
'$leashcode'(half,2'1010) :- !.
|
|
|
|
'$leashcode'(loose,2'1000) :- !.
|
|
|
|
'$leashcode'(off,2'0000) :- !.
|
2002-06-01 02:46:06 +01:00
|
|
|
'$leashcode'(none,2'0000) :- !.
|
2001-04-09 20:54:03 +01:00
|
|
|
%'$leashcode'([L|M],Code) :- !, '$leashcode_list'([L|M],Code).
|
2002-06-01 02:46:06 +01:00
|
|
|
'$leashcode'([L|M],Code) :- !,
|
|
|
|
'$list2Code'([L|M],Code).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$leashcode'(N,N) :- integer(N), N >= 0, N =< 2'1111.
|
|
|
|
|
|
|
|
'$list2Code'(V,_) :- var(V), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,leash(V)).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$list2Code'([],0) :- !.
|
|
|
|
'$list2Code'([V|L],_) :- var(V), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,leash([V|L])).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$list2Code'([call|L],N) :- '$list2Code'(L,N1), N is 2'1000 + N1.
|
|
|
|
'$list2Code'([exit|L],N) :- '$list2Code'(L,N1), N is 2'0100 + N1.
|
|
|
|
'$list2Code'([redo|L],N) :- '$list2Code'(L,N1), N is 2'0010 + N1.
|
|
|
|
'$list2Code'([fail|L],N) :- '$list2Code'(L,N1), N is 2'0001 + N1.
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
debugging
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
debugging :-
|
2002-06-01 02:46:06 +01:00
|
|
|
( '$get_value'(debug,1) ->
|
|
|
|
'$print_message'(help,debug(debug))
|
|
|
|
;
|
|
|
|
'$print_message'(help,debug(off))
|
|
|
|
),
|
|
|
|
findall(M:(N/A),('$recorded'('$spy','$spy'(T,M),_),functor(T,N,A)),L),
|
|
|
|
'$print_message'(help,breakpoints(L)),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'('$leash',Leash),
|
2002-06-01 02:46:06 +01:00
|
|
|
'$show_leash'(help,Leash).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
spy
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
% This is executed before from the abstract
|
|
|
|
% machine when the spy_flag is on
|
|
|
|
|
|
|
|
% these flags are used
|
|
|
|
|
|
|
|
% flag description initial/possible values
|
|
|
|
|
|
|
|
% spy_gn goal number 1 1...
|
|
|
|
% spy_creep creep 0 0, 1
|
|
|
|
% spy_sl skip level 0 0...
|
|
|
|
% spy_sp skip port 0 0, call, fail, redo, exit
|
|
|
|
% spy_leap leap 0 0...
|
|
|
|
% spy_cl clause number 1 1...
|
|
|
|
% spy_fs fast skip 0 0, 1
|
2001-08-08 22:17:27 +01:00
|
|
|
% spy_trace trace 0 0, 1
|
2001-04-09 20:54:03 +01:00
|
|
|
% a flip-flop is also used
|
|
|
|
% when 1 spying is enabled
|
|
|
|
%'$spy'(G) :- write(user_error,'$spy'(G)), nl, fail.
|
|
|
|
%
|
|
|
|
% handle suspended goals
|
2001-09-12 16:52:28 +01:00
|
|
|
% take care with hidden goals.
|
2001-04-09 20:54:03 +01:00
|
|
|
%
|
2001-09-12 16:52:28 +01:00
|
|
|
% $spy may be called from user code, so be careful.
|
2001-04-09 20:54:03 +01:00
|
|
|
'$spy'(G) :-
|
|
|
|
'$awoken_goals'(LG), !,
|
|
|
|
'$creep',
|
|
|
|
'$wake_up_goal'(G, LG).
|
2001-12-07 20:27:03 +00:00
|
|
|
'$spy'([_|Mod:G]) :- !,
|
|
|
|
'$spy'([Mod|G]).
|
2002-04-06 06:33:44 +01:00
|
|
|
'$spy'([Module|'$call'(G)]) :- !,
|
2002-10-23 22:43:55 +01:00
|
|
|
'$fetch_goal_module'(G, Module, G1, Mod),
|
2002-04-06 06:33:44 +01:00
|
|
|
'$expand_goal'(G1, Mod, Module, NG, NM),
|
2002-04-08 04:11:33 +01:00
|
|
|
/* we may execute a system predicate, so we cannot
|
|
|
|
jump straight to do_spy */
|
|
|
|
'$spy'([NM|NG]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spy'([Module|G]) :-
|
2001-08-08 22:17:27 +01:00
|
|
|
% '$format'(user_error,"$spym(~w,~w)~n",[Module,G]),
|
2002-10-23 22:43:55 +01:00
|
|
|
'$hidden_predicate'(G,Module),
|
2001-08-08 22:17:27 +01:00
|
|
|
!,
|
|
|
|
/* called from prolog module */
|
2001-11-15 00:01:43 +00:00
|
|
|
'$execute0'(G,Module),
|
2001-09-12 16:52:28 +01:00
|
|
|
'$creep'.
|
2002-10-23 22:43:55 +01:00
|
|
|
'$spy'([Module|G]) :-
|
|
|
|
% '$format'(user_error,"$spym(~w,~w)~n",[Module,G]),
|
|
|
|
'$is_push_pred_mod'(G,Module),
|
|
|
|
!,
|
|
|
|
'$creep',
|
|
|
|
'$execute0'(G,Module).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spy'([Mod|G]) :-
|
|
|
|
'$do_spy'(G,Mod).
|
2001-09-12 16:52:28 +01:00
|
|
|
|
2002-10-23 22:43:55 +01:00
|
|
|
'$fetch_goal_module'(V, M, V, M) :- var(V), !.
|
|
|
|
'$fetch_goal_module'(M:G, _, NG, Mod) :- !,
|
|
|
|
'$fetch_goal_module'(G, M, NG, Mod).
|
|
|
|
'$fetch_goal_module'(G, M, G, M).
|
2002-04-06 06:33:44 +01:00
|
|
|
|
|
|
|
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'(G) :-
|
|
|
|
'$awoken_goals'(LG), !,
|
|
|
|
'$creep',
|
|
|
|
'$wake_up_goal'(G, LG).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$direct_spy'([M|G]) :-
|
2002-11-05 19:14:42 +00:00
|
|
|
'$hidden_predicate'(G,M),
|
2001-09-12 16:52:28 +01:00
|
|
|
!,
|
2002-02-26 22:15:36 +00:00
|
|
|
(
|
|
|
|
G = '$leave_creep'
|
|
|
|
->
|
|
|
|
true
|
|
|
|
;
|
|
|
|
/* called from prolog module */
|
|
|
|
'$execute0'(G,M),
|
|
|
|
'$creep'
|
|
|
|
).
|
2002-11-05 19:14:42 +00:00
|
|
|
'$direct_spy'([M|G]) :-
|
|
|
|
'$is_push_pred_mod'(G,M),
|
|
|
|
!,
|
|
|
|
'$creep',
|
|
|
|
'$execute0'(G,M).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$direct_spy'([Mod|G]) :-
|
|
|
|
'$do_spy'(G, Mod).
|
2001-09-12 16:52:28 +01:00
|
|
|
|
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_spy'(true, _) :- !, '$creep'.
|
|
|
|
'$do_spy'('$cut_by'(M), _) :- !, '$cut_by'(M).
|
|
|
|
'$do_spy'(G, Module) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
% write(user_error,$spy(G)), nl,
|
|
|
|
'$get_value'(debug,1), /* ditto if debug off */
|
|
|
|
'$get_value'(spy_fs,0), /* ditto if fast skipping */
|
|
|
|
( '$access_yap_flags'(10,0) -> /* if not creeping ... */
|
2002-01-02 16:55:24 +00:00
|
|
|
'$pred_being_spied'(G,Module) /* ... spy only if at a spy-point */
|
2001-04-09 20:54:03 +01:00
|
|
|
; true
|
|
|
|
),
|
2001-11-15 00:01:43 +00:00
|
|
|
% ( \+ '$undefined'(user_error_spy(_), user) -> user_error_spy(G) ;
|
2001-04-09 20:54:03 +01:00
|
|
|
% true );
|
|
|
|
!, /* you sure want to spy this ... */
|
|
|
|
'$get_value'(spy_gn,L), /* get goal no. */
|
|
|
|
L1 is L+1, /* bump it */
|
|
|
|
'$set_value'(spy_gn,L1), /* and save it globaly */
|
|
|
|
'$access_yap_flags'(10,SC),
|
|
|
|
'$set_yap_flags'(10,1), /* set creep on */
|
|
|
|
'$get_value'(spy_cl,CL), /* save global clause no. */
|
|
|
|
repeat, /* we need this to be able to implement retry */
|
2001-11-15 00:01:43 +00:00
|
|
|
'$init_spy_cl'(G,Module),
|
2002-01-18 04:24:10 +00:00
|
|
|
'$trace'(call,G,Module,L,CF), /* inform about call port */
|
2001-04-09 20:54:03 +01:00
|
|
|
/* the following choice point is where the predicate is called */
|
|
|
|
( '$get_value'(spy_sp,0), /* make sure we are not skipping*/
|
2002-01-10 18:01:14 +00:00
|
|
|
'$system_catch'('$spycalls'(G,Module,Res), Module,
|
|
|
|
Error,
|
|
|
|
prolog:'$DebugError'(Error))
|
|
|
|
/* go execute the predicate */
|
2001-04-09 20:54:03 +01:00
|
|
|
; /* we get here when the predicate fails */
|
2002-01-10 18:01:14 +00:00
|
|
|
( '$get_value'(spy_sl, -1) ->
|
2002-01-18 04:24:10 +00:00
|
|
|
'$trace'(exception,G,Module,L,CF)
|
2002-01-10 18:01:14 +00:00
|
|
|
;
|
2002-01-18 04:24:10 +00:00
|
|
|
'$trace'(fail,G,Module,L,CF) /* inform at fail port */
|
2002-01-10 18:01:14 +00:00
|
|
|
),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_sl,L2),/* make sure we are not ... */
|
|
|
|
L2 \= L, /* ... skiping to this level */
|
|
|
|
!, /* if not prepare to exit spy */
|
|
|
|
'$set_value'(spy_cl,CL),/* restore global value of clause no */
|
|
|
|
'$setflop'(0),
|
|
|
|
'$set_creep'(SC), /* restore creep value */
|
2002-01-18 04:24:10 +00:00
|
|
|
'$cont_creep'(CF), fail ), /* and exit */
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_cl,Cla), /* save no. of clause to try */
|
|
|
|
( var(Res), /* check not redoing */
|
2002-01-18 04:24:10 +00:00
|
|
|
'$trace'(exit,G,Module,L,CF), /* output message at exit */
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_sp,0), /* check not skipping */
|
|
|
|
'$set_value'(spy_cl,CL), /* restore clause no. */
|
2002-01-18 04:24:10 +00:00
|
|
|
'$set_creep'(SC), /* restore creep value */
|
2001-04-09 20:54:03 +01:00
|
|
|
'$setflop'(0),
|
2002-01-18 04:24:10 +00:00
|
|
|
'$cont_creep'(CF); /* exit */
|
2001-04-09 20:54:03 +01:00
|
|
|
/* we get here when we want to redo a goal */
|
|
|
|
'$set_value'(spy_cl,Cla),/* restore clause no. to try */
|
2002-01-18 04:24:10 +00:00
|
|
|
'$trace'(redo,G,Module,L,_), /* inform user_error */
|
2001-04-09 20:54:03 +01:00
|
|
|
fail /* to backtrack to spycalls */
|
|
|
|
).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_spy'(G,Mod) :-
|
|
|
|
'$execute0'(G,Mod). /* this clause applies when we do not want
|
2001-04-09 20:54:03 +01:00
|
|
|
to spy the goal */
|
|
|
|
|
2002-01-18 04:24:10 +00:00
|
|
|
'$cont_creep'( _) :- '$get_value'('$trace',1), '$set_yap_flags'(10,1), fail.
|
|
|
|
'$cont_creep'(CF) :- nonvar(CF), !, '$set_yap_flags'(10,1), '$creep'.
|
|
|
|
'$cont_creep'( _) :- '$access_yap_flags'(10,1), !, '$creep'.
|
|
|
|
'$cont_creep'( _).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$set_creep'(0) :- !, '$set_yap_flags'(10,0).
|
|
|
|
'$set_creep'(_).
|
|
|
|
|
|
|
|
%'$spycalls'(G,_) :- write(user_error,'$spycalls'(G)), nl(user_error), fail.
|
2002-04-26 20:15:21 +01:00
|
|
|
'$spycalls'('$!'(CP),Mod,_) :-
|
2001-11-15 00:01:43 +00:00
|
|
|
'$call'(!, CP, !,Mod).
|
|
|
|
'$spycalls'(Mod:G,_,Res) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
!,
|
2002-01-22 03:16:06 +00:00
|
|
|
'$spycalls'(G,Mod,Res).
|
2002-11-12 00:33:48 +00:00
|
|
|
'$spycalls'(G,Mod,Res) :-
|
|
|
|
'$pred_goal_expansion_on',
|
|
|
|
% make sure we do not try to expand conjs, etc...
|
|
|
|
user:goal_expansion(G,Mod,GF), !,
|
|
|
|
'$spycalls'(GF,Mod,Res).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'(\+ G,Mod,Res) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
!,
|
|
|
|
CP is '$last_choice_pt',
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'('$call'((\+ G), CP, (\+ G),Mod),Mod,Res).
|
|
|
|
'$spycalls'(not(G),Mod,Res) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
!,
|
|
|
|
CP is '$last_choice_pt',
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'('$call'(not(G), CP, not(G),Mod),Mod,Res).
|
|
|
|
'$spycalls'(G,M,Res) :- % undefined predicate
|
|
|
|
'$undefined'(G, M), !,
|
|
|
|
functor(G,F,N),
|
2001-04-09 20:54:03 +01:00
|
|
|
( '$recorded'('$import','$import'(S,M,F,N),_) ->
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'(G,S,Res) ;
|
2001-04-09 20:54:03 +01:00
|
|
|
'$undefp'([M|G])
|
|
|
|
).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'(G,M,_) :-
|
2002-01-08 05:22:40 +00:00
|
|
|
'$system_predicate'(G,M),
|
2002-03-04 15:55:13 +00:00
|
|
|
% '$flags'(G,M,F,_),
|
|
|
|
% F /\ 0xc00000 =:= 0, % but not meta-predicate or cut transparent
|
2001-04-09 20:54:03 +01:00
|
|
|
!,
|
2002-01-10 18:01:14 +00:00
|
|
|
'$spycall_stdpred'(G,M),
|
2001-04-09 20:54:03 +01:00
|
|
|
(true;
|
|
|
|
'$get_value'(spy_sp,P), P \= 0, !, fail),
|
|
|
|
( true;
|
|
|
|
'$get_value'(spy_sp,P1), P1 \= 0, !, fail)
|
|
|
|
.
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'(G,M,Res) :- % asserts and retracts can complicate live
|
2001-04-09 20:54:03 +01:00
|
|
|
( '$get_value'(spy_sp,0) -> true ; !, fail ),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$flags'(G,M,F,F),
|
2001-04-09 20:54:03 +01:00
|
|
|
F /\ 16'2000 =\= 0, !, % dynamic procedure, immediate semantics
|
|
|
|
repeat,
|
2003-01-21 16:14:52 +00:00
|
|
|
'$recordedp'(M:G,Cl,_),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_gn,L),
|
2001-11-15 00:01:43 +00:00
|
|
|
( '$spycall_dynamic'(G,M,Cl) ;
|
2001-04-09 20:54:03 +01:00
|
|
|
('$get_value'(spy_gn,L) -> '$leave_creep', fail ;
|
|
|
|
Res = redo )
|
|
|
|
),
|
|
|
|
( true ;
|
|
|
|
'$get_value'(spy_sp,P), P \= 0, !, fail )
|
|
|
|
.
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'(G,M,Res) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
( '$get_value'(spy_sp,0) -> true ; !, fail ),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$flags'(G,M,F,F),
|
2001-04-09 20:54:03 +01:00
|
|
|
F /\ 16'8 =\= 0, !, % dynamic procedure, logical update semantics
|
2001-11-15 00:01:43 +00:00
|
|
|
'$hold_index'(M:G, Index, Max), % hold an index on the procedure state when we called this goal
|
2001-04-09 20:54:03 +01:00
|
|
|
repeat,
|
|
|
|
'$get_value'(spy_cl,Cl),
|
|
|
|
'$get_value'(spy_gn,L),
|
|
|
|
Maxx is Max+1,
|
|
|
|
'$set_value'(spy_cl,Maxx),
|
|
|
|
( Cl > Max -> !, fail ; true),
|
2001-11-15 00:01:43 +00:00
|
|
|
( '$log_upd_spycall'(G,M,Cl,Index) ;
|
2001-04-09 20:54:03 +01:00
|
|
|
('$get_value'(spy_gn,L) ->
|
|
|
|
'$leave_creep', fail ; % to backtrack to repeat
|
|
|
|
Res = redo )
|
|
|
|
),
|
|
|
|
( true ;
|
|
|
|
'$get_value'(spy_sp,P), P \= 0, !, fail
|
|
|
|
)
|
|
|
|
.
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycalls'(G,M,Res) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
( '$get_value'(spy_sp,0) -> true ; !, fail ),
|
|
|
|
repeat,
|
2001-11-15 00:01:43 +00:00
|
|
|
'$number_of_clauses'(G,M,Max),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_cl,Cl),
|
|
|
|
'$get_value'(spy_gn,L),
|
|
|
|
Maxx is Max+1,
|
|
|
|
'$set_value'(spy_cl,Maxx),
|
|
|
|
( Cl > Max -> !, fail ; true),
|
2001-11-15 00:01:43 +00:00
|
|
|
( '$spycall'(G,M,Cl) ;
|
2001-04-09 20:54:03 +01:00
|
|
|
('$get_value'(spy_gn,L) ->
|
|
|
|
'$leave_creep', fail ; % to backtrack to repeat
|
|
|
|
Res = redo )
|
|
|
|
),
|
|
|
|
( true ;
|
|
|
|
'$get_value'(spy_sp,P), P \= 0, !, fail )
|
|
|
|
.
|
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycall'(G,M,Cl) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$access_yap_flags'(10,0),
|
|
|
|
!,
|
|
|
|
'$setflop'(0),
|
2002-01-10 18:01:14 +00:00
|
|
|
'$do_execute_clause'(G,M,Cl).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycall'(G,M,Cl) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$setflop'(0),
|
2002-02-26 22:15:36 +00:00
|
|
|
'$do_creep_execute'(G,M,Cl),
|
|
|
|
'$leave_creep'.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$log_upd_spycall'(G,M,Cl,Index) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$access_yap_flags'(10,0),
|
|
|
|
!,
|
|
|
|
'$setflop'(0),
|
2002-01-10 18:01:14 +00:00
|
|
|
'$do_execute_log_upd_clause'(G,M,Cl,Index).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$log_upd_spycall'(G,M,Cl,Index) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$setflop'(0),
|
2002-01-10 18:01:14 +00:00
|
|
|
'$do_execute_log_upd_clause'(G,M,Cl,Index).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
% this is to be used only for dynamic predicates
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycall_dynamic'(G,M,Cl) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$access_yap_flags'(10,0),
|
|
|
|
!,
|
|
|
|
'$setflop'(0),
|
2002-01-10 18:01:14 +00:00
|
|
|
'$do_execute_dynamic_clause'(G,M,Cl).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycall_dynamic'(G,M,Cl) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$setflop'(0),
|
2002-02-26 22:15:36 +00:00
|
|
|
'$do_creep_execute_dynamic'(G,M,Cl),
|
|
|
|
'$leave_creep'.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spycall_stdpred'(G,M) :-
|
2002-01-22 03:16:06 +00:00
|
|
|
CP is '$last_choice_pt',
|
2001-04-09 20:54:03 +01:00
|
|
|
functor(G,F,N),
|
|
|
|
(
|
2003-01-21 23:27:02 +00:00
|
|
|
'$meta_predicate'(F,M,N,_) ->
|
2001-04-09 20:54:03 +01:00
|
|
|
'$setflop'(1),
|
|
|
|
'$creep',
|
2002-01-22 03:16:06 +00:00
|
|
|
% I need to use call, otherwise I'll be in trouble if G
|
|
|
|
% is a meta-call.
|
|
|
|
'$call'(G,CP,G,M)
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
|
|
|
'$setflop'(1),
|
2002-01-22 03:16:06 +00:00
|
|
|
'$call'(G,CP,G,M)
|
2001-04-09 20:54:03 +01:00
|
|
|
),
|
|
|
|
'$setflop'(0).
|
|
|
|
|
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_execute_clause'(G,M,Cl) :-
|
|
|
|
'$some_recordedp'(M:G), !,
|
2001-04-09 20:54:03 +01:00
|
|
|
'$check_depth_for_interpreter'(D),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
|
2001-04-09 20:54:03 +01:00
|
|
|
CP is '$last_choice_pt',
|
|
|
|
(
|
2002-12-13 20:00:41 +00:00
|
|
|
'$nth_instancep'(M:G,Cl,R),
|
|
|
|
instance(R,(G:-Clause)),
|
2002-01-19 16:10:53 +00:00
|
|
|
(Clause = true -> true ; '$call'(Clause,CP,Clause,M) )
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
|
|
|
Next is Cl+1, '$set_value'(spy_cl,Next), fail
|
|
|
|
).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_execute_clause'(G,M,Cl) :-
|
|
|
|
'$execute'(G,M,Cl) ; Next is Cl+1, '$set_value'(spy_cl,Next), fail.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_execute_log_upd_clause'(G,M,Cl,Index) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$check_depth_for_interpreter'(D),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
|
2001-04-09 20:54:03 +01:00
|
|
|
CP is '$last_choice_pt',
|
|
|
|
(
|
|
|
|
(Index = [] ->
|
|
|
|
/* We have a single clause */
|
|
|
|
Cl = 1,
|
2001-11-15 00:01:43 +00:00
|
|
|
'$clause'(G, M, Clause)
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
|
|
|
Cl1 is Cl-1,
|
|
|
|
'$fetch_reference_from_index'(Index, Cl1, Ref),
|
|
|
|
instance(Ref, (G :- Clause))
|
|
|
|
),
|
2002-01-19 16:10:53 +00:00
|
|
|
(Clause = true -> true ; '$call'(Clause,CP,Clause,M) )
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
|
|
|
Next is Cl+1, '$set_value'(spy_cl,Next), fail
|
|
|
|
).
|
|
|
|
|
|
|
|
'$check_depth_for_interpreter'(10000000) :-
|
2001-11-15 00:01:43 +00:00
|
|
|
'$undefined'(get_depth_limit(_), prolog), !.
|
2001-04-09 20:54:03 +01:00
|
|
|
'$check_depth_for_interpreter'(D1) :-
|
|
|
|
get_depth_limit(D0),
|
|
|
|
D0 =\= 0,
|
|
|
|
D1 is D0-1.
|
|
|
|
|
2003-01-21 16:14:52 +00:00
|
|
|
'$do_execute_dynamic_clause'(G,M,Clause) :-
|
2003-01-21 23:27:02 +00:00
|
|
|
Clause = (G :- Body),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$check_depth_for_interpreter'(D),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
|
2001-04-09 20:54:03 +01:00
|
|
|
CP is '$last_choice_pt',
|
2003-01-21 16:14:52 +00:00
|
|
|
( Body = true -> true ; '$call'(Body,CP,Body,M) ).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_creep_execute'(G,M,Cl) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
% fast skip should ignore source mode
|
|
|
|
'$get_value'(spy_fs,0),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$some_recordedp'(M:G),
|
2001-04-09 20:54:03 +01:00
|
|
|
!,
|
|
|
|
'$check_depth_for_interpreter'(D),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
|
2001-04-09 20:54:03 +01:00
|
|
|
CP is '$last_choice_pt',
|
|
|
|
(
|
2002-12-13 20:00:41 +00:00
|
|
|
'$nth_instancep'(M:G,Cl,R),
|
|
|
|
instance(R,(G:-Clause)),
|
|
|
|
(
|
|
|
|
Clause = true
|
|
|
|
->
|
|
|
|
true
|
|
|
|
;
|
|
|
|
'$creep_call'(Clause,M,CP)
|
|
|
|
)
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
|
|
|
Next is Cl+1, '$set_value'(spy_cl,Next), fail
|
|
|
|
).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_creep_execute'(G,M,Cl) :-
|
2002-12-11 16:08:35 +00:00
|
|
|
(
|
|
|
|
'$creep_execute'(G,M,Cl),
|
|
|
|
'$leave_creep'
|
|
|
|
;
|
|
|
|
'$leave_creep',
|
|
|
|
Next is Cl+1,
|
|
|
|
'$set_value'(spy_cl,Next),
|
|
|
|
fail
|
|
|
|
).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_creep_log_upd_execute'(G,M,Cl,Index) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$check_depth_for_interpreter'(D),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
|
2001-04-09 20:54:03 +01:00
|
|
|
( CP is '$last_choice_pt',
|
|
|
|
(Index = [] ->
|
|
|
|
/* We have a single clause */
|
|
|
|
Cl = 1,
|
2001-11-15 00:01:43 +00:00
|
|
|
'$clause'(G, M, Clause)
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
|
|
|
Cl1 is Cl-1,
|
|
|
|
'$fetch_reference_from_index'(Index, Cl1, Ref),
|
|
|
|
instance(Ref, (G :- Clause))
|
|
|
|
),
|
|
|
|
(Clause = true -> true ;
|
|
|
|
% otherwise fast skip may try to interpret assembly builtins.
|
2002-01-19 16:10:53 +00:00
|
|
|
'$get_value'(spy_fs,1) -> '$call'(Clause,CP,Clause,M) ;
|
2002-01-10 18:01:14 +00:00
|
|
|
'$creep_call'(Clause,M,CP)
|
2001-04-09 20:54:03 +01:00
|
|
|
)
|
|
|
|
;
|
|
|
|
Next is Cl+1, '$set_value'(spy_cl,Next), fail
|
|
|
|
).
|
|
|
|
|
2003-01-21 16:14:52 +00:00
|
|
|
'$do_creep_execute_dynamic'(G,M,Clause) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$check_depth_for_interpreter'(D),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
|
2001-04-09 20:54:03 +01:00
|
|
|
CP is '$last_choice_pt',
|
2003-01-21 16:14:52 +00:00
|
|
|
Clause = (G :- Body),
|
2001-04-09 20:54:03 +01:00
|
|
|
(
|
2003-01-21 16:14:52 +00:00
|
|
|
Body = true -> true
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
2003-01-21 16:14:52 +00:00
|
|
|
% otherwise fast skip may try to interpret assembly builtins.
|
|
|
|
'$get_value'(spy_fs,1) -> '$call'(Body,CP,Body,M)
|
|
|
|
;
|
|
|
|
'$creep_call'(Body,M,CP)
|
2001-04-09 20:54:03 +01:00
|
|
|
).
|
|
|
|
|
|
|
|
'$leave_creep'.
|
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_execute'(G,M,Cl) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$creep',
|
2001-11-15 00:01:43 +00:00
|
|
|
'$execute'(G,M,Cl).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
%'$creep_call'(G,_) :- write(user_error,'$creepcall'(G)), nl(user_error), fail.
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(V,M,_) :- var(V), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,meta_call(M:V)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(A,M,_) :- number(A), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(type_error(callable,A),meta_call(M:A)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(R,M,_) :- db_reference(R), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(type_error(callable,R),meta_call(M:R)).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(M:G,_,CP) :- !,
|
|
|
|
'$creep_call'(G,M,CP).
|
|
|
|
'$creep_call'(fail,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|fail]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(false,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|false]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(true,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|true]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(otherwise,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|otherwise]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'((A,B),Module,CP) :- !,
|
|
|
|
'$creep_call'(A,Module,CP), '$creep_call'(B,Module,CP).
|
|
|
|
'$creep_call'((X->Y; Z),Module,CP) :- !,
|
|
|
|
( '$creep_call'(X,Module,CP), !, '$creep_call'(Y,Module,CP); '$creep_call'(Z,Module,CP)).
|
|
|
|
'$creep_call'((A;B),Module,CP) :- !,
|
|
|
|
('$creep_call'(A,Module,CP) ; '$creep_call'(B,Module,CP)).
|
|
|
|
'$creep_call'((A|B),Module,CP) :- !,
|
|
|
|
('$creep_call'(A,Module,CP) ; '$creep_call'(B,Module,CP)).
|
|
|
|
'$creep_call'(atom(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|atom(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(atomic(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|atomic(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(integer(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|integer(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(nonvar(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|nonvar(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(var(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|var(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(number(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|number(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(prismitive(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|primitive(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(compound(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|compound(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(float(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|float(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(db_reference(A),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|db_reference(A)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(\+ X,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|(\+ X)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(not X,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|not(X)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X=Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X=Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X\=Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X\=Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X==Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X==Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X>Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X>Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X>=Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X>=Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X<Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X<Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X=<Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X=<Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X=:=Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X=:=Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X=\=Y,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|X=\=Y]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(arg(X,Y,Z),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|arg(X,Y,Z)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(functor(X,Y,Z),Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|functor(X,Y,Z)]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'((X->Y),Module,CP) :- !,
|
2001-04-09 20:54:03 +01:00
|
|
|
CP1 is '$last_choice_pt',
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(X,Module,CP),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$$cut_by'(CP1),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(Y,Module,CP).
|
|
|
|
'$creep_call'(!,Module,CP) :- !,
|
2002-04-26 20:15:21 +01:00
|
|
|
'$direct_spy'([Module|'$!'(CP)]),
|
2001-04-09 20:54:03 +01:00
|
|
|
% clean up any garbage left here by the debugger.
|
|
|
|
'$$cut_by'(CP).
|
2002-01-02 16:55:24 +00:00
|
|
|
'$creep_call'('$cut_by'(X),_,_) :- !,
|
2001-04-09 20:54:03 +01:00
|
|
|
'$$cut_by'(X).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(repeat,Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|repeat]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'([A|B],Module,_) :- !,
|
2001-09-12 16:52:28 +01:00
|
|
|
'$direct_spy'([Module|[A|B]]).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$creep_call'(A,Module,CP) :-
|
2001-12-10 05:37:39 +00:00
|
|
|
'$undefined'(A,Module),
|
2001-04-09 20:54:03 +01:00
|
|
|
functor(A,F,N),
|
2001-12-10 05:37:39 +00:00
|
|
|
'$recorded'('$import','$import'(S,Module,F,N),_), !,
|
2001-12-07 20:27:03 +00:00
|
|
|
'$creep_call'(A,S,CP).
|
2001-12-10 05:37:39 +00:00
|
|
|
'$creep_call'(A,Module,_) :-
|
|
|
|
'$direct_spy'([Module|A]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
%'$creep'(G) :- $current_module(M),write(user_error,[creep,M,G]),nl(user_error),fail.
|
2002-01-18 15:55:33 +00:00
|
|
|
% skip calls to assembly versions of execute.
|
2001-04-09 20:54:03 +01:00
|
|
|
'$creep'(G) :-
|
|
|
|
'$get_value'('$alarm', true), !,
|
|
|
|
'$set_value'('$alarm', []),
|
|
|
|
( '$recorded'('$alarm_handler',A,_) ->
|
|
|
|
'$execute'(A),
|
|
|
|
G=[M|Goal]
|
|
|
|
;
|
|
|
|
true
|
|
|
|
),
|
|
|
|
'$execute'(M:Goal).
|
2002-01-09 17:19:36 +00:00
|
|
|
'$creep'(G) :-
|
2002-01-15 15:44:57 +00:00
|
|
|
'$get_value'('$sig_pending', Signals),
|
|
|
|
Signals \== [], !,
|
|
|
|
'$set_value'('$sig_pending', [] ),
|
|
|
|
'$handle_signals'(Signals),
|
|
|
|
G=[M|Goal],
|
2002-01-09 17:19:36 +00:00
|
|
|
'$execute'(M:Goal).
|
2002-02-26 21:03:15 +00:00
|
|
|
'$creep'([M|V]) :- var(V), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,M:call(M:V)).
|
2002-02-26 21:03:15 +00:00
|
|
|
'$creep'([M|'$execute_in_mod'(G,ModNum)]) :- !,
|
2002-01-18 16:08:30 +00:00
|
|
|
'$module_number'(Mod,ModNum),
|
2002-11-20 20:01:33 +00:00
|
|
|
'$clean_module_for_creep'(G,Mod,TrueMod,TrueG),
|
|
|
|
'$creep'([TrueMod|TrueG]).
|
2002-01-18 16:08:30 +00:00
|
|
|
'$creep'([M|'$execute_within'(G)]) :- !,
|
2002-11-26 22:16:30 +00:00
|
|
|
'$clean_module_for_creep'(G,M,TrueMod,TrueG),
|
2002-11-20 20:01:33 +00:00
|
|
|
'$creep'([TrueMod|TrueG]).
|
2002-01-18 16:08:30 +00:00
|
|
|
'$creep'([M|'$last_execute_within'(G)]) :- !,
|
2002-11-20 20:01:33 +00:00
|
|
|
'$clean_module_for_creep'(G,M,TrueMod,TrueG),
|
|
|
|
'$creep'([TrueMod|TrueG]).
|
2001-09-12 16:52:28 +01:00
|
|
|
'$creep'(G) :- '$direct_spy'(G).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-11-20 20:01:33 +00:00
|
|
|
'$clean_module_for_creep'(M:G,_,TrueMod,TrueG) :- !,
|
|
|
|
'$clean_module_for_creep'(G,M,TrueMod,TrueG).
|
|
|
|
'$clean_module_for_creep'(G,M,M,G).
|
|
|
|
|
2002-04-26 20:15:21 +01:00
|
|
|
'$trace'(P,'$!'(_),Mod,L,NC) :- !,
|
2002-01-18 04:24:10 +00:00
|
|
|
'$trace'(P,!,Mod,L,NC).
|
|
|
|
'$trace'(P,G,Mod,L,NC) :-
|
2001-11-15 00:01:43 +00:00
|
|
|
'$chk'(P,L,G,Mod,SL),
|
2002-01-18 04:24:10 +00:00
|
|
|
'$msg'(P,G,Mod,L,SL,NC), !.
|
|
|
|
'$trace'(_,_,_,_,_).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-01-15 15:44:57 +00:00
|
|
|
'$handle_signals'([]).
|
|
|
|
'$handle_signals'([S|Rest]) :-
|
|
|
|
'$recorded'('$sig_handler', action(S,A),_),
|
|
|
|
'$execute'(A),
|
|
|
|
'$handle_signals'(Rest).
|
2002-01-15 15:53:59 +00:00
|
|
|
'$handle_signals'([_|Rest]) :- '$handle_signals'(Rest).
|
2002-01-15 15:44:57 +00:00
|
|
|
|
2002-01-18 04:24:10 +00:00
|
|
|
'$msg'(P,G,Module,L,SL,NC):-
|
2001-04-09 20:54:03 +01:00
|
|
|
flush_output(user_output),
|
|
|
|
flush_output(user_error),
|
|
|
|
'$get_value'(debug,1),
|
|
|
|
repeat,
|
2002-03-28 18:48:55 +00:00
|
|
|
'$set_value'(debug,0),
|
|
|
|
'$get_value'('$trace',OldTrace),
|
|
|
|
'$set_value'('$trace',0),
|
2002-11-20 15:04:37 +00:00
|
|
|
('$pred_being_spied'(G,Module) -> CSPY = '*' ; CSPY = ' '),
|
|
|
|
( SL = L -> SLL = '>' ; SLL = ' '),
|
2001-11-15 00:01:43 +00:00
|
|
|
( Module\=prolog,
|
2002-11-20 15:04:37 +00:00
|
|
|
Module\=user ->
|
2002-11-20 15:07:36 +00:00
|
|
|
'$format'(user_error,"~a~a (~d) ~a: ~a:",[CSPY,SLL,L,P,Module])
|
2002-11-20 15:04:37 +00:00
|
|
|
;
|
2002-11-20 15:07:36 +00:00
|
|
|
'$format'(user_error,"~a~a (~d) ~a:",[CSPY,SLL,L,P])
|
2001-04-09 20:54:03 +01:00
|
|
|
),
|
|
|
|
'$debugger_write'(user_error,G),
|
2002-03-28 18:48:55 +00:00
|
|
|
'$set_value'(debug,1),
|
|
|
|
'$set_value'('$trace',OldTrace),
|
2001-04-09 20:54:03 +01:00
|
|
|
(
|
|
|
|
'$unleashed'(P),
|
|
|
|
nl(user_error)
|
|
|
|
;
|
|
|
|
write(user_error,' ? '), get0(user_input,C),
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(C,P,L,G,Module,NC),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(C)
|
2002-01-18 04:24:10 +00:00
|
|
|
),
|
|
|
|
!.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$unleashed'(call) :- '$get_value'('$leash',L), L /\ 2'1000 =:= 0.
|
|
|
|
'$unleashed'(exit) :- '$get_value'('$leash',L), L /\ 2'0100 =:= 0.
|
|
|
|
'$unleashed'(redo) :- '$get_value'('$leash',L), L /\ 2'0010 =:= 0.
|
|
|
|
'$unleashed'(fail) :- '$get_value'('$leash',L), L /\ 2'0001 =:= 0.
|
2002-01-10 18:01:14 +00:00
|
|
|
% the same as fail.
|
|
|
|
'$unleashed'(exception) :- '$get_value'('$leash',L), L /\ 2'0001 =:= 0.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-01-10 18:01:14 +00:00
|
|
|
'$debugger_write'(Stream, G) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$recorded'('$print_options','$debugger'(OUT),_), !,
|
|
|
|
write_term(Stream, G, OUT).
|
2002-01-10 18:01:14 +00:00
|
|
|
'$debugger_write'(Stream, G) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
writeq(Stream, G).
|
|
|
|
|
|
|
|
/*
|
|
|
|
'$chk'(P,L,G,_) :-
|
|
|
|
'$get_value'(spy_leap,Leap),
|
|
|
|
'$get_value'(spy_sp,SP),
|
|
|
|
'$access_yap_flags'(10,SC),
|
|
|
|
'$get_value'(spy_sl,SL),
|
|
|
|
'$get_value'(spy_fs,FS),
|
|
|
|
'$get_value'(spy_cl,CL),
|
|
|
|
write(user_error,[chk,L,P,Leap,SP,SC,SL,FS,CL,G]), nl(user_error),
|
|
|
|
fail.
|
|
|
|
*/
|
2001-11-15 00:01:43 +00:00
|
|
|
'$chk'(P,L,G,Mod,SL) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_leap,Leap),
|
|
|
|
(Leap = 0 -> true; % not leaping
|
2001-11-15 00:01:43 +00:00
|
|
|
('$pred_being_spied'(G,Mod) ; Leap = L), % leaping or quasileaping
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_value'(spy_leap,0) ),
|
|
|
|
'$get_value'(spy_sp,SP),
|
|
|
|
(SP = 0; SP = P), % the current skipport or no skipport
|
|
|
|
'$access_yap_flags'(10,SC),
|
2001-11-15 00:01:43 +00:00
|
|
|
(SC = 1; '$pred_being_spied'(G,Mod)),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'(spy_sl,SL),
|
|
|
|
(SL = 0; SL = L, '$set_value'(spy_sl,0), '$set_value'(spy_fs,0)),
|
|
|
|
'$set_value'(spy_sp,0), !.
|
|
|
|
|
|
|
|
'$skipeol'(10) :- !.
|
|
|
|
'$skipeol'(_) :- get0(user,C), '$skipeol'(C).
|
|
|
|
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(10,call,_,_,_,continue) :- !, % newline creep
|
2002-04-26 20:15:21 +01:00
|
|
|
'$set_yap_flags'(10,1).
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(10,_,_,_,_,continue) :- !. % newline creep
|
|
|
|
'$action'(33,_,_,_,_,_) :- !, % ! g execute
|
2001-04-09 20:54:03 +01:00
|
|
|
read(user,G),
|
|
|
|
% don't allow yourself to be caught by creep.
|
|
|
|
'$access_yap_flags'(10, CL),
|
|
|
|
'$set_yap_flags'(10, 0),
|
|
|
|
( '$execute'(G) -> true ; true),
|
|
|
|
'$set_yap_flags'(10, CL),
|
|
|
|
!, fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(60,_,_,_,_,_) :- !, % <Depth
|
2002-01-02 03:54:15 +00:00
|
|
|
'$new_deb_depth',
|
|
|
|
fail.
|
2002-05-07 22:19:52 +01:00
|
|
|
'$action'(94,_,_,G,_) :- !,
|
|
|
|
'$print_deb_sterm'(G), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'a,_,_,_,_,_) :- !, abort. % a abort
|
2002-05-07 22:19:52 +01:00
|
|
|
'$action'(0'b,_,_,_,_,_) :- !, break, % b break
|
2001-04-09 20:54:03 +01:00
|
|
|
fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'c,call,_,_,_,_) :- !, % c creep
|
2002-04-26 20:15:21 +01:00
|
|
|
'$set_yap_flags'(10,1).
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'c,exit,_,_,_,continue) :- !. % c creep
|
|
|
|
'$action'(0'c,fail,_,_,_,continue) :- !, % c creep
|
2002-04-26 20:15:21 +01:00
|
|
|
'$set_yap_flags'(10,1).
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'e,_,_,_,_,_) :- !, % e exit
|
2001-04-09 20:54:03 +01:00
|
|
|
halt.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'f,P,L,_,_,_) :- !, % f fail
|
2001-04-09 20:54:03 +01:00
|
|
|
( \+ P = fail, !; '$ilgl'(102) ),
|
|
|
|
'$set_value'(spy_sp,fail),
|
|
|
|
'$set_value'(spy_sl,L).
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'h,_,_,_,_,_) :- !, % h help
|
2002-01-18 04:24:10 +00:00
|
|
|
'$action_help',
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(104), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'?,_,_,_,_,_) :- !, % ? help
|
2002-01-18 04:24:10 +00:00
|
|
|
'$action_help',
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(104), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'p,_,_,G,Module,_) :- !, % p print
|
|
|
|
((Module = prolog ; Module = user) ->
|
|
|
|
print(user_error,G), nl(user_error)
|
|
|
|
;
|
|
|
|
print(user_error,Module:G), nl(user_error)
|
|
|
|
),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(112), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'd,_,_,G,Module,_) :- !, % d display
|
|
|
|
((Module = prolog ; Module = user) ->
|
|
|
|
display(user_error,G), nl(user_error)
|
|
|
|
;
|
|
|
|
display(user_error,Module:G), nl(user_error)
|
|
|
|
),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(100), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'l,_,_,_,_,_) :- !, % l leap
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_value'(spy_leap,1).
|
2002-05-07 04:51:59 +01:00
|
|
|
'$action'(0'n,_,_,_,_,_) :- !, % n nodebug
|
2001-04-09 20:54:03 +01:00
|
|
|
nodebug.
|
2002-05-07 04:51:59 +01:00
|
|
|
'$action'(0'k,_,_,_,_,_) :- !, % k quasi leap
|
2002-05-23 05:21:54 +01:00
|
|
|
'$set_value'(spy_leap,1),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_yap_flags'(10,0).
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'r,P,L,_,_,_) :- !, % r retry
|
2001-04-09 20:54:03 +01:00
|
|
|
( P=call, !, '$ilgl'(114); true),
|
|
|
|
'$set_value'(spy_sp,call),
|
|
|
|
'$set_value'(spy_sl,L),
|
|
|
|
write(user_error,'[ retry ]'), nl(user_error).
|
2002-05-10 16:04:03 +01:00
|
|
|
'$action'(0's,P,L,_,_,C) :- !, % s skip
|
|
|
|
( (P=call; P=redo) ->
|
|
|
|
'$set_value'(spy_sl,L)
|
|
|
|
;
|
|
|
|
C = continue
|
|
|
|
).
|
|
|
|
'$action'(0't,P,L,_,_,C) :- !, % t fast skip
|
|
|
|
( (P=call; P=redo) ->
|
|
|
|
'$set_value'(spy_sl,L), '$set_value'(spy_fs,1)
|
|
|
|
;
|
|
|
|
C = continue
|
|
|
|
).
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'+,_,_,G,M,_) :- !, % + spy this
|
|
|
|
functor(G,F,N), spy(M:(F/N)),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(43), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(0'-,_,_,G,M,_) :- !, % - nospy this
|
|
|
|
functor(G,F,N), nospy(M:(F/N)),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$skipeol'(45), fail.
|
2002-04-26 20:29:22 +01:00
|
|
|
'$action'(C,_,_,_,_,_) :- '$ilgl'(C).
|
2002-01-18 04:24:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
'$action_help' :-
|
2002-06-01 02:46:06 +01:00
|
|
|
'$format'(user_error,"newline creep a abort~n", []),
|
|
|
|
'$format'(user_error,"c creep e exit~n", []),
|
|
|
|
'$format'(user_error,"f fail h help~n", []),
|
|
|
|
'$format'(user_error,"l leap r retry~n", []),
|
|
|
|
'$format'(user_error,"s skip t fastskip~n", []),
|
|
|
|
'$format'(user_error,"q quasiskip k quasileap~n", []),
|
|
|
|
'$format'(user_error,"b break n no debug~n", []),
|
|
|
|
'$format'(user_error,"p print d display~n", []),
|
|
|
|
'$format'(user_error,"<D depth D < full term~n", []),
|
|
|
|
'$format'(user_error,"+ spy this - nospy this~n", []),
|
|
|
|
'$format'(user_error,"^ view subg ^^ view using~n", []),
|
2002-08-01 18:57:18 +01:00
|
|
|
'$format'(user_error,"! g execute goal~n", []).
|
2002-01-18 04:24:10 +00:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
'$ilgl'(C) :- '$skipeol'(C), write(user_error,'[ Illegal option. Use h for help. ]'),
|
|
|
|
nl(user_error), fail.
|
|
|
|
|
|
|
|
'$print_deb_sterm'(G) :-
|
|
|
|
'$get_sterm_list'(L), !,
|
|
|
|
'$deb_get_sterm_in_g'(L,G,A),
|
|
|
|
recorda('$debug_sub_skel',L,_),
|
2002-05-07 22:19:52 +01:00
|
|
|
'$format'(user_error,"~n~w~n~n",[A]).
|
2001-10-30 16:42:05 +00:00
|
|
|
'$print_deb_sterm'(_) :- '$skipeol'(94).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$get_sterm_list'(L) :-
|
|
|
|
get0(user_input,C),
|
|
|
|
'$deb_inc_in_sterm_oldie'(C,L0,CN),
|
|
|
|
'$get_sterm_list'(L0,CN,0,L).
|
|
|
|
|
|
|
|
'$deb_inc_in_sterm_oldie'(94,L0,CN) :- !,
|
|
|
|
get0(user_input,CN),
|
|
|
|
( '$recorded'('$debug_sub_skel',L0,_) -> true ;
|
|
|
|
CN = [] ).
|
|
|
|
'$deb_inc_in_sterm_oldie'(C,[],C).
|
|
|
|
|
|
|
|
'$get_sterm_list'(L0,C,N,L) :-
|
|
|
|
( C =:= "^", N \== 0 -> get0(CN),
|
|
|
|
'$get_sterm_list'([N|L0],CN,0,L) ;
|
|
|
|
C >= "0", C =< "9" -> NN is 10*N+C-"0", get0(CN),
|
|
|
|
'$get_sterm_list'(L0,CN,NN,L);
|
|
|
|
C =:= 10 -> (N =:= 0 -> L = L0 ; L=[N|L0]) ).
|
|
|
|
|
|
|
|
'$deb_get_sterm_in_g'([],G,G).
|
|
|
|
'$deb_get_sterm_in_g'([H|T],G,A) :-
|
|
|
|
'$deb_get_sterm_in_g'(T,G,A1),
|
|
|
|
arg(H,A1,A).
|
|
|
|
|
2002-01-02 03:54:15 +00:00
|
|
|
'$new_deb_depth' :-
|
2001-04-09 20:54:03 +01:00
|
|
|
get0(user_input,C),
|
2002-11-20 20:01:33 +00:00
|
|
|
'$get_deb_depth'(C,D),
|
|
|
|
'$set_deb_depth'(D).
|
2002-01-02 03:54:15 +00:00
|
|
|
|
2002-11-20 20:01:33 +00:00
|
|
|
'$get_deb_depth'(10,10) :- !. % default depth is 0
|
|
|
|
'$get_deb_depth'(C,XF) :-
|
|
|
|
'$get_deb_depth_char_by_char'(C,0,XF).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-11-20 20:01:33 +00:00
|
|
|
'$get_deb_depth_char_by_char'(10,X,X) :- !.
|
|
|
|
'$get_deb_depth_char_by_char'(C,X0,XF) :-
|
|
|
|
C >= "0", C =< "9", !,
|
2001-04-09 20:54:03 +01:00
|
|
|
XI is X0*10+C-"0",
|
2002-11-20 20:01:33 +00:00
|
|
|
get0(user_input,NC),
|
|
|
|
'$get_deb_depth_char_by_char'(NC,XI,XF).
|
|
|
|
% reset when given garbage.
|
|
|
|
'$get_deb_depth_char_by_char'(C,_,10) :- '$skipeol'(C).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2002-01-02 03:54:15 +00:00
|
|
|
'$set_deb_depth'(D) :-
|
|
|
|
recorded('$print_options','$debugger'(L),R), !,
|
|
|
|
'$delete_if_there'(L, max_depth(_), LN),
|
|
|
|
erase(R),
|
|
|
|
'$recorda'('$print_options','$debugger'([max_depth(D)|LN]),_).
|
|
|
|
'$set_deb_depth'(D) :-
|
|
|
|
'$recorda'('$print_options','$debugger'([quoted(true),numbervars(true),portrayed(true),max_depth(D)]),_).
|
|
|
|
|
|
|
|
'$delete_if_there'([], _, []).
|
|
|
|
'$delete_if_there'([T|L], T, LN) :- !,
|
|
|
|
'$delete_if_there'(L, T, LN).
|
|
|
|
'$delete_if_there'([Q|L], T, [Q|LN]) :-
|
|
|
|
'$delete_if_there'(L, T, LN).
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
%
|
2002-01-10 18:01:14 +00:00
|
|
|
% catch errors
|
2001-04-09 20:54:03 +01:00
|
|
|
%
|
2002-01-10 18:01:14 +00:00
|
|
|
'$DebugError'(error(Msg,Error)) :- !,
|
|
|
|
'$LoopError'(error(Msg,Error)),
|
|
|
|
fail.
|
|
|
|
% allow abort and user defined exceptions to go through.
|
|
|
|
'$DebugError'(Ball) :- !,
|
|
|
|
throw(Ball).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$init_spy_cl'(_,_) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_value'(spy_cl, 1).
|
|
|
|
|