How to interrupt prolog execution

Hi, sometimes prolog gets into an infinite loop and it keeps on tunning until it runs out of stack. Is there any way to stop the execution so I can see what’s going on?
Regards, John

Use trace/0 or gtrace/0.

ctrl-C
should get you a prompt, at which point you can reply with s (for a stack trace) or t to trace execution. If this doesn’t work (e.g., you run out of stack before you can hit ctrl-C), you can set spy-points and the start tracing.

Some more details:
https://www.swi-prolog.org/pldoc/man?section=debugoverview
https://www.swi-prolog.org/pldoc/man?section=debugger

1 Like