[lldb-dev] [Bug 46046] New: inconsistent behaviors at -O1

via lldb-dev lldb-dev at lists.llvm.org
Sat May 23 08:22:16 PDT 2020


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

            Bug ID: 46046
           Summary: inconsistent behaviors at -O1
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: RESOLVED
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: yangyibiao at hust.edu.cn
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org
            Status: RESOLVED
        Resolution: DUPLICATE

$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ lldb --version
lldb version 11.0.0
  clang revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af
  llvm revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af


$ clang -O1 -g small.c
$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b 22
Breakpoint 1: where = a.out`foo + 37 at small.c:22:3, address =
0x0000000000401135
(lldb) r
Process 367418 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 367418 exited with status = 0 (0x00000000) 
(lldb)



/*********************************************
As showed above, when setting breakpoint at Line 22, lldb wrongly exit
directly.
Line 22 is actually executed in step-i as follow:
*********************************************/


$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 1 at small.c:26:3, address =
0x0000000000401151
(lldb) r
Process 367312 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 367312 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401151 a.out`main at small.c:26:3
   23   }
   24   
   25   int main() {
-> 26     foo();
   27     return 0;
   28   }
(lldb) si -c 9
Process 367312 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x000000000040113f a.out`foo at small.c:22:3
   19     if (pn->p==(void *)ph)
   20       ph->f = &nd;
   21   
-> 22     return 0;
   23   }
   24   
   25   int main() {
(lldb) 




$ cat small.c
struct sn {
  struct sn *n;
  struct sn *p;
} nd;

struct sh {
  struct sn *f;
} hs[2];

struct sh *h=&hs[0];

int foo() {
  nd.p = (void*)h;
  h->f = &nd;

  struct sn *pn=h->f;
  struct sh *ph=h;

  if (pn->p==(void *)ph)
    ph->f = &nd;

  return 0;
}

int main() {
  foo();
  return 0;
}

--- Comment #1 from Yibiao Yang (杨已彪) <yangyibiao at hust.edu.cn> ---


*** This bug has been marked as a duplicate of bug 46045 ***

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200523/b2ed710c/attachment.html>


More information about the lldb-dev mailing list