public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/107012] [debug, dwarf-5] Missing line information for evaluating macros
Date: Fri, 23 Sep 2022 12:51:05 +0000	[thread overview]
Message-ID: <bug-107012-4-YPsGXcl2WC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107012-4@http.gcc.gnu.org/bugzilla/>

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...

  parent reply	other threads:[~2022-09-23 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 22:45 [Bug debug/107012] New: " gandalf at winds dot org
2022-09-22 22:46 ` [Bug debug/107012] " gandalf at winds dot org
2022-09-23 12:51 ` jakub at gcc dot gnu.org [this message]
2022-10-26 11:37 ` pinskia at gcc dot gnu.org
2022-10-26 16:50 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107012-4-YPsGXcl2WC@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).