From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D2DBE3858C53; Fri, 21 Jul 2023 06:51:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2DBE3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689922313; bh=7Oab8EsIrzN5XURsTkEL1QqW2k9faAxQklpvenXYWpY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PXPvMYNtQFAHeJFk397WMiXwKQdUbvg4P8BG5FMy8eEc/8TyVUUg70alWaVANsm4A rTGY20GrB+3TGlerwD2WUWyrrXIHHu5BHRubSFg0qw9a3WaB13OiP8MDOd2A4vBcwo 95PwqZG5T0OkST4fH3mJLqHkcMqpUTNB6OmFfSzI= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/30656] [gdb/symtab] optimized out static handled inconsistently Date: Fri, 21 Jul 2023 06:51:53 +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: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 14.1 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30656 --- Comment #7 from Tom de Vries --- (In reply to Tom de Vries from comment #2) > (In reply to Tom de Vries from comment #0) > > I wrote a dwarf assembly test-case simulating an optimized-out static > > variable: >=20 > Also reproduced with a plain C test-case: > ... > $ cat whole-program.c > static int aaa; >=20 > int > main (void) > { > return 0; > } > $ gcc-12 whole-program.c -g -flto -O2 > $ nm a.out | grep aaa > $ > ... >=20 > Corresponding DIE: > ... > <1><104>: Abbrev Number: 2 (DW_TAG_variable) > <105> DW_AT_name : aaa > <109> DW_AT_decl_file : 1 > <10a> DW_AT_decl_line : 1 > <10b> DW_AT_decl_column : 12 > <10c> DW_AT_type : <0x110> > ... >=20 > Difference in behaviour: > .... > $ gdb -q -batch ./a.out -ex "print aaa" > No symbol "aaa" in current context. > $ gdb -q -batch -readnow ./a.out -ex "print aaa" > $1 =3D > ... FTR, while writing the test-case I realized I couldn't reproduce this, I probably got the system gdb and devel gdb mixed up. Anyway, this does reproduce with system gdb based on 12.1. This points to the fact that we've regressed in terms of not requiring to expand the symtab in order to find t= he language of main, I suppose because we're not tracking the language of entr= ies in the cooked index. For the test-case I split up the source in two CUs, to make sure that --=20 You are receiving this mail because: You are on the CC list for the bug.=