public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/101575] New: [gcc-11, -gdwarf-4] Missing .file <n> directive causes invalid line info Date: Thu, 22 Jul 2021 09:37:12 +0000 [thread overview] Message-ID: <bug-101575-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101575 Bug ID: 101575 Summary: [gcc-11, -gdwarf-4] Missing .file <n> directive causes invalid line info Product: gcc Version: 11.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider test-case defs.adb/defs.ads from a gdb testcase ( https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/testsuite/gdb.ada/formatted_ref ). If we compile with dwarf 5, we have only one address at defs.adb:20, 0x2a: ... $ gcc -c -gdwarf-5 -g defs.adb $ readelf -wL defs.o Contents of the .debug_line section: CU: ./defs.adb: File name Line number Starting address View Stmt defs.adb 18 0x22 x defs.adb 20 0x2a x defs.adb 21 0x30 x ./defs.adb:[++] defs.adb 16 0x32 x defs.adb 25 0x36 x defs.adb 27 0x45 x defs.adb - 0x48 ... With dwarf 4, we have two addresses: ... $ gcc -c -gdwarf-4 -g defs.adb $ readelf -wL defs.o Contents of the .debug_line section: CU: ./defs.adb: File name Line number Starting address View Stmt defs.adb 10 0 x defs.adb 13 0x1 x defs.adb 15 0x4 x defs.adb 16 0x8 x defs.adb 17 0xb x defs.adb 18 0xf x defs.adb 19 0x15 x defs.adb 20 0x19 x defs.adb 21 0x20 x defs.adb 23 0x21 x defs.adb 18 0x22 x defs.adb 20 0x2a x defs.adb 21 0x30 x ./defs.ads:[++] defs.ads 16 0x32 x defs.ads 25 0x36 x defs.ads 27 0x45 x defs.ads - 0x48 ... The additional breakpoint at address 0x19 falls into: ... 0000000000000000 <defs__struct1IP>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 89 7d f8 mov %rdi,-0x8(%rbp) 8: 89 75 f4 mov %esi,-0xc(%rbp) b: 48 8b 45 f8 mov -0x8(%rbp),%rax f: c7 00 0d 00 00 00 movl $0xd,(%rax) 15: 48 8b 45 f8 mov -0x8(%rbp),%rax 19: c7 40 04 13 00 00 00 movl $0x13,0x4(%rax) 20: 5d pop %rbp 21: c3 ret ... which is an initialization function corresponding to this code in defs.ads: ... type Struct1 is limited record X : Integer := 13; Y : Integer := 19; end record; ... The dwarf 4 assembly starts like this: ... $ cat -n defs.s 1 .file "defs.adb" 2 .text 3 .Ltext0: 4 .align 2 5 .globl defs__struct1IP 6 .type defs__struct1IP, @function 7 defs__struct1IP: 8 .LFB2: 9 .cfi_startproc 10 pushq %rbp 11 .cfi_def_cfa_offset 16 12 .cfi_offset 6, -16 13 movq %rsp, %rbp 14 .cfi_def_cfa_register 6 15 movq %rdi, -8(%rbp) 16 movl %esi, -12(%rbp) 17 movq -8(%rbp), %rax 18 movl $13, (%rax) 19 movq -8(%rbp), %rax 20 movl $19, 4(%rax) 21 popq %rbp 22 .cfi_def_cfa 7, 8 23 ret 24 .cfi_endproc 25 .LFE2: 26 .size defs__struct1IP, .-defs__struct1IP 27 .align 2 28 .globl defs__f1 29 .type defs__f1, @function 30 defs__f1: 31 .LFB3: 32 .file 1 "defs.adb" 33 .loc 1 18 4 ... and gas generates line-info for this assembly because: - we pass --gdwarf-4 to gas - of the absence of a .file <n> <file> directive in defs__struct1IP The dwarf 5 assembly starts like: ... .file "defs.adb" .text .Ltext0: .file 0 "/home/vries/gdb_versions/devel" "defs.adb" .align 2 .globl defs__struct1IP .type defs__struct1IP, @function defs__struct1IP: .LFB2: .cfi_startproc pushq %rbp ... and due to the .file 0 directive we hit this in gas/dwarf2dbg.c: ... /* A .file directive implies compiler generated debug information is being supplied. Turn off gas generated debug info. */ debug_type = DEBUG_NONE; ... and no line info is generated for the assembly. AFAIU, this can be fixed by having gcc issue a .file <n> directive in defs__struct1IP.
next reply other threads:[~2021-07-22 9:37 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-22 9:37 vries at gcc dot gnu.org [this message] 2021-07-22 12:30 ` [Bug debug/101575] " ebotcazou at gcc dot gnu.org 2021-07-22 12:32 ` vries at gcc dot gnu.org 2021-07-22 12:54 ` [Bug ada/101575] " ebotcazou at gcc dot gnu.org 2021-07-22 13:32 ` bernd.edlinger at hotmail dot de 2021-07-22 15:57 ` vries at gcc dot gnu.org 2021-07-22 16:00 ` vries at gcc dot gnu.org 2021-07-22 16:53 ` ebotcazou at gcc dot gnu.org 2021-07-23 12:22 ` bernd.edlinger at hotmail dot de 2021-07-23 12:36 ` vries at gcc dot gnu.org 2021-07-23 15:14 ` ebotcazou at gcc dot gnu.org 2021-07-24 7:43 ` bernd.edlinger at hotmail dot de 2021-07-24 11:21 ` bernd.edlinger at hotmail dot de 2021-07-24 12:24 ` ebotcazou at gcc dot gnu.org 2021-08-04 14:19 ` cvs-commit 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-101575-4@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: linkBe 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).