GUI debugger hangs

I’m using: SWI-Prolog version 8.1.13

When I attempt to trace within one particular program, the process hangs. At the bottom it says, “Cross referencing buffer”. After about 10 minutes it finishes cross-referencing and I can see the trace.

I suspect the cause is goal_expansion stuff. Given that, I don’t know how to approach resolving the problem. The program won’t function without the rewrites.

:- module(plateOrder, [allowed_mold_base/1,
		       allowed_mold_base/4,
		       allowed_insertion/3,
		       named_plates/2
		      ]).
:- include(loop_expansion).
:- include(goal_expansion).

allowed_mold_base(PlateList, CavReversed, Stack, CoreSidePlates)  :-
	%% divide full plate list into two halves
	trace, 
        .... % really simple function.

… other code that involves this expansion stuff.

%loop_expansion.pl
% to use this, must include this file from within other *modules*.

:- include(ops).

:- module_transparent t00/2.

t00(Extra0, Extra1) :-
gen:transform_term(Extra0, [], [], [Extra1], [])

goal_expansion(loop X, Result) :-
gen:transform_hook(loop X, Extra0, [Result], [])
, maplist(t00, Extra0, Extras)
, compile_aux_clauses(Extras).

.

%goal_expansion.pl
% to use this, must include this file from within other *modules*.

goal_expansion(X, Result) :-
	gen:transform_term(X, [], [], [Result], []).

I’m afraid there is little I can do without a complete program that can be run. A hypothesis could be that your expansion depends on the order of loading and cannot be called anymore on the final system. Note that you can test for the Prolog flag xref, which is true if term expansion is called on behalf of the development tools (originally only for the cross referencer, but now for all similar tools).

I assume the cause is the algorithmic complexity of something in the cross-referencing, and a small program simply would not show the problem. I could give access to our program for diagnostic purposes.

I do not understand your suggestion to “test for the Prolog flag”. Suppose I test it and it says true. How does that help me?

You may not want to do some expansions at all when called from the cross-referencer and other IDE tools. So, quite some expansions have

goal_expansion(X, Y) :-
     \+ current_prolog_flag(xref, true),
     ...

The idea that a tool such as a cross-referencer can have unintended consequences for an application semantics and that it’s the application job to prevent it is troublesome and a good argument to do both term-expansion and tools differently.

1 Like

12 posts were split to a new topic: Prolog inline predicates