How to trace "system" predicates/hide my predicates from tracing?

In trace mode, it appears as though “system” predicates are not traced:

foo(X) :- atom(X).

?- trace.

[trace]  ?- foo(a).
   Call: (10) foo(a) ? creep
   Exit: (10) foo(a) ? creep

How is this accomplished? Is there a way to turn this off (so I can see the system calls)? And is there conversely a way to hide my own predicates like that?

Jan W. will no doubt fill in the details I miss but think about what is happening. You are using a Prolog tracer written as a Meta-interpreter, or something that smells of a meta-interpreter. Now the meta-interpreter only knows about Prolog and not about C code. The “system” predicates are the predicates that are implemented as C code. So if you want to trace them then you will have to switch over to looking at the code running at the C level. I have never done this so don’t ask me questions.

For more details see: Debugging and profiling foreign code (valgrind)

You can trace through (Prolog) system predicates after

?- set_prolog_flag(access_level, system).

This doesn’t always work nice, especially the graphical debugger sometimes gets into debugging itself and producing something completely not understandable or crashing.

Source file can turn their predicates into black boxes using

:- set_prolog_flag(generate_debug_info, false).

That might only work properly for module files. Not sure.

1 Like