public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/27151] New: Step will skip subsequent statements for malloc functions
@ 2021-01-05 15:31 yangyibiao at outlook dot com
  2021-01-06  0:57 ` [Bug breakpoints/27151] " yangyibiao at outlook dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: yangyibiao at outlook dot com @ 2021-01-05 15:31 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27151

            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 <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  int *p = (int *)malloc(sizeof(int)*4); // L7
  memset(p, 0, sizeof(p));  // L8
  printf("p[0] = %d; p[3] = %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 

Temporary breakpoint 1, main () at small.c:7
7         int *p = (int *)malloc(sizeof(int)*4); // L7
(gdb) step
p[0] = 0; p[3] = 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. 


When inspecting line-table, we can found that L8, L9, L10 all in the line table
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 
0      6      0x0000555555555189 Y 
1      7      0x0000555555555195 Y 
2      8      0x00005555555551a3 Y 
3      9      0x00005555555551b9 Y 
4      9      0x00005555555551c1 Y 
5      10     0x00005555555551dc Y 
6      11     0x00005555555551e1 Y 
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 <http://gnu.org/licenses/gpl.html>
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.


========================================================================
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-01-14  9:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 15:31 [Bug breakpoints/27151] New: Step will skip subsequent statements for malloc functions yangyibiao at outlook dot com
2021-01-06  0:57 ` [Bug breakpoints/27151] " yangyibiao at outlook dot com
2021-01-06 12:22 ` vries at gcc dot gnu.org
2021-01-06 12:22 ` vries at gcc dot gnu.org
2021-01-06 12:25 ` vries at gcc dot gnu.org
2021-01-06 12:28 ` vries at gcc dot gnu.org
2021-01-06 13:44 ` yangyibiao at outlook dot com
2021-01-06 13:53 ` vries at gcc dot gnu.org
2021-01-06 15:37 ` vries at gcc dot gnu.org
2021-01-14  9:35 ` cvs-commit at gcc dot gnu.org
2021-01-14  9:41 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).