This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: macro debugging info: emit correct line number for #inclusions
- From: Daniel Berlin <dan at dberlin dot org>
- To: Jim Blandy <jimb at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Mar 2002 16:36:43 -0500 (EST)
- Subject: Re: macro debugging info: emit correct line number for #inclusions
On Tue, 19 Mar 2002, Jim Blandy wrote:
>
> GCC -gdwarf-2 -g3 currently emits macro info which claims that every
> #inclusion occurs on line 1 of the #including file:
Someone must have moved the debug hook after the src location pushing,
which resets the line number variable we were using.
The code hasn't been looked at since I wrote it and tested it, since GDB
didn't support it, and I don't use many macros when debugging with my
debugger.
We can't really test it in the testsuite, though if gdb had tests, the
regression checker for gcc, which runs the gdb testsuite, should catch it.
>
> Here is a patch:
>
> 2002-03-19 Jim Blandy <jimb@redhat.com>
>
> * c-lex.c (cb_file_change): Pass the #inclusion's line number to
> the start_source_file debug hook, not the current line number.
>
> Index: gcc/c-lex.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
> retrieving revision 1.167
> diff -c -r1.167 c-lex.c
> *** gcc/c-lex.c 2002/03/17 20:41:34 1.167
> --- gcc/c-lex.c 2002/03/19 19:55:14
> ***************
> *** 273,282 ****
> main_input_filename = new_map->to_file;
> else
> {
> ! lineno = SOURCE_LINE (new_map - 1, new_map->from_line - 1);
> push_srcloc (new_map->to_file, 1);
> input_file_stack->indent_level = indent_level;
> ! (*debug_hooks->start_source_file) (lineno, new_map->to_file);
> #ifndef NO_IMPLICIT_EXTERN_C
> if (c_header_level)
> ++c_header_level;
> --- 273,284 ----
> main_input_filename = new_map->to_file;
> else
> {
> ! int included_at = SOURCE_LINE (new_map - 1, new_map->from_line - 1);
> !
> ! lineno = included_at;
> push_srcloc (new_map->to_file, 1);
> input_file_stack->indent_level = indent_level;
> ! (*debug_hooks->start_source_file) (included_at, new_map->to_file);
> #ifndef NO_IMPLICIT_EXTERN_C
> if (c_header_level)
> ++c_header_level;
>
Looks right.