debugging
This commit is contained in:
parent
408c15f5eb
commit
a7fe5683a8
69
C/write.c
69
C/write.c
@ -100,7 +100,8 @@ static bool callPortray(Term t, int sno USES_REGS) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PROTECT(t,F) { \
|
#define PROTECT(t, F) \
|
||||||
|
{ \
|
||||||
yhandle_t yt = Yap_InitHandle(t); \
|
yhandle_t yt = Yap_InitHandle(t); \
|
||||||
F; \
|
F; \
|
||||||
t = Yap_PopHandle(yt); \
|
t = Yap_PopHandle(yt); \
|
||||||
@ -700,7 +701,7 @@ static void write_var(CELL *t, struct write_globs *wglb,
|
|||||||
wrputs("$AT(", wglb->stream);
|
wrputs("$AT(", wglb->stream);
|
||||||
write_var(t, wglb, rwt);
|
write_var(t, wglb, rwt);
|
||||||
wrputc(',', wglb->stream);
|
wrputc(',', wglb->stream);
|
||||||
PROTECT(*t,writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
PROTECT(*t, writeTerm(*l, 999, 1, FALSE, wglb, &nrwt));
|
||||||
attv = RepAttVar(t);
|
attv = RepAttVar(t);
|
||||||
wrputc(',', wglb->stream);
|
wrputc(',', wglb->stream);
|
||||||
l++;
|
l++;
|
||||||
@ -717,7 +718,6 @@ static void write_var(CELL *t, struct write_globs *wglb,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void write_list(Term t, int direction, int depth,
|
static void write_list(Term t, int direction, int depth,
|
||||||
struct write_globs *wglb, struct rewind_term *rwt) {
|
struct write_globs *wglb, struct rewind_term *rwt) {
|
||||||
Term ti;
|
Term ti;
|
||||||
@ -729,8 +729,7 @@ static void write_list(Term t, int direction, int depth,
|
|||||||
int ndirection;
|
int ndirection;
|
||||||
int do_jump;
|
int do_jump;
|
||||||
|
|
||||||
PROTECT(t,writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE,
|
PROTECT(t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||||
wglb, &nrwt));
|
|
||||||
ti = TailOfTerm(t);
|
ti = TailOfTerm(t);
|
||||||
if (IsVarTerm(ti))
|
if (IsVarTerm(ti))
|
||||||
break;
|
break;
|
||||||
@ -775,8 +774,7 @@ static void write_list(Term t, int direction, int depth,
|
|||||||
}
|
}
|
||||||
wrputc('|', wglb->stream);
|
wrputc('|', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
writeTerm(ti, 999, depth, FALSE,
|
writeTerm(ti, 999, depth, FALSE, wglb, &nrwt);
|
||||||
wglb, &nrwt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,11 +805,9 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
wrputs("'.'(", wglb->stream);
|
wrputs("'.'(", wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
|
|
||||||
PROTECT( t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE,
|
PROTECT(t, writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||||
wglb, &nrwt));
|
|
||||||
wrputs(",", wglb->stream);
|
wrputs(",", wglb->stream);
|
||||||
writeTerm(TailOfTerm(t), 999, depth + 1,
|
writeTerm(TailOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
FALSE, wglb, &nrwt);
|
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -877,8 +873,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
*p++;
|
*p++;
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
/* cannot use the term directly with the SBA */
|
/* cannot use the term directly with the SBA */
|
||||||
PROTECT( t, writeTerm(*p, 999, depth + 1, FALSE, wglb,
|
PROTECT(t, writeTerm(*p, 999, depth + 1, FALSE, wglb, &nrwt));
|
||||||
&nrwt) );
|
|
||||||
if (*p)
|
if (*p)
|
||||||
wrputc(',', wglb->stream);
|
wrputc(',', wglb->stream);
|
||||||
argno++;
|
argno++;
|
||||||
@ -906,8 +901,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
} else if (atom == AtomMinus) {
|
} else if (atom == AtomMinus) {
|
||||||
last_minus = TRUE;
|
last_minus = TRUE;
|
||||||
}
|
}
|
||||||
writeTerm(tright, rp, depth + 1, TRUE,
|
writeTerm(tright, rp, depth + 1, TRUE, wglb, &nrwt);
|
||||||
wglb, &nrwt);
|
|
||||||
if (bracket_right) {
|
if (bracket_right) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
@ -940,8 +934,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wropen_bracket(wglb, TRUE);
|
wropen_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
writeTerm(ArgOfTerm(offset,t), lp, depth + 1,
|
writeTerm(ArgOfTerm(offset, t), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||||
rinfixarg, wglb, &nrwt);
|
|
||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
@ -986,8 +979,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wropen_bracket(wglb, TRUE);
|
wropen_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
PROTECT(t,writeTerm(ArgOfTerm(1,t), lp, depth + 1,
|
PROTECT(
|
||||||
rinfixarg, wglb, &nrwt));
|
t, writeTerm(ArgOfTerm(1, t), lp, depth + 1, rinfixarg, wglb, &nrwt));
|
||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
@ -1006,8 +999,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
if (bracket_right) {
|
if (bracket_right) {
|
||||||
wropen_bracket(wglb, TRUE);
|
wropen_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
writeTerm(ArgOfTerm(2,t), rp, depth + 1, TRUE,
|
writeTerm(ArgOfTerm(2, t), rp, depth + 1, TRUE, wglb, &nrwt);
|
||||||
wglb, &nrwt);
|
|
||||||
if (bracket_right) {
|
if (bracket_right) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
@ -1047,15 +1039,14 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
} else {
|
} else {
|
||||||
wrputs("'$VAR'(", wglb->stream);
|
wrputs("'$VAR'(", wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
writeTerm(ArgOfTerm(1, t), 999, depth + 1,
|
writeTerm(ArgOfTerm(1, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
FALSE, wglb, &nrwt);
|
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
|
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
|
||||||
wrputc('{', wglb->stream);
|
wrputc('{', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
writeTerm(ArgOfTerm(1, t), GLOBAL_MaxPriority,
|
writeTerm(ArgOfTerm(1, t), GLOBAL_MaxPriority, depth + 1, FALSE, wglb,
|
||||||
depth + 1, FALSE, wglb, &nrwt);
|
&nrwt);
|
||||||
wrputc('}', wglb->stream);
|
wrputc('}', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
} else if (atom == AtomArray) {
|
} else if (atom == AtomArray) {
|
||||||
@ -1066,17 +1057,15 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
wrputs("...", wglb->stream);
|
wrputs("...", wglb->stream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
FALSE, wglb, &nrwt);
|
|
||||||
if (op != Arity) {
|
if (op != Arity) {
|
||||||
PROTECT(t, writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
PROTECT(t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb,
|
||||||
FALSE, wglb, &nrwt));
|
&nrwt));
|
||||||
wrputc(',', wglb->stream);
|
wrputc(',', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
FALSE, wglb, &nrwt);
|
|
||||||
wrputc('}', wglb->stream);
|
wrputc('}', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
} else {
|
} else {
|
||||||
@ -1090,13 +1079,12 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
|||||||
wrputc('.', wglb->stream);
|
wrputc('.', wglb->stream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PROTECT(t,writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
PROTECT(
|
||||||
FALSE, wglb, &nrwt));
|
t, writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt));
|
||||||
wrputc(',', wglb->stream);
|
wrputc(',', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
}
|
}
|
||||||
writeTerm(ArgOfTerm(op, t), 999, depth + 1,
|
writeTerm(ArgOfTerm(op, t), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
FALSE, wglb, &nrwt);
|
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1138,12 +1126,12 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
|||||||
wglb.Write_strings = flags & BackQuote_String_f;
|
wglb.Write_strings = flags & BackQuote_String_f;
|
||||||
if (!(flags & Ignore_cyclics_f) && false) {
|
if (!(flags & Ignore_cyclics_f) && false) {
|
||||||
Term ts[2];
|
Term ts[2];
|
||||||
ts[0] = Yap_BreakRational(t, 0, ts+1, TermNil PASS_REGS);
|
ts[0] = Yap_BreakRational(t, 0, ts + 1, TermNil PASS_REGS);
|
||||||
//fprintf(stderr, "%lx %lx %lx\n", t, ts[0], ts[1]);
|
// fprintf(stderr, "%lx %lx %lx\n", t, ts[0], ts[1]);
|
||||||
//Yap_DebugPlWriteln(ts[0]);
|
// Yap_DebugPlWriteln(ts[0]);
|
||||||
//ap_DebugPlWriteln(ts[1[);
|
// ap_DebugPlWriteln(ts[1[);
|
||||||
if (ts[1] != TermNil) {
|
if (ts[1] != TermNil) {
|
||||||
t = Yap_MkApplTerm( FunctorAtSymbol, 2, ts);
|
t = Yap_MkApplTerm(FunctorAtSymbol, 2, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* protect slots for portray */
|
/* protect slots for portray */
|
||||||
@ -1164,4 +1152,3 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
|||||||
Yap_CloseSlots(sls);
|
Yap_CloseSlots(sls);
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
pl/debug.yap
16
pl/debug.yap
@ -399,7 +399,7 @@ be lost.
|
|||||||
%
|
%
|
||||||
% debug a complex query
|
% debug a complex query
|
||||||
%
|
%
|
||||||
'$trace_query'(V, M, CP, _, '$trace'([M|V],CP)) :-
|
'$trace_query'(V, M, CP, _, call(M:V) :-
|
||||||
var(V), !.
|
var(V), !.
|
||||||
'$trace_query'(!, _, CP, _, '$$cut_by'(CP)) :-
|
'$trace_query'(!, _, CP, _, '$$cut_by'(CP)) :-
|
||||||
!.
|
!.
|
||||||
@ -605,11 +605,11 @@ be lost.
|
|||||||
'$re_trace_query'(abort, _G, _Module, _GoalNumber, _H) :-
|
'$re_trace_query'(abort, _G, _Module, _GoalNumber, _H) :-
|
||||||
!,
|
!,
|
||||||
abort.
|
abort.
|
||||||
'$re_trace_query'(forward(fail,G0), _G, __Module, GoalNumber, _H) :-
|
'$re_trace_query'(error(event(fail),G0), _G, __Module, GoalNumber, _H) :-
|
||||||
GoalNumber =< G0,
|
GoalNumber =< G0,
|
||||||
!,
|
!,
|
||||||
fail.
|
fail.
|
||||||
'$re_trace_query'(forward(redo,G0), G, M, GoalNumber, H) :-
|
'$re_trace_query'(error(event(redo),G0), G, M, GoalNumber, H) :-
|
||||||
GoalNumber > G0,
|
GoalNumber > G0,
|
||||||
!,
|
!,
|
||||||
catch(
|
catch(
|
||||||
@ -617,8 +617,8 @@ be lost.
|
|||||||
E,
|
E,
|
||||||
'$re_trace_query'(E, G,M, GoalNumber, H)
|
'$re_trace_query'(E, G,M, GoalNumber, H)
|
||||||
).
|
).
|
||||||
'$re_trace_query'(forward(C,G0), _G, _Module, _GoalNumber, _H) :-
|
'$re_trace_query'(Throw, _G, _Module, _GoalNumber, _H) :-
|
||||||
throw(forward(C,G0)).
|
throw(Throw).
|
||||||
|
|
||||||
'$trace_port'(Port, GoalNumber, G, Module, _CalledFromDebugger, Info) :-
|
'$trace_port'(Port, GoalNumber, G, Module, _CalledFromDebugger, Info) :-
|
||||||
'$stop_creeping'(_) ,
|
'$stop_creeping'(_) ,
|
||||||
@ -791,7 +791,7 @@ be lost.
|
|||||||
halt.
|
halt.
|
||||||
'$action'(f,_,_,_,_,_) :- !, % 'f fail
|
'$action'(f,_,_,_,_,_) :- !, % 'f fail
|
||||||
'$scan_number'( GoalId), %'f
|
'$scan_number'( GoalId), %'f
|
||||||
throw(forward(fail,GoalId)).
|
throw(error(event(fail),GoalId)).
|
||||||
'$action'(h,_,_,_,_,_) :- !, % 'h help
|
'$action'(h,_,_,_,_,_) :- !, % 'h help
|
||||||
'$action_help',
|
'$action_help',
|
||||||
skip( debugger_input, 10),
|
skip( debugger_input, 10),
|
||||||
@ -837,7 +837,7 @@ be lost.
|
|||||||
'$action'(r,_,_,_,_,_) :- !, % 'r retry
|
'$action'(r,_,_,_,_,_) :- !, % 'r retry
|
||||||
'$scan_number'(ScanNumber), % '
|
'$scan_number'(ScanNumber), % '
|
||||||
% set_prolog_flag(debug, true),
|
% set_prolog_flag(debug, true),
|
||||||
throw(forward(redo,ScanNumber)).
|
throw(error(event(redo,ScanNumber)).
|
||||||
'$action'(s,P,CallNumber,_,_,_) :- !, % 's skip
|
'$action'(s,P,CallNumber,_,_,_) :- !, % 's skip
|
||||||
skip( debugger_input, 10), % '
|
skip( debugger_input, 10), % '
|
||||||
( (P=call; P=redo) ->
|
( (P=call; P=redo) ->
|
||||||
@ -869,7 +869,7 @@ be lost.
|
|||||||
'$show_ancestors'(HowMany),
|
'$show_ancestors'(HowMany),
|
||||||
fail.
|
fail.
|
||||||
'$action'('T',exception(G),_,_,_,_) :- !, % 'T throw
|
'$action'('T',exception(G),_,_,_,_) :- !, % 'T throw
|
||||||
throw( forward('$wrapper',G)).
|
throw( G ).
|
||||||
'$action'(C,_,_,_,_,_) :-
|
'$action'(C,_,_,_,_,_) :-
|
||||||
skip( debugger_input, 10),
|
skip( debugger_input, 10),
|
||||||
'$ilgl'(C),
|
'$ilgl'(C),
|
||||||
|
Reference in New Issue
Block a user