There is an issue with the gui tracer, i.e. the debugger.
I am using the DCG feature.
With some of my DCG clauses, the gui tracer can’t display the source code.
Instead it shows a decompiled listing of the clause.
E.g. it will show “decompiled listing of 11th clause of question/3”.
I noticed that the clauses that it can’t display properly all contain “{once( … )}”.
When I delete the “once”, that clause can be displayed correctly by the tracer.
Its this that the tracer can’t handle:
“… --> …, {once( ( … ; … ) )}, …”.
I am using SWI Prolog version 8.1.3-31-g32d2d0a1d.
I use the DCG with {} regularly and while I do sometimes see the problem you note, I don’t think that it is that. If the source code is edited without being reloaded that can cause the problem you see and if the DCG is to long an complex that sometimes seems to be a problem.
My setup is using Windows 10 with Visual Studio Code and using swipl.exe as the top level.
When the problem occurs I first save the source code again and then using swipl menu File → Reload modified files, and start a trace run again from the start. If that doesn’t work I restart swipl and that usually works. Can’t recall a situation where it just would not get resync with the code after trying a few things.
If I see the tracer is not displaying the source code of one clause, then I save all my source files in my editor, and restart SWI prolog, then start the tracer. This normally fixes it.
But the problem with “{once(…)}” was not fixed by restarting prolog. This seems to be a seperate problem from the problem of the source code being edited after starting SWI Prolog.
This week I noticed that there were three separate clauses that the tracer could not display the source code of, and all three clauses contained “{once( … )}”.
I also noticed that the problem vanished when I commented out a line that contained “{once( … )}”.
Eric wrote: “if the DCG is too long and complex that sometimes seems to be a problem”.
I tried removing the “once” in “once( ( A ; B ) )”, to make it “( A ; B )”, and this fixed the problem, for that clause.
When I removed the “once”, that made it simpler, so that could be why that worked. So I can’t be sure that the problem only occurs when using “{once( … )}”.
The first I believe is what you have but it seems to have more parentheses than I would use, and the second one has the extra parentheses removed.
I can repeatedly reproduce the problem as you noted with the first one, but it works as I would expect with the second one. I must note that I don’t use once/1 with my DCG or even regular Prolog which is probably why I haven’t seen the problem before.
EDIT
After adding two more examples and trying them all again, now all four are working as expected.
After shutting down swipl.exe and reloading and retrying it is back.
I agree that there is a problem and it consistently happens more with the pattern you gave, but I can’t get it to fail consistently. Hopefully someone can shed some light on this. I will work on it some more but don’t expect to find more than I have already noted.
My problem was different, when the problem occurred it was showing
a decompiled listing of the code, it was not showing the source code.
I don’t know if “retry” will help when the gui tracer is not showing the source code,
and is showing a decompiled listing of the clause.