public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/27179] New: function call with complex switch-case will be skipped by gdb
@ 2021-01-13  5:54 yangyibiao at outlook dot com
  2021-01-13  5:54 ` [Bug breakpoints/27179] " yangyibiao at outlook dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: yangyibiao at outlook dot com @ 2021-01-13  5:54 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 27179
           Summary: function call with complex switch-case will be skipped
                    by gdb
           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 case:
------------------
$ cat small.c
#include <stdio.h>

void foo (int x, int y)
{
  switch (x) {
    case 0: break;
    case 1: break;
    case 2: break;
    case 3:
      for (int z = 0; z < ({ if (y) break; 5; }); z++)
          break;
    case 4: break;
        default: break;
  }
}

int main ()
{
  foo (1, 1);  // L1
  foo (2, 1);  // L2
  printf("hello world!");  // L3
  return 0;
}

--------------------

$ gcc -O0 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x11ac: file small.c, line 19.
Starting program: /home/yibiao/DeVIL/a.out 

Temporary breakpoint 1, main () at small.c:19
19        foo (1, 1);  // L1
(gdb) s
hello world![Inferior 1 (process 87566) exited normally]
(gdb) 


##########################3
L2 and L3 are both executed. However, we can found that L2 is skipped by gdb.
When stepping at instruction level or set breakpoints at L2, L2 will be hit by
gdb.
When examing the line table, L2 is indeed has debug info as follow:

(gdb) maint info line-table
objfile: /home/yibiao/DeVIL/a.out ((struct objfile *) 0x56479b754400)
compunit_symtab: ((struct compunit_symtab *) 0x56479b74bea0)
symtab: /home/yibiao/DeVIL/small.c ((struct symtab *) 0x56479b74bf20)
linetable: ((struct linetable *) 0x56479b795080):
INDEX  LINE   ADDRESS            IS-STMT 
0      4      0x0000555555555149 Y 
1      10     0x0000555555555181 Y 
2      10     0x0000555555555188 Y 
3      10     0x0000555555555189 Y 
4      12     0x0000555555555197 Y 
5      13     0x000055555555519a Y 
6      12     0x000055555555519d Y 
7      10     0x00005555555551a0 Y 
8      15     0x00005555555551a1 Y 
9      18     0x00005555555551a4 Y 
10     19     0x00005555555551ac Y 
11     20     0x00005555555551bb Y 
12     21     0x00005555555551ca Y 
13     22     0x00005555555551db Y 
14     23     0x00005555555551e0 Y 
15     END    0x00005555555551e2 Y 
(gdb) 



$ gcc --version; gdb --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.

GNU gdb (GDB) 11.0.50.20210113-git
Copyright (C) 2021 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.

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

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

end of thread, other threads:[~2021-01-21 12:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  5:54 [Bug breakpoints/27179] New: function call with complex switch-case will be skipped by gdb yangyibiao at outlook dot com
2021-01-13  5:54 ` [Bug breakpoints/27179] " yangyibiao at outlook dot com
2021-01-13  5:57 ` yangyibiao at outlook dot com
2021-01-13 10:30 ` [Bug breakpoints/27179] Handle stepping into function with broken line number info vries at gcc dot gnu.org
2021-01-17 19:43 ` tromey at sourceware dot org
2021-01-18 10:52 ` vries at gcc dot gnu.org
2021-01-21 12:45 ` [Bug breakpoints/27179] Ensure a step failure degrades to next instead of continue 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).