2006-12-27 01:54:21 +00:00
|
|
|
% File : hacks.yap
|
|
|
|
% Author : Vitor Santos Costa
|
2007-01-24 10:01:40 +00:00
|
|
|
% Updated: 2007
|
2006-12-27 01:54:21 +00:00
|
|
|
% Purpose: Prolog hacking
|
|
|
|
|
|
|
|
:- module(yap_hacks, [
|
2008-02-12 17:03:59 +00:00
|
|
|
current_choicepoint/1,
|
2006-12-27 01:54:21 +00:00
|
|
|
cut_by/1,
|
2008-02-12 17:03:59 +00:00
|
|
|
cut_at/1,
|
2007-01-24 10:01:40 +00:00
|
|
|
current_choicepoints/1,
|
2007-02-13 12:35:30 +00:00
|
|
|
choicepoint/7,
|
2007-01-24 10:01:40 +00:00
|
|
|
current_continuations/1,
|
|
|
|
continuation/4,
|
2008-02-12 17:03:59 +00:00
|
|
|
stack_dump/0,
|
|
|
|
stack_dump/1
|
2006-12-27 01:54:21 +00:00
|
|
|
]).
|
|
|
|
|
2007-01-24 10:01:40 +00:00
|
|
|
stack_dump :-
|
2008-02-12 17:03:59 +00:00
|
|
|
stack_dump(-1).
|
|
|
|
|
|
|
|
stack_dump(Max) :-
|
2007-01-24 10:01:40 +00:00
|
|
|
current_choicepoints(CPs),
|
|
|
|
current_continuations([Env|Envs]),
|
|
|
|
continuation(Env,_,ContP,_),
|
|
|
|
length(CPs, LCPs),
|
|
|
|
length(Envs, LEnvs),
|
|
|
|
format(user_error,'~n~n~tStack Dump~t~40+~n~nAddress~tChoiceP~16+ Cur/Next Clause Goal~n',[LCPs,LEnvs]),
|
2008-08-25 15:20:18 +01:00
|
|
|
'$hacks':display_stack_info(CPs, Envs, Max, ContP, StackInfo, []),
|
2008-02-22 15:08:37 +00:00
|
|
|
run_formats(StackInfo, user_error).
|
2007-01-24 10:01:40 +00:00
|
|
|
|
2008-02-22 15:08:37 +00:00
|
|
|
run_formats([], _).
|
|
|
|
run_formats([Com-Args|StackInfo], Stream) :-
|
|
|
|
format(Stream, Com, Args),
|
|
|
|
run_formats(StackInfo, user_error).
|
2007-01-24 10:01:40 +00:00
|
|
|
|
2006-12-27 01:54:21 +00:00
|
|
|
|
|
|
|
|