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) , !,
|
|
|
|
throw(error(instantiation_error,M:spy(V,S))).
|
|
|
|
'$suspy'((M:S),P,_) :- !,
|
|
|
|
'$suspy'(S,P,M).
|
|
|
|
'$suspy'([],_,_) :- !.
|
|
|
|
'$suspy'([F|L],S,M) :- !, ( '$suspy'(F,S,M) ; '$suspy'(L,S,M) ).
|
|
|
|
'$suspy'(F/N,S,M) :- !, functor(T,F,N),
|
2002-01-08 05:22:40 +00:00
|
|
|
( '$system_predicate'(T,M) ->
|
2001-04-09 20:54:03 +01:00
|
|
|
throw(error(permission_error(access,private_procedure,F/N),spy(F/N,S)));
|
2001-11-15 00:01:43 +00:00
|
|
|
'$undefined'(T,M) ->
|
2001-04-09 20:54:03 +01:00
|
|
|
throw(error(existence_error(procedure,F/N),spy(F/N,S)));
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy2'(S,F,N,T,M) ).
|
|
|
|
'$suspy'(A,S,_) :- \+ atom(A) , !,
|
2001-04-09 20:54:03 +01:00
|
|
|
throw(error(type_error(predicate_indicator,A),spy(A,S))).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy'(A,spy,M) :- '$noclausesfor'(A,M), !,
|
2001-04-09 20:54:03 +01:00
|
|
|
throw(error(existence_error(procedure,A),spy(A))).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy'(A,nospy,M) :- '$noclausesfor'(A,M), !,
|
2001-04-09 20:54:03 +01:00
|
|
|
throw(error(existence_error(procedure,A),nospy(A))).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy'(A,S,M) :- current_predicate(A,M:T),
|
2002-01-08 05:22:40 +00:00
|
|
|
\+ '$undefined'(T,M), \+ '$system_predicate'(T,M),
|
2001-10-30 16:42:05 +00:00
|
|
|
functor(T,F,N),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$suspy2'(S,F,N,T,M).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$noclausesfor'(A,M) :- current_predicate(A,M:T),
|
2002-01-08 05:22:40 +00:00
|
|
|
\+ '$undefined'(T,M) , \+ '$system_predicate'(T,M) ,
|
2001-04-09 20:54:03 +01:00
|
|
|
!, fail .
|
2001-11-15 00:01:43 +00:00
|
|
|
'$noclausesfor'(_,_).
|
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),_), !,
|
2001-11-15 00:01:43 +00:00
|
|
|
'$format'(user_error, "[ Warning: there is already a spy point on ~w:~w/~w ]~n",[M,F,N]).
|
|
|
|
'$suspy2'(spy,F,N,T,M) :- !,
|
|
|
|
'$warn_if_undef'(T,F,N,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),
|
|
|
|
'$format'(user_error,"[ Spy point set on ~w:~w/~w ]~n", [M,F,N]).
|
|
|
|
'$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),
|
|
|
|
'$format'(user_error,"[ Spy point on ~w:~w/~w removed ]~n", [M,F,N]).
|
|
|
|
'$suspy2'(nospy,F,N,_,M) :-
|
|
|
|
'$format'(user_error,"[ Warning: there is no spy point on ~w:~w/~w ]~n", [M,F,N]).
|
|
|
|
|
|
|
|
'$warn_if_undef'(T,F,N,M) :- '$undefined'(T,M), !,
|
2001-04-09 20:54:03 +01:00
|
|
|
write(user_error,'[ Warning: you have no clauses for '),
|
2001-11-15 00:01:43 +00:00
|
|
|
write(user_error,M:F/N), write(user_error,' ]'), nl(user_error).
|
|
|
|
'$warn_if_undef'(_,_,_,_).
|
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), !.
|
|
|
|
debug :- '$set_value'(debug,1), write(user_error,'[ Debug mode on ]'), nl(user_error).
|
|
|
|
|
|
|
|
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),
|
2001-08-08 22:17:27 +01:00
|
|
|
'$format'(user_error,"[ Debug mode off ]~n",[]).
|
|
|
|
|
|
|
|
trace :- '$get_value'('$trace',1), !.
|
|
|
|
trace :-
|
|
|
|
'$format'(user_error,"[ Trace mode on ]~n",[]),
|
|
|
|
'$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),
|
|
|
|
'$format'(user_error,"[ Trace and Debug mode off ]",[]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
leash
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
leash(X) :- var(X),
|
|
|
|
throw(error(instantiation_error,leash(X))).
|
|
|
|
leash(X) :- '$leashcode'(X,Code),
|
|
|
|
'$set_value'('$leash',Code),
|
|
|
|
'$show_leash'(Code), !.
|
|
|
|
leash(X) :-
|
|
|
|
throw(error(type_error(leash_mode,X),leash(X))).
|
|
|
|
|
|
|
|
'$show_leash'(0) :- write(user_error,'[ No leashing ]'), nl(user_error).
|
|
|
|
'$show_leash'(L) :-
|
|
|
|
'$leashcode'(Code,L),
|
|
|
|
write(user_error,'[ Leashing set to '), write(user_error,Code),
|
|
|
|
write(user_error,' ('),
|
|
|
|
'$show_leash_bit'(WasWritten,2'1000,L,call),
|
|
|
|
'$show_leash_bit'(WasWritten,2'0100,L,exit),
|
|
|
|
'$show_leash_bit'(WasWritten,2'0010,L,redo),
|
|
|
|
'$show_leash_bit'(WasWritten,2'0001,L,fail),
|
|
|
|
write(user_error,') ]'), nl(user_error).
|
|
|
|
|
2001-10-30 16:42:05 +00:00
|
|
|
'$show_leash_bit'(_,Bit,Code,_) :- Bit /\ Code =:= 0, !.
|
2001-04-09 20:54:03 +01:00
|
|
|
'$show_leash_bit'(Was,_,_,Name) :- var(Was), !,
|
|
|
|
Was = yes, write(user_error,Name).
|
2001-10-30 16:42:05 +00:00
|
|
|
'$show_leash_bit'(_,_,_,Name) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
write(user_error,','), write(user_error,Name).
|
|
|
|
|
|
|
|
'$leashcode'(full,2'1111) :- !.
|
|
|
|
'$leashcode'(on,2'1111) :- !.
|
|
|
|
'$leashcode'(half,2'1010) :- !.
|
|
|
|
'$leashcode'(loose,2'1000) :- !.
|
|
|
|
'$leashcode'(off,2'0000) :- !.
|
|
|
|
%'$leashcode'([L|M],Code) :- !, '$leashcode_list'([L|M],Code).
|
|
|
|
'$leashcode'([L|M],Code) :- !, ( var(Code) -> '$list2Code'([L|M],Code)
|
|
|
|
; '$code2List'(Code,[L|M]) ).
|
|
|
|
'$leashcode'(N,N) :- integer(N), N >= 0, N =< 2'1111.
|
|
|
|
|
|
|
|
'$list2Code'(V,_) :- var(V), !,
|
|
|
|
throw(error(instantiation_error,leash(V))).
|
|
|
|
'$list2Code'([],0) :- !.
|
|
|
|
'$list2Code'([V|L],_) :- var(V), !,
|
|
|
|
throw(error(instantiation_error,leash([V|L]))).
|
|
|
|
'$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.
|
|
|
|
|
|
|
|
'$code2List'(0,[]) :- !.
|
|
|
|
'$code2List'(N,[call|L]) :- X is N /\ 2'1000, X \= 0, !,
|
|
|
|
M is N-X, '$code2List'(M,L).
|
|
|
|
'$code2List'(N,[exit|L]) :- X is N /\ 2'0100, X \= 0, !,
|
|
|
|
M is N-X, '$code2List'(M,L).
|
|
|
|
'$code2List'(N,[redo|L]) :- X is N /\ 2'0010, X \= 0, !,
|
|
|
|
M is N-X, '$code2List'(M,L).
|
|
|
|
'$code2List'(N,[fail|L]) :- X is N /\ 2'0001, X \= 0, !,
|
|
|
|
M is N-X, '$code2List'(M,L).
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
debugging
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
debugging :-
|
|
|
|
'$get_value'(debug,1) ->
|
|
|
|
write(user_error,'[ Debug mode is switched on ]') ,
|
|
|
|
nl(user_error),
|
|
|
|
'$debugging_mode'
|
|
|
|
;
|
|
|
|
write(user_error,'[ Debug mode is switched off ]') ,
|
|
|
|
nl(user_error)
|
|
|
|
.
|
|
|
|
|
|
|
|
'$debugging_mode' :-
|
|
|
|
( '$recorded'('$spy',_,_) -> '$show_spies' ;
|
|
|
|
write(user_error,'[ Warning: there are no spy-points set ]') ,
|
|
|
|
nl(user_error) ),
|
|
|
|
'$get_value'('$leash',Leash),
|
|
|
|
'$show_leash'(Leash).
|
|
|
|
|
|
|
|
'$show_spies' :-
|
|
|
|
write(user_error,'[ Spy points set on :'), nl(user_error),
|
|
|
|
( '$recorded'('$spy','$spy'(T,M),_), functor(T,F,N),
|
|
|
|
write(user_error,' '),write(user_error,M:F/N),nl(user_error),
|
|
|
|
fail ;
|
|
|
|
write(user_error,' ]'), nl(user_error) ).
|
|
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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)]) :- !,
|
|
|
|
'fetch_goal_module'(G, Module, G1, Mod),
|
|
|
|
'$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]),
|
2001-12-27 22:38:41 +00:00
|
|
|
'$hidden'(G),
|
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'.
|
2001-11-15 00:01:43 +00:00
|
|
|
'$spy'([Mod|G]) :-
|
|
|
|
'$do_spy'(G,Mod).
|
2001-09-12 16:52:28 +01:00
|
|
|
|
2002-04-06 06:33:44 +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).
|
|
|
|
|
|
|
|
|
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]) :-
|
2001-09-12 16:52:28 +01:00
|
|
|
'$hidden'(G),
|
|
|
|
!,
|
2002-02-26 22:15:36 +00:00
|
|
|
(
|
|
|
|
G = '$leave_creep'
|
|
|
|
->
|
|
|
|
true
|
|
|
|
;
|
|
|
|
/* called from prolog module */
|
|
|
|
'$execute0'(G,M),
|
|
|
|
'$creep'
|
|
|
|
).
|
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).
|
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,
|
2002-05-18 05:01:53 +01:00
|
|
|
( '$db_last_age'(M:G,Max) -> true ; !, fail ),
|
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_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),
|
|
|
|
(
|
2001-11-15 00:01:43 +00:00
|
|
|
user:'$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',
|
|
|
|
(
|
2001-11-15 00:01:43 +00:00
|
|
|
'$fetch_clause'(G,M,Cl,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.
|
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_execute_dynamic_clause'(G,M,Cl) :-
|
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-01-02 16:55:24 +00:00
|
|
|
'$db_nb_to_ref'(Cl,M:G,Ref),
|
2001-04-09 20:54:03 +01:00
|
|
|
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
|
|
|
|
).
|
|
|
|
|
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',
|
|
|
|
(
|
2001-11-15 00:01:43 +00:00
|
|
|
'$fetch_clause'(G,M,Cl,Clause),
|
2001-04-09 20:54:03 +01:00
|
|
|
(Clause = true -> true ;
|
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
|
|
|
|
).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_creep_execute'(G,M,Cl) :-
|
2002-02-26 22:15:36 +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
|
|
|
|
).
|
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$do_creep_execute_dynamic'(G,M,Cl) :-
|
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',
|
|
|
|
(
|
2001-11-15 00:01:43 +00:00
|
|
|
'$db_nb_to_ref'(Cl,M:G,Ref),
|
2001-04-09 20:54:03 +01:00
|
|
|
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
|
|
|
|
).
|
|
|
|
|
|
|
|
'$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
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
'$fetch_clause'(G,M,ClNum,Body) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
% I'd like an easier way to keep a counter
|
|
|
|
'$set_value'('$fetching_clauses',1),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$recordedp'(M:G,Clause,_),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$get_value'('$fetching_clauses',Num),
|
|
|
|
( Num = ClNum ->
|
|
|
|
!,
|
|
|
|
Clause = (G :- Body)
|
|
|
|
;
|
|
|
|
Num1 is Num+1,
|
|
|
|
'$set_value'('$fetching_clauses',Num1),
|
|
|
|
fail
|
|
|
|
).
|
|
|
|
|
|
|
|
|
|
|
|
%'$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), !,
|
|
|
|
throw(error(instantiation_error,meta_call(M:V))).
|
|
|
|
'$creep_call'(A,M,_) :- number(A), !,
|
|
|
|
throw(error(type_error(callable,A),meta_call(M:A))).
|
|
|
|
'$creep_call'(R,M,_) :- db_reference(R), !,
|
|
|
|
throw(error(type_error(callable,R),meta_call(M:R))).
|
|
|
|
'$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), !,
|
|
|
|
throw(error(instantiation_error,M:call(M:V))).
|
|
|
|
'$creep'([M|'$execute_in_mod'(G,ModNum)]) :- !,
|
2002-01-18 16:08:30 +00:00
|
|
|
'$module_number'(Mod,ModNum),
|
|
|
|
'$creep'([Mod|G]).
|
|
|
|
'$creep'([M|'$execute_within'(G)]) :- !,
|
|
|
|
'$creep'([M|G]).
|
|
|
|
'$creep'([M|'$last_execute_within'(G)]) :- !,
|
2002-02-26 21:21:17 +00:00
|
|
|
'$creep'([M|G]).
|
2001-09-12 16:52:28 +01:00
|
|
|
'$creep'(G) :- '$direct_spy'(G).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
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),
|
2001-11-15 00:01:43 +00:00
|
|
|
('$pred_being_spied'(G,Module) -> write(user_error,'*') ; write(user_error,' ')),
|
2001-04-09 20:54:03 +01:00
|
|
|
( SL = L -> write(user_error,'>') ; write(user_error,' ')),
|
|
|
|
write(user_error,' ('), write(user_error,L), write(user_error,') '),
|
|
|
|
write(user_error,P), write(user_error,': '),
|
2001-11-15 00:01:43 +00:00
|
|
|
( Module\=prolog,
|
|
|
|
Module\=user -> write(user_error,Module),write(user_error,':');
|
2001-04-09 20:54:03 +01:00
|
|
|
true
|
|
|
|
),
|
|
|
|
'$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' :-
|
|
|
|
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", []),
|
|
|
|
format(user_error,"! g execute goal~n").
|
|
|
|
|
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' :-
|
|
|
|
'$get_deb_depth'(0,D),
|
|
|
|
'$set_deb_depth'(D).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$get_deb_depth'(X0,XF) :-
|
|
|
|
get0(user_input,C),
|
2002-01-02 03:54:15 +00:00
|
|
|
'$get_depth_handle_char'(C,X0,XI),
|
|
|
|
'$post_process_depth'(XI, XF).
|
|
|
|
|
|
|
|
'$post_process_depth'(0, 10) :- !.
|
|
|
|
'$post_process_depth'(X, X).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$get_depth_handle_char'(10,X,X) :- !.
|
|
|
|
'$get_depth_handle_char'(C,X0,XF) :-
|
|
|
|
C >= "0", C =< "9", !,
|
|
|
|
XI is X0*10+C-"0",
|
|
|
|
'$get_deb_depth'(XI,XF).
|
|
|
|
'$get_depth_handle_char'(C,X,X) :- '$skipeol'(C).
|
|
|
|
|
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'(G,M) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
% dynamic, immediate update procedure.
|
2001-11-15 00:01:43 +00:00
|
|
|
'$flags'(G,M,F,F), F /\ 16'2000 =\= 0, !,
|
|
|
|
( '$db_first_age'(M:G,A) ->
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_value'(spy_cl, A) ;
|
|
|
|
% no clauses for pred.
|
|
|
|
'$set_value'(spy_cl, 1) ).
|
2001-11-15 00:01:43 +00:00
|
|
|
'$init_spy_cl'(_,_) :-
|
2001-04-09 20:54:03 +01:00
|
|
|
'$set_value'(spy_cl, 1).
|
|
|
|
|