From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 906BF3858C56; Sat, 16 Dec 2023 10:28:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 906BF3858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1702722500; bh=oxxlJJgbnN5DGkqWA7FaTTf51Xf1vJcSErtmcVK3CqI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oHEyqGgA+D9N9TycgHworHo04JLmgAsg59RNs+A7SsiyakdA8QOop1FZ6+Xh7MlCx X5NQsoLRfEQP9AEc2aH3b1XTDoYLIby5NRiMkxOHEXz2jqTpZhzt6WBMsoEYfmlpIa gdW2+/oUUQMELYWHV6vGZDe2S9rkknaI/fF2/Fnk= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/28987] Outdated value being displayed for variable while DWARF info apparently contains the correct one Date: Sat, 16 Dec 2023 10:28:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 11.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28987 --- Comment #4 from Sourceware Commits --- The master branch has been updated by Hannes Domani : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db45d18f19ec9= 507d7561c4d503a5a189214f3f77 commit b45d18f19ec9507d7561c4d503a5a189214f3f77 Author: Hannes Domani Date: Sat Dec 16 11:24:16 2023 +0100 Use function entry point record only for entry values PR28987 notes that optimized code sometimes shows the wrong value of variables at the entry point of a function, if some code was optimized away and the variable has multiple values stored in the debug info for this location. In this example: ``` void foo() { int l_3 =3D 5, i =3D 0; for (; i < 8; i++) ; test(l_3, i); } ``` When compiled with optimization, the entry point of foo is at the test() function call, since everything else is optimized away. The debug info of i looks like this: ``` (gdb) info address i Symbol "i" is multi-location: Base address 0x140001600 Range 0x13fd41600-0x13fd41600: the constant= 0 Range 0x13fd41600-0x13fd41600: the constant 1 Range 0x13fd41600-0x13fd41600: the constant 2 Range 0x13fd41600-0x13fd41600: the constant 3 Range 0x13fd41600-0x13fd41600: the constant 4 Range 0x13fd41600-0x13fd41600: the constant 5 Range 0x13fd41600-0x13fd41600: the constant 6 Range 0x13fd41600-0x13fd41600: the constant 7 Range 0x13fd41600-0x13fd4160f: the constant 8 (gdb) p i $1 =3D 0 ``` Currently, when at the entry point of a function, it will always show the initial value (here 0), while the user would expect the last value (here 8). This logic was introduced for showing the entry-values of function arguments if they are available, but for some reason this was added for non-entry-values as well. One of the tests of amd64-entry-value.exp shows the same problem for function arguments, if you "break stacktest" in the following example, you stop at this line: ``` 124 static void __attribute__((noinline, noclone)) 125 stacktest (int r1, int r2, int r3, int r4, int r5, int r6, int = s1, int s2, 126 double d1, double d2, double d3, double d4, double d= 5, double d6, 127 double d7, double d8, double d9, double da) 128 { 129 s1 =3D 3; 130 s2 =3D 4; 131 d9 =3D 3.5; 132 da =3D 4.5; 133 -> e (v, v); 134 asm ("breakhere_stacktest:"); 135 e (v, v); 136 } ``` But `bt` still shows the entry values: ``` s1=3Ds1@entry=3D11, s2=3Ds2@entry=3D12, ..., d9=3Dd9@entry=3D11.5, da= =3Dda@entry=3D12.5 ``` I've fixed this by only using the initial values when explicitely looking for entry values. Now the local variable of the first example is as expected: ``` (gdb) p i $1 =3D 8 ``` And the test of amd64-entry-value.exp shows the expected current and entry values of the function arguments: ``` s1=3D3, s1@entry=3D11, s2=3D4, s2@entry=3D12, ..., d9=3D3.5, d9@entry= =3D11.5, da=3D4.5, da@entry=3D12.5 ``` Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28987 Tested-By: Guinevere Larsen Approved-By: Tom Tromey --=20 You are receiving this mail because: You are on the CC list for the bug.=