This commit is contained in:
Vítor Santos Costa 2018-04-20 14:59:17 +01:00
parent 11dae5653e
commit c7995f276c
14 changed files with 186 additions and 48 deletions

View File

@ -1233,8 +1233,15 @@ static Int creep_step(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod)
return rc;
}
static Int execute_nonstop(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod)
*/
/**
* @brief Two argument version of non-interruptible execution: this will
* ignore signals including debugging requests.
*
* @return Int succeeds if it can transfer control.
*/
static Int execute_nonstop(USES_REGS1) {
Term t = Deref(ARG1);
Term mod = Deref(ARG2);
unsigned int arity;
@ -1309,6 +1316,20 @@ static Int execute_nonstop(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod)
}
}
/**
* @brief One argument version of non-interruptible execution: this will
* ignore signals including debugging requests.
*
* @return Int succeeds if it can transfer control.
*/
static Int execute_nonstop1(USES_REGS1)
{
ARG2 = CurrentModule;
return execute_nonstop( PASS_REGS1 );
}
static Int execute_0(USES_REGS1) { /* '$execute_0'(Goal) */
Term mod = CurrentModule;
Term t = Yap_YapStripModule(Deref(ARG1), &mod);
@ -2233,6 +2254,7 @@ void Yap_InitExecFs(void) {
#endif
Yap_InitCPred("$execute0", 2, execute0, NoTracePredFlag);
Yap_InitCPred("$execute_nonstop", 2, execute_nonstop, NoTracePredFlag);
Yap_InitCPred("$execute_nonstop", 1, execute_nonstop1, NoTracePredFlag);
Yap_InitCPred("$creep_step", 2, creep_step, NoTracePredFlag);
Yap_InitCPred("$execute_clause", 4, execute_clause, NoTracePredFlag);
Yap_InitCPred("$current_choice_point", 1, current_choice_point, 0);

View File

@ -17,7 +17,7 @@
/** @file YapFlags.h
@addtogroup Flags
@addtogroup YAPFlags
*/
#ifndef YAP_FLAGS_H

View File

@ -18,10 +18,12 @@
/** @file YapLFlagInfo.h
@addtogroup Flags
@addtogroup YAPFlags
*/
/** + `autoload`: set the system to look for undefined procedures */
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false" , NULL ),
/** + `read-only flag, that tells if Prolog is in an inner top-level */
YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
YAP_FLAG( CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true" , NULL ), /** + `call_counting`

View File

@ -33,6 +33,8 @@ SET (CMAKE_HTML_EXTRA_
endforeach(i ${CMAKE_HTML_EXTRA_})
set(DOCS_EXCLUDE_
${CMAKE_SOURCE_DIR}/build
${CMAKE_SOURCE_DIR}/Debug
${CMAKE_SOURCE_DIR}/packages/jpl
${CMAKE_SOURCE_DIR}/packages/swig
${CMAKE_SOURCE_DIR}/packages/myddas/sqlite3/src
@ -47,7 +49,6 @@ ${CMAKE_SOURCE_DIR}/packages/gecode/3.7.0
${CMAKE_SOURCE_DIR}/packages/gecode/3.6.0
${CMAKE_SOURCE_DIR}/packages/gecode/dev
${CMAKE_SOURCE_DIR}/C/traced_absmi_insts.h
${CMAKE_SOURCE_DIR}/H/locals.h
${CMAKE_SOURCE_DIR}/H/globals.h
${CMAKE_SOURCE_DIR}/packages/cplint
${CMAKE_SOURCE_DIR}/packages/CLPBN/examples

View File

@ -816,7 +816,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = /home/vsc/github/yap-6.3/packages/jpl /home/vsc/github/yap-6.3/packages/swig /home/vsc/github/yap-6.3/packages/myddas/sqlite3/src /home/vsc/github/yap-6.3/packages/gecode/4.4.0 /home/vsc/github/yap-6.3/packages/gecode/4.2.1 /home/vsc/github/yap-6.3/packages/gecode/4.2.0 /home/vsc/github/yap-6.3/packages/gecode/4.0.0 /home/vsc/github/yap-6.3/packages/gecode/3.7.3 /home/vsc/github/yap-6.3/packages/gecode/3.7.2 /home/vsc/github/yap-6.3/packages/gecode/3.7.1 /home/vsc/github/yap-6.3/packages/gecode/3.7.0 /home/vsc/github/yap-6.3/packages/gecode/3.6.0 /home/vsc/github/yap-6.3/packages/gecode/dev /home/vsc/github/yap-6.3/C/traced_absmi_insts.h /home/vsc/github/yap-6.3/H/locals.h /home/vsc/github/yap-6.3/H/globals.h /home/vsc/github/yap-6.3/packages/cplint /home/vsc/github/yap-6.3/packages/CLPBN/examples /home/vsc/github/yap-6.3/packages/CLPBN/horus /home/vsc/github/yap-6.3/packages/prosqlite /home/vsc/github/yap-6.3/packages/pyswip /home/vsc/github/yap-6.3/packages/yap-lbfgs/liblbfgs-1.10 /home/vsc/github/yap-6.3/library/dialect/swi/os /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode3.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4.yap /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap_hand_written.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap_hand_written.yap */CMakeFiles/* *~ */
EXCLUDE = /home/vsc/github/yap-6.3/build /home/vsc/github/yap-6.3/Debug /home/vsc/github/yap-6.3/packages/jpl /home/vsc/github/yap-6.3/packages/swig /home/vsc/github/yap-6.3/packages/myddas/sqlite3/src /home/vsc/github/yap-6.3/packages/gecode/4.4.0 /home/vsc/github/yap-6.3/packages/gecode/4.2.1 /home/vsc/github/yap-6.3/packages/gecode/4.2.0 /home/vsc/github/yap-6.3/packages/gecode/4.0.0 /home/vsc/github/yap-6.3/packages/gecode/3.7.3 /home/vsc/github/yap-6.3/packages/gecode/3.7.2 /home/vsc/github/yap-6.3/packages/gecode/3.7.1 /home/vsc/github/yap-6.3/packages/gecode/3.7.0 /home/vsc/github/yap-6.3/packages/gecode/3.6.0 /home/vsc/github/yap-6.3/packages/gecode/dev /home/vsc/github/yap-6.3/C/traced_absmi_insts.h /home/vsc/github/yap-6.3/H/globals.h /home/vsc/github/yap-6.3/packages/cplint /home/vsc/github/yap-6.3/packages/CLPBN/examples /home/vsc/github/yap-6.3/packages/CLPBN/horus /home/vsc/github/yap-6.3/packages/prosqlite /home/vsc/github/yap-6.3/packages/pyswip /home/vsc/github/yap-6.3/packages/yap-lbfgs/liblbfgs-1.10 /home/vsc/github/yap-6.3/library/dialect/swi/os /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode3.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4.yap /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap_hand_written.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap_hand_written.yap */CMakeFiles/* *~ */
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded

65
docs/checkpl.yap Normal file
View File

@ -0,0 +1,65 @@
:- use_module(library(lists)).
:- use_module(library(lineutils)).
:- initialization(main).
main :-
%system('find . \( -name '*.pl' -o -name '*.yap' -o -name '*.c' -o -name '*.h' -o -name '*.cpp' -o -name '*.hh' \) -type f -print | xargs grep '@defgroup\|@ingroup\|@addtogroup\|@{|@}').
file_filter_with_start_end( docs, tmp, add2graph, initgraph, checkgraph).
initgraph(_,_).
:- dynamic node/3, edge/3, e_b_n/3.
checkgraph(_,_) :-
e_b_n(F,KN,_C),
node(KF,KN,_),
add_edge(KF, F, KN),
fail.
checkgraph(_,_) :-
listing(node),
listing(edge).
add2graph(Line, _Out) :-
split( Line, "% \t/*:", [File, Job, Name|_]),
append( _, L, Line),
append(Name, R, L),
dispatch( Name, File, Job, R).
dispatch( Name, File, "defgroup", Comment):-
atom_codes(KN, Name),
atom_codes(KF, File),
atom_codes(C, Comment),
add_node(KF, KN,C).
dispatch( Name, File, "addtogroup", Comment):-
atom_codes(KN, Name),
atom_codes(KF, File),
atom_codes(C, Comment),
add_node_edge(KF, KN,C).
dispatch( Name, File, "ingroup", Comment):-
atom_codes(KN, Name),
atom_codes(KF, File),
atom_codes(C, Comment),
add_edge(KF, KN,C).
add_node(F, K,_C) :-
node(_,K,_),
throw( repeat(F:K) ).
add_node(F, K,C) :-
assert(node(F,K,C)).
add_node_edge(F, K,_C) :-
node(F1,K,_),
!,
assert(edge(F1,F,K)).
add_node_edge(F, K,C) :-
assert(node(F,K,C)).
add_edge(F, K,_C) :-
node(F1,K,_),
!,
assert(edge(F1,F,K)).
add_edge(F, K,C) :-
assert(e_b_n(F,K,C)).

View File

@ -17,7 +17,7 @@ Porto.
The manual is organised as follows:
+ @subpage install
+ @subpage INSTALL
+ @subpage run

View File

@ -816,7 +816,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = /home/vsc/github/yap-6.3/packages/jpl /home/vsc/github/yap-6.3/packages/swig /home/vsc/github/yap-6.3/packages/myddas/sqlite3/src /home/vsc/github/yap-6.3/packages/gecode/4.4.0 /home/vsc/github/yap-6.3/packages/gecode/4.2.1 /home/vsc/github/yap-6.3/packages/gecode/4.2.0 /home/vsc/github/yap-6.3/packages/gecode/4.0.0 /home/vsc/github/yap-6.3/packages/gecode/3.7.3 /home/vsc/github/yap-6.3/packages/gecode/3.7.2 /home/vsc/github/yap-6.3/packages/gecode/3.7.1 /home/vsc/github/yap-6.3/packages/gecode/3.7.0 /home/vsc/github/yap-6.3/packages/gecode/3.6.0 /home/vsc/github/yap-6.3/packages/gecode/dev /home/vsc/github/yap-6.3/C/traced_absmi_insts.h /home/vsc/github/yap-6.3/H/locals.h /home/vsc/github/yap-6.3/H/globals.h /home/vsc/github/yap-6.3/packages/cplint /home/vsc/github/yap-6.3/packages/CLPBN/examples /home/vsc/github/yap-6.3/packages/CLPBN/horus /home/vsc/github/yap-6.3/packages/prosqlite /home/vsc/github/yap-6.3/packages/pyswip /home/vsc/github/yap-6.3/packages/yap-lbfgs/liblbfgs-1.10 /home/vsc/github/yap-6.3/library/dialect/swi/os /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode3.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4.yap /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap_hand_written.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap_hand_written.yap */CMakeFiles/* *~ */
EXCLUDE = /home/vsc/github/yap-6.3/build /home/vsc/github/yap-6.3/Debug /home/vsc/github/yap-6.3/packages/jpl /home/vsc/github/yap-6.3/packages/swig /home/vsc/github/yap-6.3/packages/myddas/sqlite3/src /home/vsc/github/yap-6.3/packages/gecode/4.4.0 /home/vsc/github/yap-6.3/packages/gecode/4.2.1 /home/vsc/github/yap-6.3/packages/gecode/4.2.0 /home/vsc/github/yap-6.3/packages/gecode/4.0.0 /home/vsc/github/yap-6.3/packages/gecode/3.7.3 /home/vsc/github/yap-6.3/packages/gecode/3.7.2 /home/vsc/github/yap-6.3/packages/gecode/3.7.1 /home/vsc/github/yap-6.3/packages/gecode/3.7.0 /home/vsc/github/yap-6.3/packages/gecode/3.6.0 /home/vsc/github/yap-6.3/packages/gecode/dev /home/vsc/github/yap-6.3/C/traced_absmi_insts.h /home/vsc/github/yap-6.3/H/globals.h /home/vsc/github/yap-6.3/packages/cplint /home/vsc/github/yap-6.3/packages/CLPBN/examples /home/vsc/github/yap-6.3/packages/CLPBN/horus /home/vsc/github/yap-6.3/packages/prosqlite /home/vsc/github/yap-6.3/packages/pyswip /home/vsc/github/yap-6.3/packages/yap-lbfgs/liblbfgs-1.10 /home/vsc/github/yap-6.3/library/dialect/swi/os /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap.cc /home/vsc/github/yap-6.3/packages/gecode/gecode3.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4.yap /home/vsc/github/yap-6.3/packages/gecode/gecode3_yap_hand_written.yap /home/vsc/github/yap-6.3/packages/gecode/gecode4_yap_hand_written.yap */CMakeFiles/* *~ */
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded

View File

@ -15,10 +15,13 @@
* *
*************************************************************************/
%% @{
/**
@file arrays.yap
@addtogroup YAPArrays
@{
*/
%
% These are the array built-in predicates. They will only work if

View File

@ -284,28 +284,30 @@ be lost.
/**
* @pred $trace( +Goal )
*
* This launches a goal from the debugger with the call. It must:
* - disable user interaction;
* - verify whether debugging is still ok;
* - enter the debugger core.
* The top gated_call should set up creeping for the next call.
*
* @param _Goal_ is the goal to be examined.
* @param _Mod_:_Goal_ is the goal to be examined.
* @return `call(Goal)`
*/
% handle suspended goals
% take care with hidden goals.
%
% $trace may be called from user code, so be careful.
'$trace'([Mod|G]) :-
'$stop_creeping'(_),
'$stop_creeping'(_),
current_prolog_flag(debug, false),
!,
'$execute_nonstop'(G,Mod).
'$trace'([Mod|G]) :-
CP is '$last_choice_pt',
gated_call(
'$debugger_input',
'$trace_query'(G, Mod, CP, not_expanded),
E,
'$continue_debugging'(E)
'$debugger_input',
'$trace_query'(G, Mod, CP, not_expanded),
E,
'$continue_debugging'(E)
).
'$continue_debugging'(_) :- !,
current_prolog_flag(debug, false).
'$continue_debugging'(exit) :- !, '$creep'.
@ -361,10 +363,12 @@ be lost.
/**
* @pred debugger_input.
* name of stream used for debugging,
* must be always connected to a tty.
*
* '$debugger_input': try to connect the debugger to an open terminal.
* set up the stream used for debugging,
* - must be interactive.
* - default is `user_input`, but /dev/tty and CONIN$ can be used directly if
* user_input is bound to a file.
*
*/
'$debugger_input' :-
stream_property(_,alias(debugger_input)),
@ -388,10 +392,13 @@ be lost.
%% @pred '$trace_query'( +G, +M, +CP, +Expanded)
%
%% debug a complex query
% debug a complex query
%
'$trace_query'(V, M, CP, _) :-
'$creep',
!,
'$call'(V,M,V,CP).
'$trace_query'(V, M, CP, _) :-
'$stop_creeping'(_),
var(V), !,
'$trace_query'(call(V), M, CP, _).
'$trace_query'(!, _, CP, _) :-
@ -459,7 +466,7 @@ be lost.
%% @pred $trace_goal( +Goal, +Module, +CallId, +CallInfo)
%%
%% Actually debugs a
%% Actuallb sy debugs a
%% goal!
'$trace_goal'(G, M, GoalNumber, _H) :-
(
@ -490,18 +497,18 @@ be lost.
'$debugger_expand_meta_call'(M:G, [], G1),
strip_module(G1, MF, NG),
gated_call(
'$enter_trace'(GoalNumber, G, M, H, _What),
'$enter_trace'(GoalNumber, G, M, H),
'$execute_nonstop'(NG,MF),
Port,
'$trace_port'(Port, GoalNumber, G, M, true, H)
).
% system_
'$trace_goal'(G, M, GoalNumber, H) :-
(
'$is_opaque_predicate'(G, M)
;
'strip_module'(M:G, prolog, _NG)
),
(
'$is_opaque_predicate'(G, M)
;
'strip_module'(M:G, prolog, _NG)
),
!,
gated_call(
'$enter_trace'(GoalNumber, G, M, H),
@ -510,12 +517,24 @@ be lost.
'$trace_port'(Port, GoalNumber, G, M, true, H)
).
'$trace_goal'(G, M, GoalNumber, H) :-
gated_call(
'$enter_trace'(GoalNumber, G, M, H),
'$debug'( GoalNumber, G, M, H),
Port,
'$trace_port'(Port, GoalNumber, G, M, true, H)
).
gated_call(
'$enter_trace'(GoalNumber, G, M, H),
'$debug'( GoalNumber, G, M, H),
Port,
'$trace_port'(Port, GoalNumber, G, M, true, H)
).
/**
* @pred '$enter_trace'(+L, 0:G, +Module, +Info)
*
* call goal: prelims
*
* @parameter _Module_:_G_
* @parameter _L_ is the list of active goals
* @parameter _Info_ describes the goal
*
*/
'$enter_trace'(L, G, Module, Info) :-
/* get goal no. */
( var(L) ->
@ -543,6 +562,19 @@ be lost.
/* and save it globaly */
'__NB_setval__'('$spy_gn',L1).
/**
* @pred '$enter_trace'(+L, 0:G, +Module, +Info)
*
* call goal: setup the diferrent cases
* - zip, just run through
* - source, call an interpreter
* - compiled code: try black magic.
*
* @parameter _Module_:_G_
* @parameter _GoalNumber_ identifies the active goal
* @parameter _Info_ describes the goal
*
*/
'$debug'(_, G, M, _H) :-
'__NB_getval__'('$debug_status',state(zip,_Border,_), fail),
!,
@ -555,12 +587,24 @@ be lost.
'$creep_step'(GoalNumber, G, M, Info).
/**
* @pred '$trace_go'(+L, 0:G, +Module, +Info)
*
* It needs to run in two separate steps:
* 1. Select a clause;
* 2. Debug it.
* We use a marker to track who we are in gated_call.
*
* @parameter _Module_:_G_
* @parameter _GoalNumber_ identifies the active goal
* @parameter _Info_ describes the goal
*
*/
'$trace_go'(GoalNumber, G, M, Info) :-
X=marker(_,M,G),
X=marker(_,M,G),
CP is '$last_choice_pt',
clause(M:G, Cl, _),
'$retry_clause'(GoalNumber, G, M, Info, X),
'$retry_clause'(GoalNumber, G, M, Info, X),
'$trace_query'(Cl, M, CP, expanded).
'$creep_step'(GoalNumber, G, M, Info) :-
@ -592,7 +636,7 @@ be lost.
GoalNumber =< G0,
!,
fail.
'$re_trace_query'(forward(redo,G0), G, M, GoalNumber, H) :-
'$re_trace_query'(forward(redo,G0), G, M, GoalNumber, H) :-
GoalNumber > G0,
!,
catch(
@ -638,7 +682,7 @@ be lost.
'$TraceError'(forward(redo,_G0), _, _, _, _).
%%% - backtrack long distance
'$TraceError'(forward(fail,_G0),GoalNumber, _, _, _) :- !,
throw(error(fail(GoalNumber))).
throw(debugger(fail,GoalNumber)).
%%%
%%% - forward through the debugger
'$TraceError'(forward('$wrapper',Event), _, _, _, _) :-

View File

@ -17,8 +17,8 @@
/**
* @file flagd.ysp
*
* @defgroup Flags Yap Flags
* @{}
* @defgroup YAPFlags Yap Flags
*
* @ingroup builtins
*
*/

View File

@ -670,6 +670,7 @@ write_query_answer( Bindings ) :-
;
'$call'(Z,CP,G0,M)
).
'$call'((X*->Y| Z),CP,G0,M) :- !,
(
'$current_choice_point'(DCP),
@ -831,7 +832,7 @@ gated_call(Setup, Goal, Catcher, Cleanup) :-
Task0 = cleanup( All, Catcher, Cleanup, Tag, true, CP0),
TaskF = cleanup( All, Catcher, Cleanup, Tag, false, CP0),
'$tag_cleanup'(CP0, Task0),
'$execute'( Goal ),
'$execute_nonstop'( Goal ),
'$cleanup_on_exit'(CP0, TaskF).
@ -965,7 +966,7 @@ catch(G, C, A) :-
).
'$catch'(_,C,A) :-
'$get_exception'(C0),
( C = C0 -> '$execute'(A) ; throw(C0) ).
( C = C0 -> '$execute_nonstop'(A, prolog) ; throw(C0) ).
% variable throws are user-handled.
'$run_catch'(G,E) :-