small improvements to debugger, prolog mode and meta-call (*->)

This commit is contained in:
Vítor Santos Costa 2013-12-10 22:58:02 +00:00
parent 795f01d125
commit e768a7e7be
7 changed files with 41 additions and 60 deletions

View File

@ -7527,7 +7527,7 @@ Yap_absmi(int inp)
/* make sure that we can still have access to our old PREG after calling user defined goals and backtracking or failing */
yamop *savedP;
LOCAL_PrologMode = UserCCallMode;
LOCAL_PrologMode |= UserCCallMode;
{
PredEntry *p = PREG->u.Osbpp.p;
@ -7539,7 +7539,7 @@ Yap_absmi(int inp)
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
}
setregs();
LOCAL_PrologMode = UserMode;
LOCAL_PrologMode &= ~UserCCallMode;
restore_machine_regs();
PREG = savedP;
}
@ -7708,7 +7708,7 @@ Yap_absmi(int inp)
#endif
SET_BB(B_YREG);
ENDCACHE_Y();
LOCAL_PrologMode = UserCCallMode;
LOCAL_PrologMode |= UserCCallMode;
ASP = YREG;
saveregs();
save_machine_regs();
@ -7716,7 +7716,7 @@ Yap_absmi(int inp)
EX = NULL;
restore_machine_regs();
setregs();
LOCAL_PrologMode = UserMode;
LOCAL_PrologMode &= ~UserCCallMode;
if (!SREG) {
FAIL();
}
@ -7748,7 +7748,7 @@ Yap_absmi(int inp)
restore_args(PREG->u.OtapFs.s);
ENDCACHE_Y();
LOCAL_PrologMode = UserCCallMode;
LOCAL_PrologMode |= UserCCallMode;
SET_ASP(YREG, E_CB*sizeof(CELL));
saveregs();
save_machine_regs();
@ -7756,7 +7756,7 @@ Yap_absmi(int inp)
EX = NULL;
restore_machine_regs();
setregs();
LOCAL_PrologMode = UserMode;
LOCAL_PrologMode &= ~UserCCallMode;
if (!SREG) {
#ifdef CUT_C
/* Removes the cut functions from the stack

View File

@ -2384,9 +2384,9 @@ run_emulator(YAP_dogoalinfo *dgi USES_REGS)
{
int out;
LOCAL_PrologMode = UserMode;
LOCAL_PrologMode &= ~(UserCCallMode|CCallMode);
out = Yap_absmi(0);
LOCAL_PrologMode = UserCCallMode;
LOCAL_PrologMode |= UserCCallMode;
return out;
}

View File

@ -172,7 +172,9 @@ do_execute(Term t, Term mod USES_REGS)
}
UNLOCK(LOCAL_SignalLock);
return CallMetaCall(ARG1, mod PASS_REGS);
} else if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
} else if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled &&
!(LOCAL_PrologMode & (AbortMode|InterruptMode|SystemMode))) {
printf("here %lx\n", LOCAL_PrologMode);
return EnterCreepMode(t, mod PASS_REGS);
}
restart_exec:

View File

@ -1840,11 +1840,20 @@ p_set_yap_flags( USES_REGS1 )
static Int
p_system_mode( USES_REGS1 )
{
Int i = IntegerOfTerm(Deref(ARG1));
if (i == 0)
LOCAL_PrologMode &= ~SystemMode;
else
LOCAL_PrologMode |= SystemMode;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
if (LOCAL_PrologMode & SystemMode)
return Yap_unify( t1, MkAtomTerm(AtomTrue));
else
return Yap_unify( t1, MkAtomTerm(AtomFalse));
} else {
Atom at = AtomOfTerm(t1);
if (at == AtomFalse)
LOCAL_PrologMode &= ~SystemMode;
else
LOCAL_PrologMode |= SystemMode;
}
return TRUE;
}
@ -2002,7 +2011,7 @@ Yap_InitCPreds(void)
Yap_InitCPred("$walltime", 2, p_walltime, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$access_yap_flags", 2, p_access_yap_flags, SafePredFlag);
Yap_InitCPred("$set_yap_flags", 2, p_set_yap_flags, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$p_system_mode", 1, p_system_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$system_mode", 1, p_system_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("abort", 0, p_abort, SyncPredFlag);
Yap_InitCPred("$break", 1, p_break, SafePredFlag);
#ifdef BEAM

View File

@ -95,7 +95,7 @@ true :- true.
'$init_consult',
% '$swi_set_prolog_flag'(break_level, 0),
% '$set_read_error_handler'(error), let the user do that
nb_setval('$system_mode',off),
'$system_mode'(true),
nb_setval('$chr_toplevel_show_store',false).
'$init_consult' :-
@ -1200,58 +1200,26 @@ catch_ball(C, C).
'$enter_system_mode' :-
'$stop_creeping',
nb_setval('$system_mode',on).
'$system_mode'(true).
'$in_system_mode' :-
'$nb_getval'('$system_mode',on,fail).
'$system_mode'(State),
State = true.
'$execute_outside_system_mode'(G,M) :-
CP is '$last_choice_pt',
'$execute_outside_system_mode'(G,M,CP).
'$execute_outside_system_mode'(V,M,_) :-
var(V), !,
call(M:V).
'$execute_outside_system_mode'(M:G, _M, CP) :- !,
'$execute_outside_system_mode'(G, M, CP).
'$execute_outside_system_mode'((G1,G2), M, CP) :- !,
'$execute_outside_system_mode'(G1, M, CP),
'$execute_outside_system_mode'(G2, M, CP).
'$execute_outside_system_mode'((G1;G2), M, CP) :- !,
(
'$execute_outside_system_mode'(G1, M, CP)
;
'$execute_outside_system_mode'(G2, M, CP)
).
'$execute_outside_system_mode'(G, M, CP) :-
'$nb_getval'('$trace', on, fail), !,
(
'$$save_by'(CP1),
'$do_spy'(G, M, CP, meta_creep),
% we may exit system mode...
( '$$save_by'(CP1),
'$exit_system_mode',
'$call'(G, CP, M:G, M),
'$$save_by'(CP2),
(CP1 == CP2 -> ! ; ( true ; '$exit_system_mode', fail ) ),
(CP1 == CP2 -> ! ; ( true ; '$exit_system_mode', fail ) ),
'$enter_system_mode'
;
'$enter_system_mode',
fail
).
'$execute_outside_system_mode'(G, M, CP) :-
(
'$$save_by'(CP1),
'$exit_system_mode',
'$call'(G, CP, M:G, M),
'$$save_by'(CP2),
(CP1 == CP2 -> ! ; ( true ; '$exit_system_mode', fail ) ),
'$enter_system_mode'
;
'$enter_system_mode',
fail
).
'$exit_system_mode' :-
nb_setval('$system_mode',off),
'$system_mode'(false),
( '$nb_getval'('$trace',on,fail) -> '$meta_creep' ; true).
'$run_at_thread_start' :-

View File

@ -401,8 +401,8 @@ use_module(M,F,Is) :-
'$extend_exports'(ContextModule, Imports)
),
( LC == 0 -> prompt(_,' |: ') ; true),
( OldMode == off -> '$exit_system_mode' ; true ),
'$exec_initialisation_goals',
( OldMode == true -> '$enter_system_mode' ; true ),
% format( 'O=~w~n', [Mod=UserFile] ),
!.
@ -436,8 +436,8 @@ use_module(M,F,Is) :-
'$get_if'(0).
'$into_system_mode'(OldMode) :-
( '$nb_getval'('$system_mode', OldMode, fail) -> true ; OldMode = off),
( OldMode == off -> '$enter_system_mode' ; true ).
'$system_mode'(OldMode),
'$system_mode'(true).
'$bind_module'(_, load_files).
'$bind_module'(Mod, use_module(Mod)).

View File

@ -193,7 +193,9 @@ trace :-
'$do_trace' :-
'$init_debugger',
'$nb_getval'('$trace', on, fail), !.
'$nb_getval'('$trace', on, fail), !,
'$start_debugging'(on),
'$creep'.
'$do_trace' :-
nb_setval('$trace',on),
'$start_debugging'(on),