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

View File

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

View File

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

View File

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