From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BAAE3858C50; Wed, 5 Apr 2023 13:39:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BAAE3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680701967; bh=j9xzCBGUtyYdXUIYqpisc8owNOoWcWtjnzrcaik/4Gs=; h=From:To:Subject:Date:From; b=VrKYNrC+elIrCymGUa6XqkfxeAz1X3rYqHj4j5/eRMLPUYZgjhmzqPDf+k+cQVS3N /AVNVekBdsw5SpYVAfDiEqytt4jOIki+GjRzirJ9aFh6Ao3yCv72b4NJeWOW7OBPmg k6p829iO6Ek+El5X7PvxdzFzSTNTNcUq5gYAK6kw= From: "hluaw at connect dot ust.hk" To: gdb-prs@sourceware.org Subject: [Bug gdb/30315] New: GDB not showing variable that is supposed to be there Date: Wed, 05 Apr 2023 13:39:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 13.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hluaw at connect dot ust.hk X-Bugzilla-Status: UNCONFIRMED 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: 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://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30315 Bug ID: 30315 Summary: GDB not showing variable that is supposed to be there Product: gdb Version: 13.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: hluaw at connect dot ust.hk Target Milestone: --- Given the following code: #include "stdint.h" #include "string.h" #include int a, b; char* c; static int func_1() { int i =3D 0; for (; i < 4; i++) ; for (; a <=3D 4;) { uint16_t d; b =3D 0; return b; { int i; } } return b; } int main() { func_1(); printf(c); } Compiled with gcc 12.2.0 and -O1 -g The DWARF says that i persists until func_1 exits Breakpoint 1, func_1 () at r.c:10 10 for (; a <=3D 4;) { (gdb) info addr i Symbol "i" is multi-location: Range 0x40112a-0x40112a: the constant 0 Range 0x40112a-0x40112a: the constant 1 Range 0x40112a-0x40112a: the constant 2 Range 0x40112a-0x40112a: the constant 3 Range 0x40112a-0x40113d: the constant 4 . (gdb) p i $1 =3D 4 But GDB says i is prematurely at line 12 with $pc =3D 0x401= 133 still in the range of func_1 (gdb) p i $2 =3D (gdb) p $pc $3 =3D (void (*)()) 0x401133 (gdb) --=20 You are receiving this mail because: You are on the CC list for the bug.=