https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107012

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I don't see anything wrong on what GCC emits.
If I compile with -O3 -g3 -gdwarf-4 -dA -nostdinc so that stdc-predef.h isn't
included vs. -O3 -g3 -gdwarf-5 -dA -nostdinc, in .debug_macro I see for DWARF
4:
        .section        .debug_macro,"",@progbits
.Ldebug_macro0:
        .value  0x4     # DWARF macro version number
        .byte   0x2     # Flags: 32-bit, lineptr present
        .long   .Ldebug_line0
        .byte   0x7     # Import
        .long   .Ldebug_macro2
        .byte   0x3     # Start new file
        .byte   0       # uleb128 0; Included from line number 0
        .byte   0x1     # uleb128 0x1; file pr107012.c
        .byte   0x5     # Define macro strp
        .byte   0x1     # uleb128 0x1; At line number 1
        .long   .LASF372        # The macro: "TEST_MACRO 42"
        .byte   0x4     # End file
        .byte   0       # End compilation unit
where .Ldebug_macro2 is import of the predefined macros.
.debug_line then has:
        .ascii "pr107012.c\0"   # File Entry: 0x1
        .byte   0       # uleb128 0
        .byte   0       # uleb128 0
        .byte   0       # uleb128 0
i.e. file entry 1 is pr107012.c.
In DWARF 5 it is:
        .section        .debug_macro,"",@progbits
.Ldebug_macro0:
        .value  0x5     # DWARF macro version number
        .byte   0x2     # Flags: 32-bit, lineptr present
        .long   .Ldebug_line0
        .byte   0x7     # Import
        .long   .Ldebug_macro2
        .byte   0x3     # Start new file
        .byte   0       # uleb128 0; Included from line number 0
        .byte   0x1     # uleb128 0x1; file pr107012.c
        .byte   0x5     # Define macro strp
        .byte   0x1     # uleb128 0x1; At line number 1
        .long   .LASF374        # The macro: "TEST_MACRO 42"
        .byte   0x4     # End file
        .byte   0       # End compilation unit
so there are only minor differences related to macros:
-       .long   .Ldebug_macro0  # DW_AT_GNU_macros
+       .long   .Ldebug_macro0  # DW_AT_macros
in .debug_info section and
        .section        .debug_macro,"",@progbits
 .Ldebug_macro0:
-       .value  0x4     # DWARF macro version number
+       .value  0x5     # DWARF macro version number
        .byte   0x2     # Flags: 32-bit, lineptr present
        .long   .Ldebug_line0
        .byte   0x7     # Import
...
        .byte   0x1     # uleb128 0x1; file pr107012.c
        .byte   0x5     # Define macro strp
        .byte   0x1     # uleb128 0x1; At line number 1
-       .long   .LASF372        # The macro: "TEST_MACRO 42"
+       .long   .LASF374        # The macro: "TEST_MACRO 42"
        .byte   0x4     # End file
        .byte   0       # End compilation unit
in .debug_macro.  The line table then says that both file 0 and 1 are
pr107012.c:
        .byte   0x2     # File name entry format count
        .byte   0x1     # uleb128 0x1; DW_LNCT_path
        .byte   0x1f    # uleb128 0x1f; DW_FORM_line_strp
        .byte   0x2     # uleb128 0x2; DW_LNCT_directory_index
        .byte   0xb     # uleb128 0xb; DW_FORM_data1
        .byte   0x2     # uleb128 0x2; File names count
        .long   .LASF0  # File Entry: 0: "pr107012.c"
        .byte   0
        .long   .LASF0  # File Entry: 0: "pr107012.c"
        .byte   0
You'd better file this against gdb...

Reply via email to