From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0E8B8385BF92; Wed, 1 Apr 2020 13:29:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E8B8385BF92 From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/25755] Means to not keep decls in symtab Date: Wed, 01 Apr 2020 13:29:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2020 13:29:36 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D25755 --- Comment #1 from Tom de Vries --- (In reply to Tom de Vries from comment #0) > V. >=20 > Consider a simpler test-case, test3.c: > ... > extern int aaa; >=20 > int aaa; >=20 > int > main (void) > { > return 0; > } > ... > compiled with debug info, with an older gcc: > ... > $ gcc-4.8 -g test3.c > ... >=20 > There's just one DIE describing the variable: > ... > <1><118>: Abbrev Number: 4 (DW_TAG_variable) > <119> DW_AT_name : aaa > <11d> DW_AT_decl_file : 1 > <11e> DW_AT_decl_line : 3 > <11f> DW_AT_type : <0x111> > <123> DW_AT_external : 1 > <123> DW_AT_location : 9 byte block: 3 2c 10 60 0 0 0 0 0=20=20= =20=20=20 > (DW_OP_addr: 60102c) > ... >=20 > But with a more recent gcc (7.5.0), we have a def and a decl: > ... > <1>: Abbrev Number: 2 (DW_TAG_variable) > DW_AT_name : aaa > DW_AT_decl_file : 1 > DW_AT_decl_line : 1 > DW_AT_type : <0xff> > DW_AT_external : 1 > DW_AT_declaration : 1 > <1><106>: Abbrev Number: 4 (DW_TAG_variable) > <107> DW_AT_specification: <0xf4> > <10b> DW_AT_decl_line : 3 > <10c> DW_AT_location : 9 byte block: 3 2c 10 60 0 0 0 0 0=20=20= =20=20=20 > (DW_OP_addr: 60102c) > ... >=20 > This more accurately describes the source, but gdb makes a symbol for both > the def and the decl: > ... > Blockvector: >=20 > block #000, object at 0x560017e71f40, 1 syms/buckets in 0x400497..0x4004a2 > int aaa; unresolved > int aaa; static at 0x60102c section .bss > int main(void); block object 0x560017e71e30, 0x400497..0x4004a2 section > .text > block #001, object at 0x560017e71e90 under 0x560017e71f40, 1 syms/bucke= ts > in 0x400497..0x4004a2 > typedef int int;=20 > block #002, object at 0x560017e71e30 under 0x560017e71e90, 0 > syms/buckets in 0x400497..0x4004a2, function main > ... > which is not useful at all. >=20 >=20 > VI. >=20 > This situation is further aggravated by -flto, which for a test-case test= 4.c: > ... > int aaa; >=20 > int > main (void) > { > return 0; > } > ...=20 > compiled like this: > ... > $ gcc-8 -O0 test4.c -g -flto -flto-partition=3Dnone -ffat-lto-objects > ... > generates a def and a decl: > ... > <0>: Abbrev Number: 1 (DW_TAG_compile_unit) > DW_AT_name : > <1><110>: Abbrev Number: 4 (DW_TAG_variable) > <111> DW_AT_abstract_origin: <0x13d> > <115> DW_AT_location : 9 byte block: 3 2c 10 60 0 0 0 0 0=20=20= =20=20=20 > (DW_OP_addr: 60102c) > <0><12b>: Abbrev Number: 1 (DW_TAG_compile_unit) > <131> DW_AT_name : test4.c > <1><13d>: Abbrev Number: 2 (DW_TAG_variable) > <13e> DW_AT_name : aaa > <142> DW_AT_decl_file : 1 > <143> DW_AT_decl_line : 1 > <144> DW_AT_decl_column : 5 > <145> DW_AT_type : <0x149> > <149> DW_AT_external : 1 > ... > even though there's no seperate decl in the file, and gdb again keeps two > entries in the symbol tables: > ... > Symtab for file test4.c >=20 > Blockvector: >=20 > block #000, object at 0x555e7afafb70, 1 syms/buckets in 0x0..0x0 > int aaa; unresolved > block #001, object at 0x555e7afafac0 under 0x555e7afafb70, 1 syms/bucke= ts > in 0x0..0x0 > typedef int int;=20 >=20 >=20 > Symtab for file >=20 > Blockvector: >=20 > block #000, object at 0x555e7afaf7d0, 1 syms/buckets in 0x400492..0x40049e > int main(void); block object 0x555e7afaf6c0, 0x400492..0x40049e section > .text > int aaa; static at 0x60102c section .bss > block #001, object at 0x555e7afaf770 under 0x555e7afaf7d0, 0 syms/bucke= ts > in 0x400492..0x40049e > block #002, object at 0x555e7afaf6c0 under 0x555e7afaf770, 0 > syms/buckets in 0x400492..0x40049e, function main > ... >=20 I've filed a PR to ignore these useless symbols: PR25759 - "Remove useless decls from symtab". --=20 You are receiving this mail because: You are on the CC list for the bug.=