24 current_choice_points/1,
26 current_continuations/1,
59 current_choice_points(
CPs),
60 current_continuations([
Env|Envs]),
61 continuation(
Env,
_,
ContP,
_),
64 format(user_error,
'~n~n~tStack Dump~t~40+~n~nAddress~tChoiceP~16+ Cur/Next Clause Goal~n',[
LCPs,
LEnvs]),
65 display_stack_info(
CPs,
Envs,
Max,
ContP).
67display_stack_info(
CPs,
Envs,
Lim,
PC)
:-
68 display_stack_info(
CPs,
Envs,
Lim,
PC,
Lines,[]),
71 run_formats(
Lines, user_error).
75run_formats([
Com-Args|StackInfo],
Stream)
:-
76 format(
Stream,
Com,
Args),
77 run_formats(
StackInfo,
Stream).
79code_location(
Info,
Where,
Location)
:-
81 pred_for_code(
Where,
Name,
Arity,
Mod,
Clause),
82 construct_code(
Clause,
Name,
Arity,
Mod,
Info,
Location).
83code_location(
Info,
_,
Info).
85construct_code(
-1,
Name,
Arity,
Mod,
Where,
Location)
:- construct_code,
88 atom_concat([
Where,
' at ',
Mod,
':',
Name,
'/',
ArityAtom,
' at indexing code'],
Location).
89construct_code(
0,
_,
_,
_,
Location,
Location)
:- construct_code.
90construct_code(
Cl,
Name,
Arity,
Mod,
Where,
Location)
:-
95 atom_concat([
Where,
' at ',
Mod,
':',
Name,
'/',
ArityAtom,
' (clause ',
ClAtom,
')'],
Location).
97'$prepare_loc'(
Info,
Where,
Location)
:- integer(
Where),
integer,
98 pred_for_code(
Where,
Name,
Arity,
Mod,
Clause),
99 '$construct_code'(
Clause,
Name,
Arity,
Mod,
Info,
Location).
100'$prepare_loc'(
Info,
_,
Info).
102display_pc(
PC,
PP,
Source)
-->
104 {
pred_for_code(
PC,
Name,
Arity,
Mod,
Clause) },
105 pc_code(
Clause,
PP,
Name,
Arity,
Mod,
Source).
107pc_code(
0,
_PP,
_Name,
_Arity,
_Mod,
'top level or system code' - [])
--> pc_code.
108pc_code(
-1,
_PP,
Name,
Arity,
Mod,
'~a:~q/~d' - [
Mod,
Name,
Arity])
--> pc_code,
111 clause_property(
Ref, file(
File)),
112 clause_property(
Ref, line_count(
Line)) },
113 [
'~a:~d:0, ' - [
File,
Line] ].
114pc_code(
Cl,
Name,
Arity,
Mod,
'clause ~d for ~a:~q/~d'-[
Cl,
Mod,
Name,
Arity])
-->
118 clause_property(
Ref, file(
File)),
119 clause_property(
Ref, line_count(
Line)) },
120 [
'~a:~d:0, ' - [
File,
Line] ].
122display_stack_info(
_,
_,
0,
_)
--> display_stack_info.
123display_stack_info([],[],
_,
_)
--> [].
124display_stack_info([
CP|CPs],[],
I,
_)
-->
127 display_stack_info(
CPs,[],
I1,
_).
128display_stack_info([],[
Env|Envs],
I,
Cont)
-->
129 show_env(
Env,
Cont,
NCont),
131 display_stack_info([],
Envs,
I1,
NCont).
132display_stack_info([
CP|LCPs],[
Env|LEnvs],
I,
Cont)
-->
134 yap_hacks
:continuation(
Env,
_,
NCont,
CB),
137 ( {
CP == Env,
CB < CP }
->
141 display_stack_info(
LCPs,
LEnvs,
I1,
NCont)
145 display_stack_info(
LCPs,[
Env|LEnvs],
I1,
Cont)
147 show_env(
Env,
Cont,
NCont),
148 display_stack_info([
CP|LCPs],
LEnvs,
I1,
NCont)
151show_cp(
CP,
Continuation)
-->
152 { yap_hacks
:choicepoint(
CP,
Addr,
Mod,
Name,
Arity,
Goal,
ClNo) },
155 {
scratch_goal(
Name,
Arity,
Mod,
Caller) },
156 [
'0x~16r~t*~16+ ~d~16+ ~q ~n'-
157 [
Addr,
ClNo,
Caller] ]
160 [
'0x~16r~t *~16+~a ~d~16+ ~q:' -
161 [
Addr,
Continuation,
ClNo,
Mod]]
163 {
prolog_flag( debugger_print_options,
Opts) },
164 {
clean_goal(
Goal,
Mod,
G)},
167show_env(
Env,
Cont,
NCont)
-->
169 yap_hacks
:continuation(
Env,
Addr,
NCont,
_),
170 format(
'0x~16r 0x~16r~n',[
Env,
NCont]),
171 format
:cp_to_predicate(
Cont,
Mod,
Name,
Arity,
ClId)
173 [
'0x~16r~t ~16+ ~d~16+ ~q:' -
175 {
scratch_goal(
Name,
Arity,
Mod,
G)},
176 {
prolog_flag( debugger_print_options,
Opts) },
189 Interval == 0,
virtual_alarm,
190 '$virtual_alarm'(
0,
0,
Left0,
_),
196 '$virtual_alarm'(
Interval,
0,
Left,
_).
199 '$virtual_alarm'(
Interval,
USecs,
Left,
LUSecs).
203alarm(+ Seconds,+ Callable,+ OldAlarm)
on_signal(+ Signal,? OldAction,+ Callable)
virtual_alarm(+Interval, 0:Goal, -Left)
atom_codes(?Atom, ?Codes)