• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

2.10 Overview of the Debugger
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Overview
        • Overview of the Debugger
          • The Byrd Box Model And Ports
          • Trace Mode Example
          • Trace Mode Options: leash/1 and visible/1
          • Trace Mode Commands When Paused
          • Trace Mode vs. Trace Point
          • Spy Points and Debug Mode
          • Breakpoints
          • Command Line Debugger Summary
    • Packages

2.10.3 Trace Mode Options: leash/1 and visible/1

When you enable trace mode with trace/0, the tracer will, by default, pause and wait for a command at every port it hits on every predicate. The leash/1 predicate can be used to modify the ports to pause at. This is a global setting, so changes will remain until they are changed again or SWI-Prolog is restarted. Disabling the tracer via notrace/0 doesn't affect which ports are leashed.

The leash/1 argument must start with + to add, or - to remove, followed by the name of a port such as call, exit, etc. There are special terms like all which can be used instead of manually adding or removing every port.

To stop only at the fail port, use leash/1 like this:

?- leash(-all).
true.

?- leash(+fail).
true.

?- trace.
true.

[trace]  ?- noun(X, rock), adjective(X, color, red).
   Call: (11) noun(_3794, rock)
   Call: (12) is_a(_3794, rock)
   Exit: (12) is_a(rock1, rock)
   Exit: (11) noun(rock1, rock)
   Call: (11) adjective(rock1, color, red)
   Call: (12) color(rock1, red)
   Exit: (12) color(rock1, red)
   Exit: (11) adjective(rock1, color, red)
X = rock1 ;
   Redo: (12) is_a(_3794, rock)
   Exit: (12) is_a(rock2, rock)
   Exit: (11) noun(rock2, rock)
   Call: (11) adjective(rock2, color, red)
   Call: (12) color(rock2, red)
   Fail: (12) color(rock2, red) ? creep
   Fail: (11) adjective(rock2, color, red) ? creep
false.

Now, only the lines that start with "Fail:" have "creep" after them because that was the only time the tracer paused for a command. To never pause and just see all the traces, use leash(-all) and don't turn any ports back on.

The default ports are still printed out because a different setting, visible/1, controls which ports are printed. visible/1 takes the same form of argument as leash/1. To only stop and show the fail port, use leash/1 and visible/1 like this:

?- leash(-all).
true.

?- leash(+fail).
true.

?- visible(-all).
true.

?- visible(+fail).
true.

?- trace.
true.

[trace]  ?- noun(X, rock), adjective(X, color, red).
X = rock1 ;
   Fail: (12) color(rock2, red) ? creep
   Fail: (11) adjective(rock2, color, red) ? creep
false.

ClioPatria (version V3.1.1-51-ga0b30a5)