In using gtrace/0 was expecting that pressing the space bar would step into a call for phrase/3. Instead the call to phrase/3 was stepped over.
The first code set demonstrates the problem where stepping into phrase/3 with gtrace does not work as expected using a minimally reproduceable example.
The second code set demonstrates that stepping into phrase/3 with gtrace works as expected using a minimally reproduceable example.
Using SWI-Prolog (threaded, 64 bits, version 8.3.26) on Windows 10.
File: phrase_tests_set_1.pl
:- module(phrase_tests_set_1,[]).
:- load_test_files([]).
File: phrase_tests_set_1.plt
:- begin_tests(html_dcg).
:- use_module(library(http/html_write)).
html_dcg_cases(1,success,
[
head(title('Howdy')),
body(
[
h1('Heading')
]
)
],
[nl(1),<,head,>,nl(1),nl(1),<,title,>,nl(0),'Howdy',nl(0),</,title,>,nl(1),mailbox(head,accept(html_write:head_html,_8342)),nl(1),</,head,>,nl(1),nl(1),<,body,>,nl(1),nl(2),<,h1,>,nl(0),'Heading',nl(0),</,h1,>,nl(2),nl(1),</,body,>,nl(1)],
"\n<head>\n<title>Howdy</title>\n\n</head>\n<body>\n\n<h1>Heading</h1>\n\n</body>\n"
).
test(html_dcg,[true,forall(html_dcg_cases(_,success,Input,TokenizedHtml,HTML))]) :-
phrase(html(Input),TokenizedHtml,[]),
with_output_to(string(HTML),print_html(TokenizedHtml)).
:- end_tests(html_dcg).
Example run
?- [phrase_tests_set_1].
true.
?- run_tests.
% PL-Unit: html_dcg . done
% test passed
true.
?- gtrace.
% The graphical front-end will be used for subsequent tracing
true.
[trace] ?- run_tests.
% PL-Unit: html_dcg
When the debugger is on phrase/3 I was expecting that pressing the space bar would step into the code for phrase/3, instead the debugger steps over the phrase/3 call.
Is this what it is suppose to do? or is this a bug?
Example showing stepping into phrase/3 when using gtrace that works as expected.
File: phrase_tests_set_2.plt
:- module(phrase_tests_set_2,[])
:- load_test_files([]).
File: phrase_tests_set_2.plt
:- begin_tests(phrase).
:- use_module(library(http/dcg_basics)).
phrase_cases(1,success,"ABC","abc").
to_lower([H|T]) -->
alpha_to_lower(H), !,
to_lower(T).
to_lower([]) --> [].
test(html_dcg,[true,forall(phrase_cases(_,success,Input,Lower_case))]) :-
string_codes(Input,Upper_codes),
phrase(to_lower(Lower_codes),Upper_codes,[]),
string_codes(Lower_case,Lower_codes).
:- end_tests(phrase).
Example run.
?- [phrase_tests_set_2].
% Library was moved: library(http/dcg_basics) --> library(dcg/basics)
true.
?- run_tests.
% PL-Unit: phrase . done
% test passed
true.
?- gtrace.
% The graphical front-end will be used for subsequent tracing
true.
[trace] ?- run_tests.
% PL-Unit: phrase
As expected pressing space bar at the call of phrase/3 steps into the DCG.
EDIT
To step into code with :- set_prolog_flag(generate_debug_info, false).
just use
set_prolog_flag(generate_debug_info, true)
in the code. See details in my Personal Notes.