debuggere
This commit is contained in:
parent
a7fe5683a8
commit
7381bf0d84
@ -394,13 +394,12 @@ yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
|
||||
|
||||
:- style_check([+discontiguous,+multiple,+single_var]).
|
||||
|
||||
|
||||
%
|
||||
% moved this to init_gc in gc.c to separate the alpha
|
||||
% moved this to init_gc in sgc.c to separate the alpha
|
||||
%
|
||||
% :- yap_flag(gc,on).
|
||||
|
||||
% :- yap_flag(gc_trace,verbose).
|
||||
%
|
||||
% :- yap_flag(gc_trace,verbose`
|
||||
|
||||
:- multifile
|
||||
prolog:comment_hook/3.
|
||||
|
70
pl/debug.yap
70
pl/debug.yap
@ -399,7 +399,7 @@ be lost.
|
||||
%
|
||||
% debug a complex query
|
||||
%
|
||||
'$trace_query'(V, M, CP, _, call(M:V) :-
|
||||
'$trace_query'(V, M, _CP, _, call(M:V)) :-
|
||||
var(V), !.
|
||||
'$trace_query'(!, _, CP, _, '$$cut_by'(CP)) :-
|
||||
!.
|
||||
@ -433,7 +433,7 @@ be lost.
|
||||
catch(
|
||||
'$trace_goal'(G, M, L, H),
|
||||
E,
|
||||
'$re_trace_query'(E, G, M, L, H)
|
||||
'$TraceError'(E, G, M, L, H)
|
||||
))).
|
||||
|
||||
%% @pred $trace_goal( +Goal, +Module, +CallId, +CallInfo)
|
||||
@ -446,7 +446,7 @@ be lost.
|
||||
;
|
||||
'__NB_getval__'('$debug_status',state(zip,Border,Spy), fail),
|
||||
Border < GoalNumber,
|
||||
( Spy == ignore ; '$pred_being_spied'(G, M) )
|
||||
( Spy == ignore ; \+ '$pred_being_spied'(G, M) )
|
||||
),
|
||||
%writeln(go:G:M),
|
||||
!,
|
||||
@ -547,8 +547,10 @@ be lost.
|
||||
* @parameter _Info_ describes the goal
|
||||
*
|
||||
*/
|
||||
|
||||
'$debug'(_, G, M, _H) :-
|
||||
'__NB_getval__'('$debug_status',state(zip,_Border,_), fail),
|
||||
'__NB_getval__'('$debug_status',state(zip,_Border,Spy), fail),
|
||||
( Spy == stop -> \+ '$pred_being_spied'(G,M) ; true ),
|
||||
!,
|
||||
'$execute_nonstop'( G, M ).
|
||||
'$debug'(GoalNumber, G, M, Info) :-
|
||||
@ -596,30 +598,6 @@ be lost.
|
||||
'$retry_clause'(GoalNumber, G, Module, Info, _X) :-
|
||||
'$trace_port_'(redo, GoalNumber, G, Module, Info).
|
||||
|
||||
%% @pred '$re_trace_query'( Exception, +Goal, +Mod, +GoalID )
|
||||
%
|
||||
% debugger code for exceptions. Recognised cases are:
|
||||
% - abort always forwarded
|
||||
% - redo resets the goal
|
||||
% - fail gives up on the goal.
|
||||
'$re_trace_query'(abort, _G, _Module, _GoalNumber, _H) :-
|
||||
!,
|
||||
abort.
|
||||
'$re_trace_query'(error(event(fail),G0), _G, __Module, GoalNumber, _H) :-
|
||||
GoalNumber =< G0,
|
||||
!,
|
||||
fail.
|
||||
'$re_trace_query'(error(event(redo),G0), G, M, GoalNumber, H) :-
|
||||
GoalNumber > G0,
|
||||
!,
|
||||
catch(
|
||||
'$trace_goal'(G, M, GoalNumber, H),
|
||||
E,
|
||||
'$re_trace_query'(E, G,M, GoalNumber, H)
|
||||
).
|
||||
'$re_trace_query'(Throw, _G, _Module, _GoalNumber, _H) :-
|
||||
throw(Throw).
|
||||
|
||||
'$trace_port'(Port, GoalNumber, G, Module, _CalledFromDebugger, Info) :-
|
||||
'$stop_creeping'(_) ,
|
||||
current_prolog_flag(debug, true),
|
||||
@ -651,7 +629,29 @@ be lost.
|
||||
|
||||
|
||||
%%% - abort: forward throw while the call is newer than goal
|
||||
%% @pred '$re_trace_query'( Exception, +Goal, +Mod, +GoalID )
|
||||
%
|
||||
% debugger code for exceptions. Recognised cases are:
|
||||
% - abort always forwarded
|
||||
% - redo resets the goal
|
||||
% - fail gives up on the goal.
|
||||
'$TraceError'(abort, _G, _Module, _GoalNumber, _H) :-
|
||||
!,
|
||||
abort.
|
||||
'$TraceError'(error(event(fail),G0), _G, __Module, GoalNumber, _H) :-
|
||||
GoalNumber =< G0,
|
||||
!,
|
||||
fail.
|
||||
'$TraceError'(error(event(redo),G0), G, M, GoalNumber, H) :-
|
||||
GoalNumber =< G0,
|
||||
!,
|
||||
catch(
|
||||
'$trace_goal'(G, M, GoalNumber, H),
|
||||
E,
|
||||
'$TraceError'(E, G, M, GoalNumber, H)
|
||||
).
|
||||
'$TraceError'( error(Id,Info), _, _, _, _) :-
|
||||
!,
|
||||
throw( error(Id, Info) ).
|
||||
%%% - forward through the debugger
|
||||
'$TraceError'(forward('$wrapper',Event), _, _, _, _) :-
|
||||
@ -789,9 +789,10 @@ be lost.
|
||||
'__NB_setval__'('$debug_status',status(creep,0,stop)).
|
||||
'$action'(e,_,_,_,_,_) :- !, % 'e exit
|
||||
halt.
|
||||
'$action'(f,_,_,_,_,_) :- !, % 'f fail
|
||||
'$scan_number'( GoalId), %'f
|
||||
throw(error(event(fail),GoalId)).
|
||||
'$action'(f,_,CallNumber,_,_,_) :- !, % 'f fail
|
||||
'$scan_number'( ScanNumber),
|
||||
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
|
||||
throw(error(event(fail),Goal)).
|
||||
'$action'(h,_,_,_,_,_) :- !, % 'h help
|
||||
'$action_help',
|
||||
skip( debugger_input, 10),
|
||||
@ -834,10 +835,11 @@ be lost.
|
||||
% tell debugger never to stop.
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, ignore)),
|
||||
nodebug.
|
||||
'$action'(r,_,_,_,_,_) :- !, % 'r retry
|
||||
'$action'(r,_,CallNumber,_,_,_) :- !, % 'r retry
|
||||
'$scan_number'(ScanNumber), % '
|
||||
% set_prolog_flag(debug, true),
|
||||
throw(error(event(redo,ScanNumber)).
|
||||
% set_prolog_flag(debug, true),
|
||||
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
|
||||
throw(error(event(redo),Goal)).
|
||||
'$action'(s,P,CallNumber,_,_,_) :- !, % 's skip
|
||||
skip( debugger_input, 10), % '
|
||||
( (P=call; P=redo) ->
|
||||
|
Reference in New Issue
Block a user