[llvm-bugs] [Bug 46398] New: Wrong backtrace infromation at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 19 06:12:30 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46398

            Bug ID: 46398
           Summary: Wrong backtrace infromation at Og
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: massarelli at diag.uniroma1.it
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

At line 10 backtrace information is wrong.

$ cat a.c
int k = 0, a;
int *b = &a;
int c = 2;
short d = 2;
void e() { --d; }
int *f() {
  if (a)
    e();
  else
    return b;
}
int main() {
  f();
  f();
}

$ cat -n a.c
     1  int k = 0, a;
     2  int *b = &a;
     3  int c = 2;
     4  short d = 2;
     5  void e() { --d; }
     6  int *f() {
     7    if (a)
     8      e();
     9    else
    10      return b;
    11  }
    12  int main() {
    13    f();
    14    f();
    15  }

$  clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
c143db3b1032042193c152790bcefe34365e6d6c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

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

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

$ clang -Og -g -o out a.c

$ lldb out 
(lldb) target create "out"
Current executable set to 'out' (x86_64).
(lldb) b main
Breakpoint 1: where = out`main + 1 at a.c:13:3, address = 0x00000000004004b1
(lldb) r
Process 123 launched: 'out' (x86_64)
Process 123 stopped
* thread #1, name = 'out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004b1 out`main at a.c:13:3
   10       return b;
   11   }
   12   int main() {
-> 13     f();
   14     f();
   15   }
(lldb) n
Process 123 stopped
* thread #1, name = 'out', stop reason = step over
    frame #0: 0x00000000004004b6 out`main at a.c:14:3
   11   }
   12   int main() {
   13     f();
-> 14     f();
   15   }
(lldb) s
Process 123 stopped
* thread #1, name = 'out', stop reason = step in
    frame #0: 0x0000000000400491 out`f at a.c:7:7
   4    short d = 2;
   5    void e() { --d; }
   6    int *f() {
-> 7      if (a)
   8        e();
   9      else
   10       return b;
(lldb) bt
* thread #1, name = 'out', stop reason = step in
  * frame #0: 0x0000000000400491 out`f at a.c:7:7
    frame #1: 0x00000000004004bb out`main at a.c:14:3
    frame #2: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
    frame #3: 0x00000000004003ba out`_start + 42
(lldb) s
Process 123 stopped
* thread #1, name = 'out', stop reason = step in
    frame #0: 0x00000000004004a1 out`f at a.c:10:12
   7      if (a)
   8        e();
   9      else
-> 10       return b;
   11   }
   12   int main() {
   13     f();
(lldb) bt
* thread #1, name = 'out', stop reason = step in
  * frame #0: 0x00000000004004a1 out`f at a.c:10:12
    frame #1: 0x0000000000601040 out`k + 4
    frame #2: 0x00000000004004bb out`main at a.c:14:3
    frame #3: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
    frame #4: 0x00000000004003ba out`_start + 42
(lldb) exit


$ gdb out
(gdb) b main
Breakpoint 1 at 0x4004b1: file a.c, line 13.
(gdb) r
Starting program: out 
Breakpoint 1, main () at a.c:13
13        f();
(gdb) s
f () at a.c:7
7         if (a)
(gdb) s
10          return b;
(gdb) s
11      }
(gdb) s
main () at a.c:14
14        f();
(gdb) s
f () at a.c:7
7         if (a)
(gdb) bt
#0  f () at a.c:7
#1  0x00000000004004bb in main () at a.c:14
(gdb) s
10          return b;
(gdb) bt
#0  f () at a.c:10
#1  0x00000000004004bb in main () at a.c:14
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200619/3e8d690d/attachment-0001.html>


More information about the llvm-bugs mailing list