Backtracking issue on fail

Great answer about using the debugger.

Maybe I missed it but one thing I really like about using gtrace/0 is that if you have a predicate that fails deeply down in a call chain but don’t want to have to spend the time to find it by single stepping every line, instead single step the code at the highest level until a predicate fails, then redo that step, step into the next level and repeat as much as needed. This way as you are stepping down into the code you are understanding the context of what is happening as you step down.

With DCGs sometimes these bugs are at times 15 levels or more deep but being able to understand the context while stepping in means that when I get to the root cause I don’t have to rack my brain trying to align a stack trace with pages of code. The line with the bug is there, I know all of the calls in the stack trace, and the bound values of the variables are present along with the variables that are unbound. It doesn’t get much better.