4
votes

How do I hide a module or a whole package from tracing. I have this query, and I want to step through it, but I am not interested in what CLP(X) does, only at what point something fails in my query.

?- X in 0..5, X in 7..8.
fail.

?- dif(A, 1), A = 1.
fail.

If I run this query in SWI-Prolog it shows me every nifty detail of the module CLP(X), not only some inlining related to the constraints but also everything else from CLP(X):

Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.2)

?- trace.
true.

[trace]  ?- X in 0..5, X in 7..8.
   Call: (9) clpfd:clpfd_in(_2662, 0..5) ? creep
   Call: (10) clpfd:fd_variable(_2662) ? creep
   Call: (11) var(_2662) ? creep
   Exit: (11) var(_2662) ? creep
   Call: (11) true ? creep
   Exit: (11) true ? creep

[trace]  ?- dif(A, 1), A=1.
   Call: (9) dif:dif(_3044, 1) ? creep
   Exit: (9) dif:dif(_3410{dif = ...}, 1) ? creep
   Call: (9) _3410{dif = ...}=1 ? creep

Is there a way to suppress the internals of CLP(X). For example if I use another Prolog system, I don't see any internals of the CLP(X) (Preview):

Jekejeke Prolog 3, Development Environment 1.3.6

?- trace.
Yes

?- X in 0..5, X in 7..8.
    0 Call X in 0..5 ? 
    0 Exit X in 0..5 ? 
    0 Call X in 7..8 ? 
    0 Fail X in 7..8 ? 
No

?- neq(A, 1), A = 1.
    0 Call neq(A, 1) ? 
    0 Exit neq(A, 1) ? 
    0 Call A = 1 ? 
    0 Fail A = 1 ? 
No

Is there an elegant way to disable a module/package, but nevertheless see top-level calls/exits from the module/packge?

1
Tracing clpfd leads to nowhere, consider instead to produce generalizations and specialization! - false
Most of the time it will show that labeling fails. - false
I often would like to use trace. and hide just clpfd. It's not like all the work is happening in clpfd. It looks like the recommended thing is to not use trace. and instead use trace(mypred/2, +all). - Daniel Lyons
SICStus has the directive module/3 with a third parameter [hidden(true)] for such purpose - false
@false take note of the swi-prolog tag there. - Daniel Lyons

1 Answers

-1
votes

There are various ways to control the debugging process in SWI-Prolog, see http://www.swi-prolog.org/pldoc/man?section=debugging. In this can you can use the skip option, which will "skip to exit port of this call or wake port". The option is activated by pressing s during the trace intead of Enter.

In this case skipping over all calls results in a trace which is very similar to your Jekejeke example (although a bit less nicely formatted):

?- use_module(library(clpfd)).
true.

?- trace.
true.

[trace]  ?- X in 0..5, X in 7..8.
   Call: (9) clpfd:clpfd_in(_7788, 0..5) ? skip
   Exit: (9) clpfd:clpfd_in(_8226{clpfd = ...}, 0..5) ? creep
   Call: (9) integer(_8226{clpfd = ...}) ? skip
   Fail: (9) integer(_8226{clpfd = ...}) ? creep
   Call: (9) clpfd:clpfd_in(_8226{clpfd = ...}, 7..8) ? skip
   Fail: (9) clpfd:clpfd_in(_8226{clpfd = ...}, 7..8) ? creep
false.