https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95077

            Bug ID: 95077
           Summary: Wrong backtrace infromation at O1
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: massarelli at diag dot uniroma1.it
  Target Milestone: ---

At line 14 it seems that backtrace information is wrong (pointing at function
dm).

$ cat a.c
static int a, c, d, e;
static void dm() {
  int b = 0;
  for (; b < 56; b++)
    a = b;
}
int main() {
  int k;
  dm();
  d = 0;
  for (; d != 38; d = d + 1)
    e = 0;
  for (; e < 3; e++)
    for (k = 0; k < 4; k++)
      printf("", c);
}

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/tmp/gcc_build --disable-multilib
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200511 (experimental) (GCC) 


$ lldb -v
lldb version 11.0.0
  clang revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
  llvm revision c25b20c0f6c13d68dbc2e185764082d61ae4a132

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ gcc -O1 -g -o opt a.c

$ lldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 14
Breakpoint 1: 2 locations.
(lldb) r
Process 172 launched: opt' (x86_64)
Process 172 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400531 opt`main at a.c:14:17
   11     for (; d != 38; d = d + 1)
   12       e = 0;
   13     for (; e < 3; e++)
-> 14       for (k = 0; k < 4; k++)
   15         printf("", c);
   16   }
(lldb) bt
* thread #1, name = 'opt', stop reason = breakpoint 1.1
  * frame #0: 0x0000000000400531 opt`main at a.c:14:17
    frame #1: 0x0000000000400531 opt`main at a.c:9
    frame #2: 0x00007ffff7a05b97 libc.so.6`__libc_start_main(main=(opt`main at
a.c:7:12), argc=1, argv=0x00007fffffffe5b8, init=<unavailable>,
fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe5a8) at
libc-start.c:310
    frame #3: 0x000000000040043a opt`_start + 42
(lldb) 

$ gdb opt
Reading symbols from opt...done.
(gdb) b -l 14
Breakpoint 1 at 0x400531: -source a.c -line 14. (2 locations)
(gdb) r
Starting program: opt 
Breakpoint 1, main () at a.c:9
9         dm();
(gdb) s
dm () at a.c:14
14          for (k = 0; k < 4; k++)
(gdb)

Reply via email to