[llvm-bugs] [Bug 46010] New: Confusing backtrace at -O2

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 20 11:05:10 PDT 2020


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

            Bug ID: 46010
           Summary: Confusing backtrace at -O2
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: qrzhang at gatech.edu
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

When stopped at line 4, the backtrack should be main->b. With "-O2", it gives
main->d->b. See the following example. At "-O2", only breakpoint 1.3 was hit.


$ clang-trunk -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
58684fbb6f2e6871f3f96ac8c7166a7d7486e971)



#expected backtrace
$ clang-trunk -g abc.c
$ lldb-trunk -s cmds -b a.out
(lldb) b 4
Breakpoint 1: where = a.out`b + 18 at abc.c:4:4, address = 0x0000000000400492
(lldb) r
Process 1631 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400492 a.out`b at abc.c:4:4
   1    int a;
   2    void b() {
   3      int *c = &a;
-> 4      *c = 0; // stop here
   5    }
   6    void d() { b(); }
   7    int main() {

Process 1631 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) bt
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
  * frame #0: 0x0000000000400492 a.out`b at abc.c:4:4
    frame #1: 0x00000000004004b9 a.out`main at abc.c:8:3
    frame #2: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
    frame #3: 0x00000000004003ba a.out`_start + 42
(lldb) kill



#backtrace at -O2
$ clang-trunk -g abc.c -O2
$ lldb-trunk -s cmds -b a.out
(lldb) b 4
Breakpoint 1: 3 locations.
(lldb) r
Process 17759 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.3
    frame #0: 0x00000000004004a0 a.out`main [inlined] b at abc.c:4:6
   1    int a;
   2    void b() {
   3      int *c = &a;
-> 4      *c = 0; // stop here
   5    }
   6    void d() { b(); }
   7    int main() {

Process 17759 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) bt
* thread #1, name = 'a.out', stop reason = breakpoint 1.3
  * frame #0: 0x00000000004004a0 a.out`main [inlined] b at abc.c:4:6
    frame #1: 0x00000000004004a0 a.out`main [inlined] d at abc.c:6
    frame #2: 0x00000000004004a0 a.out`main at abc.c:9
    frame #3: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
    frame #4: 0x00000000004003ba a.out`_start + 42
(lldb) kill


$ cat abc.c
int a;
void b() {
  int *c = &a;
  *c = 0; // stop here
}
void d() { b(); }
int main() {
  b();
  d();
}

$ cat cmds
b 4
r
bt
kill
q

-- 
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/20200520/7facaa67/attachment-0001.html>


More information about the llvm-bugs mailing list