This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Still a problem with debug output, with functions with #line inthe middle, on mainline
- From: Daniel Berlin <dan at dberlin dot org>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc-bugs at gcc dot gnu dot org, <neil at daikokuya dot demon dot co dot uk>
- Date: Wed, 30 Jan 2002 16:31:47 -0500 (EST)
- Subject: Re: Still a problem with debug output, with functions with #line inthe middle, on mainline
On Wed, 30 Jan 2002, Zack Weinberg wrote:
> We still get debug information for functions with #line in the middle
> partially wrong. With the same test case I just posted for 3.0.3:
>
> $ cat test.c
> int main(void) {
> int i = 0;
> #line __LINE__ "foo.c"
> i++;
> #line __LINE__ "bar.c"
> return i;
> }
It never sees a file change for the first file.
This is because cb_file_change only calls start_source_file if map != NULL
(the first file change has map == NULL).
So it never asks the debug info to output info about it.
This fixes it.
The other way (whatever people think is best) is to change push_srcloc in
toplev.c to call start_source_file, since it push_srcloc's the main input
file/line 0.
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.163
diff -c -3 -p -w -B -b -r1.163 c-lex.c
*** c-lex.c 2001/12/31 04:13:35 1.163
--- c-lex.c 2002/01/30 21:25:19
*************** cb_file_change (pfile, new_map)
*** 265,271 ****
--- 265,274 ----
/* Don't stack the main buffer on the input stack;
we already did in compile_file. */
if (map == NULL)
+ {
main_input_filename = new_map->to_file;
+ (*debug_hooks->start_source_file) (lineno, new_map->to_file);
+ }
else
{
lineno = SOURCE_LINE (new_map - 1, new_map->from_line - 1);
--Dan