[llvm-bugs] [Bug 46032] New: inconsistent behaviors at -O0

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 21 23:10:38 PDT 2020


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

            Bug ID: 46032
           Summary: inconsistent behaviors at -O0
           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: yangyibiao at hust.edu.cn
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

Created attachment 23517
  --> https://bugs.llvm.org/attachment.cgi?id=23517&action=edit
the binary

$ 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 -O0 -g small.c

$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b 13
Breakpoint 1: where = a.out`f + 90 at small.c:13:5, address =
0x000000000040118a
(lldb) r
Process 336948 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 336948 exited with status = 0 (0x00000000)
(lldb) 


/************************************
As showed, when setting breakpoint on Line 13, lldb exit directly.
However, when step-i, Line 13 is hit by lldb 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 + 15 at small.c:24:3, address =
0x00000000004011cf
(lldb) r
Process 336902 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 336902 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004011cf a.out`main at small.c:24:3
   21   }
   22   
   23   int main() {
-> 24     f("u3");
   25     return 0;
   26   }
(lldb) si -c 674
Process 336902 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x000000000040118f a.out`f(p="u3") at small.c:13:16
   10       r = strcmp(p, c[m]);
   11       if(r<0) {
   12         l = m;
-> 13       } else if(r>0) {
   14         s = m;
   15       } else {
   16         return 1;
(lldb)



$ cat small.c
#include <string.h>
char *c[3]={"u1", "u2", "u3"};

int f(char *p)
{
  int r, m=3, s=0, l=3;

  while(1) {
    m = (s+l)/2;
    r = strcmp(p, c[m]);
    if(r<0) {
      l = m;
    } else if(r>0) {
      s = m;
    } else {
      return 1;
    }
  }

  return 0;
}

int main() {
  f("u3");
  return 0;
}

-- 
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/20200522/a48fc6ac/attachment-0001.html>


More information about the llvm-bugs mailing list