Small bug in the gui tracer

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.


Martin.

1 Like

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.

Thank you for your reply Eric.

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( … )}”.

Has anyone else noticed a similar problem?


Martin.

I did a very basic test based on your example “… --> …, {once( ( … ; … ) )}, …”.

test_clause_1 -->
    {
        once(
            (
                true
            ;
                false
            )
        )
    }.

test_clause_2 -->
    {
        once(
                true
            ;
                false
        )
    }.

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.

test_clause_3 -->
    {
        once(
                (
                    true,
                    true
                )
                ;
                (
                    true,
                    false
                )
        )
    }.

test_clause_4 -->
    {
        ((
            true
        ;
            false
        ))
    }.

test :-
    Input = "ABC",
    string_codes(Input,Codes),
    DCG = test_clause_1,
    phrase(DCG,Codes,Rest),
    assertion( Rest == [65,66,67] ).

Capture

EDIT

After shutting down swipl.exe and reloading and retrying it is back.

Capture

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. :smiley:

Thank you Eric.
We seem to be managing to pin it down.


Martin.

As suggested by Jan to use retry, here is some captures of it fixing the problem.

Code and debugger out of sync.

image

Location of the retry button.

image

Code and debugger in sync, but clause restarted.

image

Thank you for that suggestion Eric.

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.

I will try it next time I see this situation.


Martin.