Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trace built-in append/3 in SWI-Prolog?

I would like to trace built-in append/3 in SWI-Prolog, but am getting the result immediately and cannot see what is going on in the middle.

Is there anything I have to do to enable trace for append?

 ?- trace .
true.

[trace]  ?- append([a,b,c], [[],[2,3], b], X).
X = [a, b, c, [], [2, 3], b].
like image 884
921kiyo Avatar asked Mar 09 '23 22:03

921kiyo


1 Answers

In SWI-Prolog, the append/3 predicate is defined in the lists module, which contains the directive:

:- set_prolog_flag(generate_debug_info, false).

This SWI-Prolog proprietary directive instructs the compiler to skip tracing of any predicate definition inside the module. If you comment out the directive in the lists.pl file in your SWI-Prolog installation, you should then be able to trace calls to the append/3 predicate or any other predicate defined in the module.

like image 56
Paulo Moura Avatar answered Mar 19 '23 10:03

Paulo Moura