errors
This commit is contained in:
parent
c50367325e
commit
de153bd479
21
os/streams.c
21
os/streams.c
@ -93,6 +93,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
#endif
|
||||
#include "iopreds.h"
|
||||
#if HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#define SYSTEM_STAT _stat
|
||||
@ -128,6 +131,7 @@ FILE *Yap_GetOutputStream(Term t, const char *msg) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmax =7;
|
||||
int GetFreeStreamD(void) {
|
||||
CACHE_REGS
|
||||
LOCK(GLOBAL_StreamDescLock);
|
||||
@ -137,6 +141,23 @@ int GetFreeStreamD(void) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if HAVE_BACKTRACEX
|
||||
void *callstack[256];
|
||||
int i;
|
||||
if (sno > cmax) {
|
||||
cmax++;
|
||||
for (i=7; i< sno; i++)
|
||||
fprintf(stderr," %d %x\n", i,GLOBAL_Stream[i].status);
|
||||
}
|
||||
fprintf(stderr, "++++ got %d\n", sno);
|
||||
int frames = backtrace(callstack, 256);
|
||||
char **strs = backtrace_symbols(callstack, frames);
|
||||
fprintf(stderr, "Execution stack:\n");
|
||||
for (i = 0; i < 5; ++i) {
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
}
|
||||
free(strs);
|
||||
#endif
|
||||
if (sno == MaxStreams) {
|
||||
UNLOCK(GLOBAL_StreamDescLock);
|
||||
return -1;
|
||||
|
@ -700,7 +700,6 @@ class YAPRun(InteractiveShell):
|
||||
# can fill in the output value.
|
||||
self.shell.displayhook.exec_result = result
|
||||
(program,squery,_ ,howmany) = self.prolog_cell(cell)
|
||||
print("program",program, "q", squery, "h",howmany)
|
||||
if howmany <= 0 and not program:
|
||||
return result
|
||||
if self.syntaxErrors(program+squery+".\n") :
|
||||
|
44
pl/debug.yap
44
pl/debug.yap
@ -299,7 +299,7 @@ be lost.
|
||||
* @return `call(Goal)`
|
||||
*/
|
||||
'$trace'(Mod:G) :-
|
||||
'$trace_is_off'(Mod:G,_GN0),
|
||||
'$creep_is_off'(Mod:G,_GN0),
|
||||
!,
|
||||
'$execute_nonstop'(G,Mod).
|
||||
'$trace'(Mod:G) :-
|
||||
@ -460,7 +460,7 @@ be lost.
|
||||
%% Actuallb sy debugs a
|
||||
%% goal!
|
||||
'$trace_goal'(G, M, GoalNumber, _H) :-
|
||||
'$trace_is_off'(M:G,GoalNumber),
|
||||
'$creep_is_off'(M:G,GoalNumber),
|
||||
!,
|
||||
'$execute_nonstop'(G,M).
|
||||
'$trace_goal'(G, M, _GoalNumber, _H) :-
|
||||
@ -556,7 +556,7 @@ be lost.
|
||||
*/
|
||||
|
||||
'$debug'(_, G, M, _H) :-
|
||||
'__NB_getval__'('$debug_status',state(zip,_Border,Spy), fail),
|
||||
'__NB_getval__'('$debug_status',state(zip,_Border,Spy,_Trace), fail),
|
||||
( Spy == stop -> \+ '$pred_being_spied'(G,M) ; true ),
|
||||
!,
|
||||
'$execute_nonstop'( G, M ).
|
||||
@ -608,10 +608,10 @@ be lost.
|
||||
'$trace_port'(Port, GoalNumber, G, Module, _CalledFromDebugger, Info) :-
|
||||
'$stop_creeping'(_) ,
|
||||
current_prolog_flag(debug, true),
|
||||
'__NB_getval__'('$debug_status',state(Skip,Border,_), fail),
|
||||
'__NB_getval__'('$debug_status',state(Skip,Border,_,Trace), fail),
|
||||
( Skip == creep -> true; '$id_goal'(GoalNumber), GoalNumber =< Border),
|
||||
!,
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop)),
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop,Trace)),
|
||||
'$trace_port_'(Port, GoalNumber, G, Module, Info).
|
||||
'$trace_port'(_Port, _GoalNumber, _G, _Module, _CalledFromDebugger, _Info).
|
||||
|
||||
@ -697,7 +697,7 @@ be lost.
|
||||
Goal.
|
||||
|
||||
'$port'(_P, _G, _M,GoalNumber,_Determinic, _Info ) :- %%> leap
|
||||
'__NB_getval__'('$debug_status',state(leap,Border,_), fail),
|
||||
'__NB_getval__'('$debug_status',state(leap,Border,_,_), fail),
|
||||
GoalNumber > Border,
|
||||
!.
|
||||
'$port'(P,G,Module,L,Deterministic, Info) :-
|
||||
@ -752,7 +752,8 @@ be lost.
|
||||
get_char( debugger_input,C),
|
||||
'$action'(C,P,CallNumber,G,Module,H).
|
||||
'$action'('\n',_,_,_,_,_) :- !, % newline creep
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop)).
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__Nb_setval__'('$debug_status', state(creep, 0, stop, Trace)).
|
||||
'$action'(!,_,_,_,_,_) :- !, % ! 'g execute
|
||||
read(debugger_input, G),
|
||||
% don't allow yourself to be caught by creep.
|
||||
@ -772,7 +773,8 @@ be lost.
|
||||
lists:memberchk( call_tracer, Opts),
|
||||
!, % <'Depth
|
||||
skip( debugger_input, 10),
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop)).
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop,Trace)).
|
||||
'$action'(^,_,_,G,_,_) :- !, % '
|
||||
'$print_deb_sterm'(G),
|
||||
skip( debugger_input, 10),
|
||||
@ -793,7 +795,8 @@ be lost.
|
||||
fail.
|
||||
'$action'(c,_,_,_,_,_) :- !, % 'c creep
|
||||
skip( debugger_input, 10),
|
||||
'__NB_setval__'('$debug_status',status(creep,0,stop)).
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status',status(creep,0,stop,Trace)).
|
||||
'$action'(e,_,_,_,_,_) :- !, % 'e exit
|
||||
halt.
|
||||
'$action'(f,_,CallNumber,_,_,_) :- !, % 'f fail
|
||||
@ -827,19 +830,23 @@ be lost.
|
||||
'$action'(l,_,CallNumber,_,_,_) :- !, % 'l leap
|
||||
'$scan_number'(ScanNumber),
|
||||
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
|
||||
'__NB_setval__'('$debug_status', state(leap, Goal, stop)).
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(leap, Goal, stop,Trace)).
|
||||
'$action'(z,_,_allNumber,_,_,_H) :- !, % 'z zip, fast leap
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, stop)).
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, stop, Trace)).
|
||||
% skip first call (for current goal),
|
||||
% stop next time.
|
||||
'$action'(k,_,_CallNumber,_,_,_) :- !, % 'k zip, fast leap
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, stop)).
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, stop, Trace)).
|
||||
% skip first call (for current goal),
|
||||
% stop next time.
|
||||
'$action'(n,_,_,_,_,_) :- !, % 'n nodebug
|
||||
skip( debugger_input, 10), % '
|
||||
% tell debugger never to stop.
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, ignore)),
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(zip, 0, ignore, Trace)),
|
||||
nodebug.
|
||||
'$action'(r,_,CallNumber,_,_,_) :- !, % r retry
|
||||
'$scan_number'(ScanNumber),
|
||||
@ -849,21 +856,24 @@ be lost.
|
||||
'$scan_number'(ScanNumber),
|
||||
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
|
||||
( (P==call; P==redo) ->
|
||||
'__NB_setval__'('$debug_status', state(leap, Goal, ignore) ) ;
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(leap, Goal, ignore,Trace) ) ;
|
||||
'$ilgl'(s) % '
|
||||
).
|
||||
'$action'(t,P,CallNumber,_,_,_) :- !, % 't fast skip
|
||||
'$scan_number'(ScanNumber),
|
||||
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
|
||||
( (P=call; P=redo) ->
|
||||
'__NB_setval__'('$debug_status', state(zip, Goal, ignore)) ;
|
||||
( (P=call; P=redo) ->
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(zip, Goal, ignore,Trace)) ;
|
||||
'$ilgl'(t) % '
|
||||
).
|
||||
'$action'(q,P,CallNumber,_,_,_) :- !, % 'qst skip
|
||||
'$scan_number'(ScanNumber),
|
||||
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
|
||||
( (P=call; P=redo) ->
|
||||
'__NB_setval__'('$debug_status', state(leap, Goal, stop)) ;
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
'__NB_setval__'('$debug_status', state(leap, Goal, stop, Trace)) ;
|
||||
'$ilgl'(t) % '
|
||||
).
|
||||
'$action'(+,_,_,G,M,_) :- !, %% spy this
|
||||
|
@ -94,7 +94,6 @@ error_handler(Error, Level) :-
|
||||
'$LoopError'(Error, Level).
|
||||
|
||||
'$LoopError'(_, _) :-
|
||||
stop_low_level_trace,
|
||||
flush_output(user_output),
|
||||
flush_output(user_error),
|
||||
fail.
|
||||
|
@ -206,7 +206,6 @@ compose_message(error(E, Exc), Level) -->
|
||||
{
|
||||
'$show_consult_level'(LC)
|
||||
},
|
||||
print_exception(Exc),
|
||||
location(error(E, Exc), Level, LC),
|
||||
main_message(error(E,Exc) , Level, LC ),
|
||||
c_goal( error(E, Exc), Level ),
|
||||
@ -273,7 +272,7 @@ location(style_check(A,LN,FileName,B ), Level , LC) -->
|
||||
!,
|
||||
display_consulting( FileName, Level,style_check(A,LN,FileName,B ), LC ),
|
||||
[ '~a:~d:0: ~a: ' - [FileName,LN,Level] ] .
|
||||
location( error(_,Info), Level, LC ) -->
|
||||
location( error(_,Info), Level, _LC ) -->
|
||||
{ '$error_descriptor'(Info, Desc) },
|
||||
{
|
||||
query_exception(prologPredFile, Desc, File),
|
||||
@ -285,7 +284,7 @@ location( error(_,Info), Level, LC ) -->
|
||||
!,
|
||||
{simplify_pred(M:Na/Ar,FF)},
|
||||
[ '~a:~d:0 ~a while executing ~q:'-[File, FilePos,Level,FF] ].
|
||||
location( error(_,Info), Level, LC ) -->
|
||||
location( error(_,Info), Level, _LC ) -->
|
||||
{ '$error_descriptor'(Info, Desc) },
|
||||
{
|
||||
query_exception(errorFile, Desc, File),
|
||||
|
19
pl/spy.yap
19
pl/spy.yap
@ -403,23 +403,26 @@ notrace(G) :-
|
||||
'$enable_debugging':-
|
||||
current_prolog_flag(debug, false), !.
|
||||
'$enable_debugging' :-
|
||||
nb_setval('$debug_status', state(creep, 0, stop)),
|
||||
'$trace_on', !,
|
||||
'__NB_getval__'('$trace',Trace,fail),
|
||||
nb_setval('$debug_status', state(creep, 0, stop,Trace)),
|
||||
Trace = on, !,
|
||||
'$creep'.
|
||||
'$enable_debugging'.
|
||||
|
||||
'$trace_on' :-
|
||||
'__NB_getval__'('$debug_status', state(_Creep, GN, Spy), fail),
|
||||
nb_setval('$debug_status', state(zip, GN, Spy)).
|
||||
'__NB_getval__'('$debug_status', state(_Creep, GN, Spy,_), fail),
|
||||
'__NB_setval__'('$trace',on),
|
||||
nb_setval('$debug_status', state(creep, GN, Spy, on)).
|
||||
|
||||
'$trace_off' :-
|
||||
'__NB_getval__'('$debug_status', state(_Creep, GN, Spy), fail),
|
||||
nb_setval('$debug_status', state(zip, GN, Spy)).
|
||||
'__NB_setval__'('$trace',off),
|
||||
nb_setval('$debug_status', state(zip, GN, Spy,off)).
|
||||
|
||||
'$trace_is_off'(_,_) :-
|
||||
'$creep_is_off'(_,_) :-
|
||||
current_prolog_flag(debug, false), !.
|
||||
'$trace_is_off'(Module:G, GN0) :-
|
||||
'__NB_getval__'('$debug_status',state(zip, GN, Spy), fail),
|
||||
'$creep_is_off'(Module:G, GN0) :-
|
||||
'__NB_getval__'('$debug_status',state(zip, GN, Spy,_), fail),
|
||||
(
|
||||
|
||||
'$pred_being_spied'(G,Module)
|
||||
|
38
pl/top.yap
38
pl/top.yap
@ -82,7 +82,8 @@ live :-
|
||||
% stop at spy-points if debugging is on.
|
||||
nb_setval('$debug_run',off),
|
||||
nb_setval('$debug_jump',off),
|
||||
nb_setval('$debug_status', state(zip, 0, stop)),
|
||||
'__NB_setval__'('$trace',off),
|
||||
nb_setval('$debug_status', state(zip, 0, stop,off)),
|
||||
'$command'(Command,Varnames,Pos,top),
|
||||
current_prolog_flag(break_level, BreakLevel),
|
||||
(
|
||||
@ -1016,28 +1017,29 @@ log_event( String, Args ) :-
|
||||
LF = ['Break (level ', BreakLevel, ')'|LD]
|
||||
),
|
||||
current_prolog_flag(debug, DBON),
|
||||
(
|
||||
DBON = true
|
||||
->
|
||||
(
|
||||
'$trace_on'
|
||||
->
|
||||
(
|
||||
var(LF)
|
||||
->
|
||||
LD = ['trace'|LP]
|
||||
;
|
||||
LD = [', trace '|LP]
|
||||
)
|
||||
'__NB_getval__'('$debug_status',state(_, _, _,on), fail),
|
||||
(
|
||||
var(LF)
|
||||
->
|
||||
LD = ['trace'|LP]
|
||||
;
|
||||
LD = [', trace '|LP]
|
||||
)
|
||||
;
|
||||
DBON == true
|
||||
(var(LF)
|
||||
->
|
||||
(var(LF)
|
||||
->
|
||||
LD = ['debug'|LP]
|
||||
;
|
||||
LD = [', debug'|LP]
|
||||
)
|
||||
LD = ['debug'|LP]
|
||||
;
|
||||
LD = [', debug'|LP]
|
||||
)
|
||||
)
|
||||
;
|
||||
LD = LP
|
||||
),
|
||||
),
|
||||
(
|
||||
var(LF)
|
||||
->
|
||||
|
Reference in New Issue
Block a user