This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: -include -g broken with current CVS (testcase for PR 771)
On Mon, Nov 13, 2000 at 12:02:38AM +0000, Neil Booth wrote:
...
> cpp_start_read calls cb_enter_file initially, and cb_enter_file does
> not call debug_start_source_file because the main file is the first
> on the buffer stack (ip->prev == 0). Thus debug_start_source_file
> is only called later, from yyparse, _after_ dbxout_init.
>
> However, when a file is "-include"d, cpp_start_read churns through it
> and amongst other things does a cb_enter_file on the file. This
> means that debug_start_source_file is called before dbxout_init has
> had a chance to set itself up (see above).
>
> What's the correct fix here? To move dbxout_init earlier within
> toplev.c? Or should cb_enter_file not be creating debug info for
> -included files? Or should we move the call to cpp_start_read later?
This is a tough one. I'm pretty sure the debug output init routines
depend on being called as late as they are. Really, we ought to call
cpp_start_read from yyparse, before entering the scanner loop.
Unfortunately, there is no way to get control at the beginning of
yyparse. We could have yylex test whether cpp_start_read had been
called, but then we'd be making that test in the fast path for every
call to yylex.
The best idea I have is to add a callback hook: in toplev.c
+ void (*delayed_init_parse_hook) PARAMS ((void));
...
/* Call the parser, which parses the entire file
(calling rest_of_compilation for each function). */
+ if (delayed_init_parse_hook)
+ (*delayed_init_parse_hook) ()
if (yyparse () != 0)
and then set that in c/c++ init_parse to a small routine that just
calls cpp_start_read.
Then we could remove the silly special case in cb_enter_file. Are
you sure we ever call debug_start_source_file for the main file right
now? I don't see how we get there except via cb_enter_file...
zw