4.39 Debugging and Tracing Programs
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Debugging and Tracing Programs
          • trace/0
          • tracing/0
          • notrace/0
          • trace/1
          • trace/2
          • notrace/1
          • debug/0
          • nodebug/0
          • debugging/0
          • spy/1
          • nospy/1
          • nospyall/0
          • leash/1
          • visible/1
          • unknown/2
          • style_check/1
    • Packages
Availability::- use_module(library(prolog_trace)).(can be autoloaded)
Sourcetrace(+Pred, +Ports)
Put a trace point on all predicates satisfying the predicate specification Pred. Ports is a list of port names (call, redo, exit, fail). The atom all refers to all ports. If the port is preceded by a - sign, the trace point is cleared for the port. If it is preceded by a +, the trace point is set. Tracing a predicate is achieved by wrapping the predicate using wrap_predicate/4.

Each time a port (of the 4-port model) is passed that has a trace point set, the goal is printed. Unlike trace/0, however, the execution is continued without asking for further information. Examples:

?- trace(hello). Trace all ports of hello with any arity in any module.
?- trace(foo/2, +fail). Trace failures of foo/2 in any module.
?- trace(bar/1, -all). Stop tracing bar/1.