From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B5290385B833; Fri, 3 Apr 2020 13:22:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5290385B833 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585920157; bh=grsv60N/+zYcco0yl26O+yGM8abqtcfL+oQHwRVni8E=; h=From:To:Subject:Date:From; b=kWNzk21jOFKJ0Q9QeA6v7QKlYl8r/9jUixhE1BiixUvwXpftCiEiINg+QOBX/pwJV SgClbfQYkQXuU0BJqy6MqmL6AjSyEnSQLrvKz6VKloYmYD1TT1ta9yChTTjOvORLBi jVCdypGcHc5Xz0LBbGSwBaMlgbNn5O3nJksLRHDw= From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/94469] New: lto abstract variable emitted as concrete decl (ada test-case) Date: Fri, 03 Apr 2020 13:22:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2020 13:22:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94469 Bug ID: 94469 Summary: lto abstract variable emitted as concrete decl (ada test-case) Product: gcc Version: 10.0 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 gdb testsuite test-case gdb.ada/call_pn ( https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dtree;f=3Dgdb/testsuite= /gdb.ada/call_pn;hb=3DHEAD ), consisting of files foo.adb, pck.adb and pck.ads. Compiled like so: ... $ gnatmake-10 \ --GCC=3D/usr/bin/gcc-10 \ --GNATBIND=3D/usr/bin/gnatbind-10 \ --GNATLINK=3D/usr/bin/gnatlink-10 \ -largs --GCC=3D/usr/bin/gcc-10 -margs \ src/gdb/testsuite/gdb.ada/call_pn/foo.adb \ -g -flto -O0 -flto-partition=3Dnone -ffat-lto-objects ... When trying to print the value of last_node_id, we get a question which sym= bol to print: ... $ gdb foo -ex "p last_node_id" Reading symbols from foo... Multiple matches for last_node_id [0] cancel [1] pck.last_node_id at src/gdb/testsuite/gdb.ada/call_pn/pck.adb:17 [2] pck.last_node_id at src/gdb/testsuite/gdb.ada/call_pn/foo.adb:17 >=20 ... where 1 gives us: ... > 1 $1 =3D ... and 2 gives us: ... > 2 $1 =3D 0 ... If we compile without lto, so just with -g, we have instead: ... $ gdb foo -ex "p last_node_id" $1 =3D 0 ... The structure of the dwarf for the lto case is: ... <0><15ef>: Abbrev Number: 1 (DW_TAG_compile_unit) <15f5> DW_AT_name : <1><1611>: Abbrev Number: 2 (DW_TAG_imported_unit) <1612> DW_AT_import : <0x167a> [Abbrev Number: 1] <1><163f>: Abbrev Number: 5 (DW_TAG_variable) <1640> DW_AT_abstract_origin: <0x16d4> <1644> DW_AT_location : 9 byte block: 3 d4 33 63 0 0 0 0 0=20=20= =20=20 (DW_OP_addr: 6333d4) <0><167a>: Abbrev Number: 1 (DW_TAG_compile_unit) <1680> DW_AT_name : src/gdb/testsuite/gdb.ada/call_pn/pck.adb <1><16d4>: Abbrev Number: 8 (DW_TAG_variable) <16d5> DW_AT_name : pck__last_node_id ... My understanding of DWARF is that this actually declares three symbols: - the one for DW_TAG_compile_unit pck.adb - the one for DW_TAG_compile_unit - the one resulting from the import of into DW_TAG_compile_unit And, AFAIU, the way to make sure we declare just one symbol is by both: - dropping the import, and - changing the tag for pck.adb to DW_TAG_partial_unit. The import was already dropped on master by commit 54af95767e8 "debug/94450= - remove DW_TAG_imported_unit generated in LTRANS units" ( see PR 94450 comme= nt 6 ). Note: interestingly, the foo.adb here is incorrect: ... [1] pck.last_node_id at src/gdb/testsuite/gdb.ada/call_pn/pck.adb:17 [2] pck.last_node_id at src/gdb/testsuite/gdb.ada/call_pn/foo.adb:17 ... For now I'm assuming that's a gdb PR, filed as=20 PR gdb/25771 - "Inter-cu DW_AT_abstract_origin results in wrong file".=