This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Speaking of DWARF-2 macro info
Daniel Berlin wrote:-
> Watch what happens when i have it printf "Starting source file" at the
> beginning of dwarf2out_start_source_file, and "Ending source file" at
> the beginning of dwarf2out_end_source_file:
>
> Example file tst.c:
> #define bob(A,b) A-b
>
> Output:
> [root@localhost root]# /gccbuild/egcs/buil/gcc/cc1 -gdwarf-2 -g3 tst.c
> Starting source file!
> Starting source file!
>
> Execution times (seconds)
> parser : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 (11%)
> wall
> TOTAL : 0.03 0.00 0.09
OK, let's get this fixed.
I'm confused. In your initial post, you claimed that there was one
entry call too many. Now you're claiming there are two. Which is it?
If I put an fprintf in dwarf2out_{start,end}_source_file like you did,
then I get, on a file foo.c that #inclues a single header foo.h:
Initial // c_common_parse_file's call of the debug hook
--Entered /tmp/foo.c
Entered with callback // cb_file_change for foo.h
--Entered /tmp/foo.h
Left // cb_file_change for leaving foo.h
--Left
Here those beginning with "--" are in dwarf2out.c's callbacks. The
other fprintf's are in c-lex.c. So I can't reproduce your two excess
"Starting source file"'s.
Now, if I understand you, you want an extra
Left // cb_file_change for leaving foo.c
--Left
This doesn't happen because, by (mis?)design, cpplib does not perform a
final hook for leaving the main file. IIRC this was to avoid a #line
marker at the end of the input file, but I'm not 100% certain. You can
see this in cppfiles.c:
/* Don't generate a callback for popping the main file. */
if (pfile->buffer)
{
_cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
/* Finally, push the next -included file, if any. */
if (!pfile->buffer->prev)
pushed = _cpp_push_next_buffer (pfile);
}
Do you want this callback to happen? That's easy to change. I could
avoid the linemarker some other way I imagine.
But then, I still don't understand. In another mail you quoted the
debug_finish hook that output debug info for terminating the main file.
So wouldn't you then output that debug info twice?
Confused,
Neil.