Strange output in console during trace regarding cached items?

I’m using: SWI-Prolog version 8.0.2.

I have no idea what caused this, but during a gtrace I got the output below in the console window. Does anyone know what these messages mean and how they got “triggered”?:

[trace] 73 ?- nlg_translate_complex_item_id(key(unlocks(room(son(youngest)))), R).
% clause_info(<clause>(0000008F6F9ED470)) (1-st clause of nlg_translate_complex_item_id/2)... 
% from nlg.pl:241 ... 
% Trying with syntax prolog
% read ...
% unified ...
% got names

% Added to info-cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% clause_info(<clause>(0000008F6B3DDE80)) (1-st clause of inspect_arguments/2)... 
% from src_text.pl:154 ... 
% Trying with syntax prolog
% read ...
% unified ...
% got names

% Added to info-cache
% clause_info(<clause>(0000008F6B3DDE80)): from cache
% clause_info(<clause>(0000008F6B3DDE80)): from cache
% clause_info(<clause>(0000008F6B3DDE80)): from cache
% clause_info(<clause>(0000008F6B40F970)) (2-nd clause of inspect_arguments/2)... 
% from src_text.pl:158 ... 
% Trying with syntax prolog
% read ...
% unified ...
% got names

% Added to info-cache
% clause_info(<clause>(0000008F6B40F970)): from cache
% clause_info(<clause>(0000008F6B40F970)): from cache
% clause_info(<clause>(0000008F6B40F970)): from cache
% clause_info(<clause>(0000008F6B3BBE80)) (4-th clause of inspect_arguments/2)... 
% from src_text.pl:169 ... 
% Trying with syntax prolog
% read ...
% unified ...
% got names

% Added to info-cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6B3BBE80)): from cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% clause_info(<clause>(0000008F6F9ED470)): from cache
% Breakpoint 2 in 1-st clause of nlg_translate_complex_item_id/2 at nlg.pl:249
% clause_info(<clause>(0000008F6F8C9FC0)) (1-st clause of nlg_translate_complex_item_id_1/2)... 
% from nlg.pl:227 ... 
% Trying with syntax prolog
% read ...
% unified ...
% got names

% Added to info-cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
% clause_info(<clause>(0000008F6F8C9FC0)): from cache
1 Like

Looks like you typed ?- debug(_). or something similar to activate the debug messages in library(prolog_clause). Try ?- list_debug_topics. or simply ?- nodebug(_)..

2 Likes

Didn’t know this one.

This one is like the Wizard of Oz; there is more behind the curtain. WiIll have to put this on my TODO list and learn the details.

library(debug): Print debug messages and test assertions

?- list_debug_topics.
---------------------------------------------
Debug Topic               Activated To
---------------------------------------------
setting                       false []
listing(source)               false []
read                          false []
clause_info                   false []
backtrace                     false []
break                         false []
socket(proxy)                 false []
autoload                      false []
codewalk(trace)               false []
codewalk                      false []
make                          false []
pldoc                         false []
markdown(overflow)            false []
markdown(emphasis)            false []
pldoc(reload)                 false []
predicate_options             false []
predicate_options(decl)       false []
arm                           false []
pldoc(man_index)              false []
html(mailman)                 false []
thread_pool(state)            false []
thread_pool(current)          false []
thread_pool                   false []
http(header)                  false []
http(request)                 false []
obsolete                      false []
cookie                        false []
http(hook)                    false []
http(transfer_encoding)       false []
http(cgi)                     false []
http(connection)              false []
http(worker)                  false []
http(keep_alive)              false []
http(error)                   false []
http(server)                  false []
http(spawn)                   false []
http_path                     false []
html(script)                  false []
http(proxy)                   false []
http(send_request)            false []
http(redirect)                false []
http(open)                    false []
http(_5096)                   false []
multipart(content)            false []
multipart(bom)                false []
post_request                  false []
post                          false []
htmlsrc                       false []
search(rank)                  false []
pldoc(cite)                   false []
format(justify)               false []
format(html)                  false []
emacs                         false []
true.
1 Like

library(debug) provides a lot of useful stuff for debugging. Notable

debug(Channel, Format, Args)

which acts as format(Format,Args) through the print_message/2 channel debug(Channel) IFF Channel has been activated using debug/1. By default the mesage end up on the console. You can redirect channels to files using e.g.

debug(http(_) > 'http.log')

Note the use of variables, which allows switching on/off sets of related de bug channels as whether or not a channel is active is decided by unification.

And the best part: if you compile with optimization enabled the debug/3 statements are removed from your code (goal_expansion maps them to true, which the compiler removes in optimized mode).

The other noteworthy primitive is assertion(:Condition) which evaluates \+ \+ Condition. On failure it prints a stack trace and will try to activate the debugger. Once again, in optimized mode this is removed.

2 Likes

In playing with list_debug_topics/0 a little more I halted my top level, then restarted it and did list_debug_topics/0 again.

?- list_debug_topics.
---------------------------------------------
Debug Topic               Activated To
---------------------------------------------
setting                       false []
listing(source)               false []
read                          false []
clause_info                   false []
backtrace                     false []
true.

Is seems that as other code is consulted more topics can be added to the list. So if you don’t get the same list as I have listed, don’t be surprised.

In this next example I consulted the code from testinput.pl

?- list_debug_topics.
---------------------------------------------
Debug Topic               Activated To
---------------------------------------------
setting                       false []
listing(source)               false []
read                          false []
clause_info                   false []
backtrace                     false []
socket(proxy)                 false []
thread_pool(state)            false []
thread_pool(current)          false []
thread_pool                   false []
html(mailman)                 false []
http(header)                  false []
http(request)                 false []
obsolete                      false []
cookie                        false []
http(hook)                    false []
http(transfer_encoding)       false []
http(cgi)                     false []
http_path                     false []
http(connection)              false []
http(worker)                  false []
http(keep_alive)              false []
http(server)                  false []
http(spawn)                   false []
http(error)                    true [user_error]
http(proxy)                   false []
http(send_request)            false []
http(redirect)                false []
http(open)                    false []
http(_498)                    false []
multipart(content)            false []
multipart(bom)                false []
post_request                  false []
post                          false []
true.

For some real working of examples using this see package HTTP

GitHub query

or see the file pengines.pl

1 Like

Note there is also a graphical tool accessible from Prolog/View debug messages from PceEmacs. It is not really good though. You can enable/disable messages and select messages in the output that belong to a given channel.

1 Like