This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
macro debugging info: emit correct line number for #inclusions
- From: Jim Blandy <jimb at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Mar 2002 16:15:56 -0500 (EST)
- Subject: macro debugging info: emit correct line number for #inclusions
GCC -gdwarf-2 -g3 currently emits macro info which claims that every
#inclusion occurs on line 1 of the #including file:
$ cat macros4.c
#include <stdio.h>
#define A(x) x
int
main (int argc, char **argv)
{
printf ("Hello, world!\n");
}
$ $GccB/gcc --version
gcc (GCC) 3.2 20020318 (experimental)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ $GccB/gcc -S -gdwarf-2 -g3 -dA macros4.c
$ cat macros4.s
...
.section .debug_macinfo
...
.byte 0x3 # Start new file
.byte 0x1 # uleb128 0x1; Included from line number 1
.byte 0x2 # uleb128 0x2; Filename we just started
.byte 0x1 # Define macro
.byte 0x1a # uleb128 0x1a; At line number 26
.ascii "_STDIO_H 1\0" # The macro
.byte 0x3 # Start new file
.byte 0x1 # uleb128 0x1; Included from line number 1
.byte 0x3 # uleb128 0x3; Filename we just started
.byte 0x1 # Define macro
.byte 0x14 # uleb128 0x14; At line number 20
.ascii "_FEATURES_H 1\0" # The macro
...
.byte 0x3 # Start new file
.byte 0x1 # uleb128 0x1; Included from line number 1
.byte 0x4 # uleb128 0x4; Filename we just started
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;