# Gtrace, Stepping into phrase/3 not being stepped into, is this expected or a bug?

**URL:** <https://swi-prolog.discourse.group/t/gtrace-stepping-into-phrase-3-not-being-stepped-into-is-this-expected-or-a-bug/4176>\
**Category:** Help!\
**Created:** [July 20, 2021, 12:16pm UTC](https://swi-prolog.discourse.group/t/gtrace-stepping-into-phrase-3-not-being-stepped-into-is-this-expected-or-a-bug/4176 "2021-07-20T12:16:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [July 20, 2021, 12:16pm UTC](https://swi-prolog.discourse.group/t/gtrace-stepping-into-phrase-3-not-being-stepped-into-is-this-expected-or-a-bug/4176/1 "2021-07-20T12:16:00Z")

</div>

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`

```prolog
:- module(phrase_tests_set_1,[]).

:- load_test_files([]).

```

File: `phrase_tests_set_1.plt`

```prolog
:- 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

```prolog
?- [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 

```

 ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/a/a2a28413a634569e6b6e0e135c822c91c3e296da.png)

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`

```prolog
:- module(phrase_tests_set_2,[])

:- load_test_files([]).

```

File: `phrase_tests_set_2.plt`

```prolog
:- 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.

```prolog
?- [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 

```

![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/1/1fc09e2891c19cd53d6df6e531cd1ad9362aec0c.png)

As expected pressing space bar at the call of phrase/3 steps into the DCG.

 ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/9/9818f6875197cad84d288bb5a8a68ccf2c927121.png)

* * *

**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](https://swi-prolog.discourse.group/t/granular-code-coverage-tool/4153/6).

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [July 20, 2021, 12:45pm UTC](https://swi-prolog.discourse.group/t/gtrace-stepping-into-phrase-3-not-being-stepped-into-is-this-expected-or-a-bug/4176/2 "2021-07-20T12:45:24Z")

</div>

library(http/html\_write) contains

```
:- set_prolog_flag(generate_debug_info, false).

```

That stops the internal machinery from being traced, only tracing the calls this library makes to normal user land. Without you get an enormous amount of details that have little value for the normal user.
