From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A7D2B3893678; Tue, 5 Jan 2021 15:31:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7D2B3893678 From: "yangyibiao at outlook dot com" To: gdb-prs@sourceware.org Subject: [Bug breakpoints/27151] New: Step will skip subsequent statements for malloc functions Date: Tue, 05 Jan 2021 15:31:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: breakpoints X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yangyibiao at outlook dot com 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 cc 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 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: Tue, 05 Jan 2021 15:31:42 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27151 Bug ID: 27151 Summary: Step will skip subsequent statements for malloc functions Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: breakpoints Assignee: unassigned at sourceware dot org Reporter: yangyibiao at outlook dot com CC: vries at gcc dot gnu.org Target Milestone: --- Consider the following test case: --- $ cat small.c #include #include #include int main() { int *p =3D (int *)malloc(sizeof(int)*4); // L7 memset(p, 0, sizeof(p)); // L8 printf("p[0] =3D %d; p[3] =3D %d\n", p[0], p[3]); // L9 return 0; // L10 } --- $ gcc -O0 -g small.c; gdb -q a.out Reading symbols from a.out... (gdb) start Temporary breakpoint 1 at 0x1195: file small.c, line 7. Starting program: /home/yibiao/DeVIL/a.out=20 Temporary breakpoint 1, main () at small.c:7 7 int *p =3D (int *)malloc(sizeof(int)*4); // L7 (gdb) step p[0] =3D 0; p[3] =3D 0 [Inferior 1 (process 66988) exited normally] (gdb) ###########################################3 We can found that L8, L9, and L10 are skipped when stepping with "step". However, p[0], p[3] are printed. That's to say, both L8 and L9 are executed= .=20 When inspecting line-table, we can found that L8, L9, L10 all in the line t= able and with "IS-STMT" is true as follows: (gdb) maint info line-table objfile: /home/yibiao/DeVIL/a.out ((struct objfile *) 0x561aabac7410) compunit_symtab: ((struct compunit_symtab *) 0x561aababd3f0) symtab: /home/yibiao/DeVIL/small.c ((struct symtab *) 0x561aababd470) linetable: ((struct linetable *) 0x561aabb08790): INDEX LINE ADDRESS IS-STMT=20 0 6 0x0000555555555189 Y=20 1 7 0x0000555555555195 Y=20 2 8 0x00005555555551a3 Y=20 3 9 0x00005555555551b9 Y=20 4 9 0x00005555555551c1 Y=20 5 10 0x00005555555551dc Y=20 6 11 0x00005555555551e1 Y=20 7 END 0x00005555555551e3 Y Thus, we believe this should be a bug of GDB -------------gdb and gcc version------------- $ gdb --version GNU gdb (GDB) 11.0.50.20201224-git Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. $ gcc --version gcc (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Note that, we reported this issue in PR27120. At that time, we are not sure whether this is a bug or a feature. Thanks to the detailed steps in PR27126= by Tom de Vries, we can confirm that this should be a bug of GDB. --=20 You are receiving this mail because: You are on the CC list for the bug.=