Invoke guitracer from embedded Prolog application

I’m using: SWI-Prolog version 9.2.0, built from source on MacOS X 10.10.5. (Also on Linux, FreeBSD, etc.)

I want the code to: Enable GUI debugging in my embedded Prolog application

But what I’m getting is: ERROR: Unknown procedure: guitracer/0 (DWIM could not correct goal)

My code looks like this:

% your code here

swipl launched from the command line successfully launches the GUI debugger, but an embedded Prolog program that calls PL_Initialise(), then PL_thead_attach_engine() and then PL_toplevel() in thread 1 generates “ERROR: Unknown procedure: guitracer/0 (DWIM could not correct goal)“ in response to “guitracer.” This is definitely the same installation of swipl - this (virtual) machine only has the one installation.
I have successfully invoked Prolog predicates from the program later on in multiple threads. Everything seems to work, including the command line debugger, except invoking the GUI debugger. For example, if I introduce a fault in my embedded Prolog, I can use the trace predicates successfully but not gtrace etc.
I have tried explicitly using “-x $SWI_HOME_DIR/boot.prc” directly. No change.
I have tried using and not using PL_toplevel(). No change.
Clearly there is something different about how swipl (the command) starts Prolog, but I have not managed to determine what that is.

A couple of side nodes:

  1. The MacPort of SDL3 does not build with SDKs older than 11.0. Consequently, the latest macOS 9.3.x source does not work. Please provide an option to use the existing X Windows System based GUI as an alternative to a native macOS GUI. In fact, MacPorts refused to build SDL3 on macOS 13.7.8, but I admit I did not try hard to find out why. For my purposes, using the same X Windows GUI on macOS, Linux, FreeBSD is actually more desirable than a native macOS GUI.
  2. Older compilers don’t support the GNU “__auto_type” extension to C. It is only used in pl-incl.h and pl-inline.h. Reverting to an older implementation allows the source to continue to build successfully using very old compilers. This seems like a small price to pay for the backward compatibility.

It loads swi('swipl.rc'), which you an either load explicitly or by passing -F swipl to PL_initialise(). With that, the GUI debugger should work normally. Note that on Windows you need to load swipl-win.rc instead. On other platforms and on recent versions both will do the trick.

I’m afraid this is not an option. I started making SDL an alternative to the old backends, but eventually decided that is just too much hassle. Sometimes we have to move on … I agree SDL3 is very new and problematic on some old (unmaintained) systems. The only feasible move would be to backport to SDL2. That too is not without troubles as the pretty involved integration of console input and SDL event processing works differently in SDL2. If someone wants to do a backport and it doesn’t get too ugly I’ll surely accept the PR. I’m not going to do the work unless someone makes a good case and is prepared to pay for it. Sorry …

Pushed a fix for that, adding a test for support to CMake. Note that the current source does demand C11.

Thank you for the fast response Jan. That worked perfectly.
Thanks also for committing the change for the alternative to “__auto_type”
Lastly, I fully understand about the cost of backward compatibility. If you are making major changes to the existing GUI code, I can see why maintaining backward compatibility with the older X Windows code would be too expensive. Thanks for considering it though. I would also like to say that the SWI-Prolog project is an impressive piece of work, and thank you for all your effort on it.
Regards,
Chris

1 Like

X11 carries a lot of legacy :frowning: The code got quite a bit simpler by removing some of that (think about colour maps, font handling, hotplug display handling, etc,., etc.). Actually, there is still quite a bit of X11 centred code in there :frowning:

As a think about it, you probably still get away by setting packages/xpce to the X11 branch. Assuming you get the sources from git, use this to update the source to get the X11 version of xpce:

git pull
git submodule update --init --recursive
cd packages/xpce
git checkout X11

And now build normally. Not tested. I’m happy to handle small PRs if there are minor problems to make/keep this working.

1 Like

Hi Jan,

I’ll give it a go and see what happens. Thank you for the pointer.

Regards,
Chris