<commit_before>/*  $Id$

    Part of XPCE --- The SWI-Prolog GUI toolkit

    Author:        <NAME> and <NAME>
    E-mail:        <EMAIL>
    WWW:           http://www.swi.psy.uva.nl/projects/xpce/
    Copyright (C): 1985-2006, University of Amsterdam

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    As a special exception, if you link this library with other files,
    compiled with a Free Software compiler, to produce an executable, this
    library does not by itself cause the resulting executable to be covered
    by the GNU General Public License. This exception does not however
    invalidate any other reasons why the executable file might be covered by
    the GNU General Public License.
*/

:- module(pce_prolog_tracer,
	  [ prolog_show_frame/2		% +Frame, +Options
	  ]).
:- use_module(library(prolog_clause)).
:- use_module(library(lists)).
:- use_module(library(debug)).
:- consult([ clause,
	     util,
	     source,
	     break,
	     gui,
	     stack
	   ]).

:- initialization
   visible(+cut_call).


		 /*******************************
		 *	      INTERCEPT		*
		 *******************************/

:- thread_local
	last_action/1,
	show_unify_as/2.

user:prolog_trace_interception(Port, Frame, CHP, Action) :-
	current_prolog_flag(gui_tracer, true),
	notrace(intercept(Port, Frame, CHP, GuiAction)),
	map_action(GuiAction, Frame, Action).


%%	map_action(+GuiAction, +Frame, -Action) is det.
%
%	Map the abstract action of the gui-tracer into actions for the
%	low-level tracer.  Runs in the debugged thread.
%	
%	@tbd	The argument frame is not used.  Delete?

map_action(creep, _, continue) :-
	traceall.
map_action(skip, _, continue) :-
	get_tracer(selected_frame, Frame),
	prolog_frame_attribute(Frame, level, Level),
	Skip is Level + 1,
	trace,
	prolog_skip_level(_, Skip).
map_action(into, _, continue) :-
	visible(+unify),<commit_msg>EHANCED: Avoid that the gui-tracer ever reverts to the normal tracer by adding a catch-all rule.  Especially avoids deadlocks when tracing threads that cannot interact with the toplevel.<commit_after>/*  $Id$

    Part of XPCE --- The SWI-Prolog GUI toolkit

    Author:        <NAME> and <NAME>
    E-mail:        <EMAIL>
    WWW:           http://www.swi.psy.uva.nl/projects/xpce/
    Copyright (C): 1985-2006, University of Amsterdam

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    As a special exception, if you link this library with other files,
    compiled with a Free Software compiler, to produce an executable, this
    library does not by itself cause the resulting executable to be covered
    by the GNU General Public License. This exception does not however
    invalidate any other reasons why the executable file might be covered by
    the GNU General Public License.
*/

:- module(pce_prolog_tracer,
	  [ prolog_show_frame/2		% +Frame, +Options
	  ]).
:- use_module(library(prolog_clause)).
:- use_module(library(lists)).
:- use_module(library(debug)).
:- consult([ clause,
	     util,
	     source,
	     break,
	     gui,
	     stack
	   ]).

:- initialization
   visible(+cut_call).


		 /*******************************
		 *	      INTERCEPT		*
		 *******************************/

:- thread_local
	last_action/1,
	show_unify_as/2.

user:prolog_trace_interception(Port, Frame, CHP, Action) :-
	current_prolog_flag(gui_tracer, true),
	(   notrace(intercept(Port, Frame, CHP, GuiAction)),
	    map_action(GuiAction, Frame, Action)
	->  true
	;   print_message(warning,
			  guitracer(intercept_failed(Port, Frame,
						     CHP, Action))),
	    Action = continue
	).


%%	map_action(+GuiAction, +Frame, -Action) is det.
%
%	Map the abstract action of the gui-tracer into actions for the
%	low-level tracer.  Runs in the debugged thread.
%	
%	@tbd	The argument frame is not used.  Delete?

map_action(creep, _, continue) :-
	traceall.
map_action(skip, _, continue) :-
	get_tracer(selected_frame, Frame),
	prolog_frame_attribute(Frame, level, Level),
	Skip is Level + 1,
	trace,
	prolog_skip_level(_, Skip).
map_action(into, _, continue) :-
	visible(+unify),
{'fraction_non_alphanumeric': 0.10537992235163617, 'fraction_numerical': 0.009983361064891847, 'mean_word_length': 3.3770226537216828, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2258355', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1570, 'n_words': 603}