This commit is contained in:
Vítor Santos Costa 2019-05-19 09:48:13 +01:00
parent c3a254e44d
commit 0e47ddc802
5 changed files with 110 additions and 93 deletions

View File

@ -2322,7 +2322,7 @@ static Int new_system_predicate(
} }
static Int static Int
p_is_system_predicate(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */ is_system_predicate(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */
PredEntry *pe; PredEntry *pe;
Term t1 = Deref(ARG1); Term t1 = Deref(ARG1);
@ -2341,7 +2341,7 @@ static Int
} }
static Int static Int
p_is_opaque_predicate(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */ is_opaque_predicate(USES_REGS1) { /* '$is_multifile'(+S,+Mod) */
PredEntry *pe; PredEntry *pe;
Term t1 = Deref(ARG1); Term t1 = Deref(ARG1);
bool out; bool out;
@ -4323,9 +4323,9 @@ void Yap_InitCdMgr(void) {
TestPredFlag | SafePredFlag); TestPredFlag | SafePredFlag);
Yap_InitCPred("$new_system_predicate", 3, new_system_predicate, Yap_InitCPred("$new_system_predicate", 3, new_system_predicate,
SafePredFlag | SyncPredFlag); SafePredFlag | SyncPredFlag);
Yap_InitCPred("$is_system_predicate", 2, p_is_system_predicate, Yap_InitCPred("$is_system_predicate", 2, is_system_predicate,
TestPredFlag | SafePredFlag); TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_opaque_predicate", 2, p_is_opaque_predicate, Yap_InitCPred("$is_opaque_predicate", 2, is_opaque_predicate,
TestPredFlag | SafePredFlag); TestPredFlag | SafePredFlag);
Yap_InitCPred("$new_discontiguous", 3, p_new_discontiguous, Yap_InitCPred("$new_discontiguous", 3, p_new_discontiguous,
SafePredFlag | SyncPredFlag); SafePredFlag | SyncPredFlag);

View File

@ -322,10 +322,11 @@ static bool getLine(int inp) {
rl_instream = GLOBAL_Stream[inp].file; rl_instream = GLOBAL_Stream[inp].file;
const unsigned char *myrl_line = NULL; const unsigned char *myrl_line = NULL;
StreamDesc *s = GLOBAL_Stream + inp; StreamDesc *s = GLOBAL_Stream + inp;
bool shouldPrompt = Yap_DoPrompt(s);
/* window of vulnerability opened */ /* window of vulnerability opened */
LOCAL_PrologMode |= ConsoleGetcMode; LOCAL_PrologMode |= ConsoleGetcMode;
if (Yap_DoPrompt(s)) { // no output so far if (true || shouldPrompt) { // no output so far
rl_set_signals(); rl_set_signals();
myrl_line = (unsigned char *)readline(LOCAL_Prompt); myrl_line = (unsigned char *)readline(LOCAL_Prompt);
rl_clear_signals(); rl_clear_signals();

View File

@ -367,12 +367,13 @@ be lost.
!, !,
set_stream(S,alias(debugger_input)). set_stream(S,alias(debugger_input)).
'$debugger_input' :- '$debugger_input' :-
current_prolog_flag(unix, true ), !, current_prolog_flag(unix, true ),
!,
open('/dev/tty', read, _S, [alias(debugger_input),bom(false)]). open('/dev/tty', read, _S, [alias(debugger_input),bom(false)]).
'$debugger_input' :- '$debugger_input' :-
current_prolog_flag(windows, true ), !, current_prolog_flag(windows, true ),
!,
open('CONIN$', read, _S, [alias(debugger_input),bom(false)]). open('CONIN$', read, _S, [alias(debugger_input),bom(false)]).
'$debugger_output' :- '$debugger_output' :-
stream_property(_,alias(debugger_output)), stream_property(_,alias(debugger_output)),
!. !.
@ -383,10 +384,12 @@ be lost.
!, !,
set_stream(S,alias(debugger_output)). set_stream(S,alias(debugger_output)).
'$debugger_output' :- '$debugger_output' :-
current_prolog_flag(unix, true ), !, current_prolog_flag(unix, true ),
!,
open('/dev/tty', write, _S, [alias(debugger_output)]). open('/dev/tty', write, _S, [alias(debugger_output)]).
'$debugger_output' :- '$debugger_output' :-
current_prolog_flag(windows, true ), !, current_prolog_flag(windows, true ),
!,
open('CONOUT$', write, _S, [alias(debugger_output)]). open('CONOUT$', write, _S, [alias(debugger_output)]).
@ -398,13 +401,18 @@ be lost.
% debug a complex query % debug a complex query
% %
'$trace_query'(V, M, _CP, _) :- '$trace_query'(V, M, _CP, _) :-
var(V), !, call(M:V). var(V),
!,
call(M:V).
'$trace_query'(!, _, CP, _) :- '$trace_query'(!, _, CP, _) :-
!, '$$cut_by'(CP). !,
'$$cut_by'(CP).
'$trace_query'('$cut_by'(M), _, _, _) :- '$trace_query'('$cut_by'(M), _, _, _) :-
!, '$$cut_by'(M). !,
'$$cut_by'(M).
'$trace_query'('$$cut_by'(M), _, _, _) :- '$trace_query'('$$cut_by'(M), _, _, _) :-
!, '$$cut_by'(M). !,
'$$cut_by'(M).
'$trace_query'(M:G, _, CP,S) :- '$trace_query'(M:G, _, CP,S) :-
!, !,
'$yap_strip_module'(M:G, M0, G0), '$yap_strip_module'(M:G, M0, G0),
@ -676,22 +684,21 @@ be lost.
'$port'(P,G,Module,L,Deterministic, Info) :- '$port'(P,G,Module,L,Deterministic, Info) :-
% at this point we are done with leap or skip % at this point we are done with leap or skip
repeat, repeat,
flush_output,
'$clear_input'(debugger_input),
'$trace_msg'(P,G,Module,L,Deterministic), '$trace_msg'(P,G,Module,L,Deterministic),
( (
'$unleashed'(P) -> '$unleashed'(P) ->
'$action'('\n',P,L,G,Module,Info), '$action'('\n',P,L,G,Module,Info),
nl(debugger_output) nl(debugger_output)
; ;
write(debugger_output,' ? '), prompt1(' ? '),
'$clear_input'(debugger_input),
get_char(debugger_input,C), get_char(debugger_input,C),
'$action'(C,P,L,G,Module,_Info) '$action'(C,P,L,G,Module,_Info)
), ),
!. !.
'$trace_msg'(P,G,Module,L,Deterministic) :- '$trace_msg'(P,G,Module,L,Deterministic) :-
flush_output(user_output),
flush_output(user_error),
functor(P,P0,_), functor(P,P0,_),
(P = exit, Deterministic \= deterministic -> Det = '?' ; Det = ' '), (P = exit, Deterministic \= deterministic -> Det = '?' ; Det = ' '),
('$pred_being_spied'(G,Module) -> CSPY = '*' ; CSPY = ' '), ('$pred_being_spied'(G,Module) -> CSPY = '*' ; CSPY = ' '),
@ -954,11 +961,17 @@ be lost.
'$deb_inc_in_sterm_oldie'(C,[],C). '$deb_inc_in_sterm_oldie'(C,[],C).
'$get_sterm_list'(L0,C,N,L) :- '$get_sterm_list'(L0,C,N,L) :-
( C =:= "^", N =\= 0 -> get_code(debugger_input, CN), ( C =:= "^", N =\= 0 ->
'$get_sterm_list'([N|L0],CN,0,L) ; get_code(debugger_input, CN),
C >= "0", C =< "9" -> NN is 10*N+C-"0", get_code(debugger_input, CN), '$get_sterm_list'([N|L0],CN,0,L)
'$get_sterm_list'(L0,CN,NN,L); ;
C =:= 10 -> (N =:= 0 -> L = L0 ; L=[N|L0]) ). C >= "0", C =< "9" ->
NN is 10*N+C-"0", get_code(debugger_input, 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'([],G,G).
'$deb_get_sterm_in_g'([H|T],G,A) :- '$deb_get_sterm_in_g'([H|T],G,A) :-
@ -1007,17 +1020,20 @@ be lost.
'$debugger_skip_trace_query'([CP|CPs],CPs1) :- '$debugger_skip_trace_query'([CP|CPs],CPs1) :-
yap_hacks:choicepoint(CP,_,prolog,'$trace_query',4,(_;_),_), !, yap_hacks:choicepoint(CP,_,prolog,'$trace_query',4,(_;_),_),
!,
'$debugger_skip_trace_query'(CPs,CPs1). '$debugger_skip_trace_query'(CPs,CPs1).
'$debugger_skip_trace_query'(CPs,CPs). '$debugger_skip_trace_query'(CPs,CPs).
'$debugger_skip_traces'([CP|CPs],CPs1) :- '$debugger_skip_traces'([CP|CPs],CPs1) :-
yap_hacks:choicepoint(CP,_,prolog,'$port',4,(_;_),_), !, yap_hacks:choicepoint(CP,_,prolog,'$port',4,(_;_),_),
!,
'$debugger_skip_traces'(CPs,CPs1). '$debugger_skip_traces'(CPs,CPs1).
'$debugger_skip_traces'(CPs,CPs). '$debugger_skip_traces'(CPs,CPs).
'$debugger_skip_loop_spy2'([CP|CPs],CPs1) :- '$debugger_skip_loop_spy2'([CP|CPs],CPs1) :-
yap_hacks:choicepoint(CP,_,prolog,'$loop_spy2',5,(_;_),_), !, yap_hacks:choicepoint(CP,_,prolog,'$loop_spy2',5,(_;_),_),
!,
'$debugger_skip_loop_spy2'(CPs,CPs1). '$debugger_skip_loop_spy2'(CPs,CPs1).
'$debugger_skip_loop_spy2'(CPs,CPs). '$debugger_skip_loop_spy2'(CPs,CPs).

View File

@ -112,7 +112,7 @@ mode and the existing spy-points, when the debugger is on.
print_message(warning,no_match(nospy(M:F/N))) print_message(warning,no_match(nospy(M:F/N)))
). ).
'$do_suspy'(S, F, N, T, M) :- '$do_suspy'(S, F, N, T, M) :-
'$system_predicate'(T,M), '$is_system_predicate'(T,M),
'$predicate_flags'(T,M,F,F), '$predicate_flags'(T,M,F,F),
F /\ 0x118dd080 =\= 0, F /\ 0x118dd080 =\= 0,
( S = spy -> ( S = spy ->
@ -486,7 +486,7 @@ notrace(G) :-
current_prolog_flag( debug, false ) current_prolog_flag( debug, false )
-> true -> true
; ;
'$system_predicate'(G,Module) '$is_opaque_zpredicate'(G,Module)
-> true -> true
; ;
'$is_private'(G,Module) '$is_private'(G,Module)
@ -507,7 +507,7 @@ notrace(G) :-
GN > GoalNo GN > GoalNo
). ).
'$creep_is_on_at_entry'(G,M,_GoalNo) :- '$creep_is_on_at_entry'(G,M,_GoalNo) :-
\+ '$system_predicate'(G,M), \+ '$is_system_predicate'(G,M),
'__NB_getval__'('$debug_state',state(Step, _GN, Spy,_), fail), '__NB_getval__'('$debug_state',state(Step, _GN, Spy,_), fail),
( (
Step \= zip Step \= zip

View File

@ -382,8 +382,8 @@ live :-
write_term(user_error,Answ,Opts). write_term(user_error,Answ,Opts).
'$another' :- '$another' :-
format(user_error,' ? ',[]),
'$clear_input'(user_input), '$clear_input'(user_input),
prompt1(' ? '),
get_code(user_input,C), get_code(user_input,C),
'$do_another'(C). '$do_another'(C).
@ -703,7 +703,7 @@ write_query_answer( Bindings ) :-
'$loop'(Stream,exo) :- '$loop'(Stream,exo) :-
prolog_flag(agc_margin,Old,0), prolog_flag(agc_margin,Old,0),
prompt1(': '), prompt(_,' '), prompt1(': '), prompt(_,'| '),
source_module(OldModule,OldModule), source_module(OldModule,OldModule),
repeat, repeat,
'$system_catch'(dbload_from_stream(Stream, OldModule, exo), '$db_load', Error, '$system_catch'(dbload_from_stream(Stream, OldModule, exo), '$db_load', Error,
@ -712,7 +712,7 @@ write_query_answer( Bindings ) :-
!. !.
'$loop'(Stream,db) :- '$loop'(Stream,db) :-
prolog_flag(agc_margin,Old,0), prolog_flag(agc_margin,Old,0),
prompt1(': '), prompt(_,' '), prompt1(': '), prompt(_,'| '),
source_module(OldModule,OldModule), source_module(OldModule,OldModule),
repeat, repeat,
'$system_catch'(dbload_from_stream(Stream, OldModule, db), '$db_load', Error, user:'$LoopError'(Error, db) '$system_catch'(dbload_from_stream(Stream, OldModule, db), '$db_load', Error, user:'$LoopError'(Error, db)
@ -1017,7 +1017,7 @@ log_event( String, Args ) :-
DBON = true DBON = true
-> ->
( (
'__NB_getval__'('$debug_state',state(_, _, _, _,on), fail), '__NB_getval__'('$debug_state',state( _, _, _,on), fail),
( (
var(LF) var(LF)
-> ->