Debugging: Tracing the Execution of a Specific Goal

That isn’t really provided. There are two alternatives. If you can point at a specific place in the code you can use the built-in editor facilities to place a break point inside some clause. So, if there is a predicate like this:

p(X) :-
    var(X),
    do_something(X).
9(X) :-
   ...

You can put the cursor on do_something and use the menu Prolog/break at

If that doesn’t help, you simple add this to your code at the place where you want a conditional break and run make/0.

    (some_condition -> gtrace ; true),

That may seem crude, but it works quite ok, especially if you use version control so you can easily check which debug statements you have added and/or reset the source.

With the recently added wrap_predicate/4 we could add conditional spy points easily. Not sure what it is worth though.

1 Like