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@lists.llvm.org
          Reporter: yangyib...@hust.edu.cn
                CC: jdevliegh...@apple.com, llvm-b...@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 (杨已彪) <yangyib...@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.
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to