I am wondering how to use the trace/1 predicate. I included the three packages mentioned in the doc, but when I then do: ?- trace( --some styff-- ) I just get that trace/1 is undefined...
In general, you need to load the packages also in the toplevel to use them in such a way.
Unfortunately, in this case it won't work. The expansion performed for the trace predicate does not work from the shell prompt. You will have to inline calls to trace in the program code.
I would advise to use the Emacs interface; debugging becomes much simpler, as the code being executed is highlighted. You can, however, debug by hand in the old style: assume you want to trace predicates in the module 'ua'; then do:
[57]> ciao Ciao-Prolog 1.9 #8: Mon May 27 19:52:33 CEST 2002 ?- debug_module(ua). {No module is selected for debugging} {Modules selected for source debugging: [ua]}
yes ?- use_module(ua).
yes ?- trace. {The debugger will first creep -- showing everything (trace)}
yes {trace} ?- make_array([2,3], A, 0). 1 1 Call: ua:make_array([2,3],_320,0) ? 2 2 Call: ua:make_array_([2,3],_320,0,init) ? 3 3 Call: ua:dope([2,3],_640) ? ....
etc... you can select several modules for source debugging. If you want to debug a file which does not have module declaration, the module to select is 'user'.
The Emacs interface issues a debug_module_source/1 call which provides more information about the file and location where the traced call is performed; this is caught by the Emacs mode and used to place a cursor in the module source (if it is available). It can also be used to trace a standalone executable by starting it from a (unix) shell withing emacs which is has been put before in Ciao listener mode (M-x ciao-inferior-mode).