How do we run the graphical debugger?

Been looking at the doc page for the graphical debugger, and would like to try it.

According to that page, I need to run gtrace, and according to the doc page for gtrace I need to include the following line…

:- use_module(library(gui_tracer)).

However, this gives a compiler error…

ERROR:    source_sink `library(gui_tracer)' does not exist

Looking at the list of libraries, I can’t see it there.

Anyone able to advise how I fix this? Thanks

This will give you an example of how to use it.

Welcome to SWI-Prolog (threaded, 64 bits, version 9.1.14-41-g41ac4a569)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- gtrace.
% The graphical front-end will be used for subsequent tracing
true.

[trace]  ?- print_term([a,b,c],[]).

You can also use gtrace/0 inside of existing code

You probably need to do a full installation. Hard to tell what you are missing though, how did you install your Prolog? What OS? and so on

@EricGT and @Boris Thanks for the replies.

I realised what the problem is (I think). I use Visual Studio Code, and have the SWI-Prolog extension. To run code, I type swipl in the VS terminal, and then call my predicates as I would if running the SWI-Prolog app.

If I run the installed SWI-Prolog app (where I get the interface) then indeed gtrace works fine. It’s only when I try it in the VS terminal that it doesn’t work.

Any idea how I run it from the VS terminal?

For the record, I’m running version 9.0.4 on Win11, and did do a full installation.

Thanks again

Don’t. The documentation notes it does not always work.

Personally I do use VSCode on Windows to write the Prolog with the VCS plugin but do the debugging from the SWI-Prolog Windows GUI app.

1 Like

Shame, I really like VSC.

Oh well, at least I don’t need to waste any more time trying to get it to run!

Thanks again

P.S. Where did you see that the doc notes say it doesn’t always work? Didn’t see that.

1 Like

The Issues on GitHub note some conditions when it does not work.

The plugin is still great and I use it constantly, just not with the debugger.

Actually, this might be possible these days. In the past you could not run a GUI from the commandline swipl.exe as this requires both the Windows message loop and synchronous read from the console. Since quite some years though, the IDE tools run in their own thread that (thus) also runs the message loop. So, you might be able to do

?- [swi('swipl.rc')].

and then start the gui tools, such as gtrace/0.

1 Like

It works if you follow Jan’s suggestion. I also use VS Code and I found it almost miracolous when, launching a prolog file, XQuartz started (on MacOS). Although I know there’s nothing miracolous (in the end if it works from the Terminal why shouldn’t it work from the VS terminal…) :+1:t2:

Thanks, but I get a message that swipl.rc doesn’t exist. Is this something that I should have, in which case where would I find it, or is it something I need to add, in which case what is it?

Thanks

Probably should be [swi('swipl-win.rc')] on Windows. On MacOS both should work, but I think this work-around should not be needed because swipl can run graphics.

Thanks that worked. All I need to do now is work out how to use the debugger :rofl:

1 Like

It’s not yet clear to me whether the whole issue (when spending some time with computers) is more about solving problems or about creating them :sweat_smile:

1 Like

Computers themselves are all about solving problems you never knew you had, and in fact probably didn’t have until you started trying to solve them with a computer!

There’s a famous (sort-of) joke that went around years ago along the lines of “Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems

I reckon you could substitute just about anything computer-related for “regular expressions” there :smile:

P.S. If you’re really bored, you can read a long and detailed background to that quote here.