[lldb-dev] [Bug 46030] New: inconsistent behaviors at -O1 (-O0 is correct)

via lldb-dev lldb-dev at lists.llvm.org
Thu May 21 21:03:27 PDT 2020


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

            Bug ID: 46030
           Summary: inconsistent behaviors at -O1 (-O0 is correct)
           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 23516
  --> https://bugs.llvm.org/attachment.cgi?id=23516&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 -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 10
Breakpoint 1: where = a.out`f + 126 at small.c:10:12, address =
0x000000000040118e
(lldb) r
Process 310513 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 310513 exited with status = 0 (0x00000000) 
(lldb) 



/************************************
As showed, when setting breakpoint on Line 10, lldb exit directly.
However, when step-i, Line 10 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 + 1 at small.c:16:3, address =
0x00000000004011c1
(lldb) r
Process 310470 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 310470 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004011c1 a.out`main at small.c:16:3
   13   }
   14   
   15   int main() {
-> 16     f(1, "ab");
   17   }
   18   
(lldb) si -c 25
Process 310470 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x00000000004011ac a.out`f(p=<unavailable>) at small.c:10:12
   7      va_start(ap, p);
   8      while (1) {
   9          v = va_arg(ap, char *);
-> 10         if (!v) break;
   11     }
   12     va_end(ap);
   13   }
(lldb) 



$ cat small.c
#include <stdarg.h>

void f(int p, ...) {
  va_list ap;
  char *v;

  va_start(ap, p);
  while (1) {
      v = va_arg(ap, char *);
      if (!v) break;
  }
  va_end(ap);
}

int main() {
  f(1, "ab");
}

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


More information about the lldb-dev mailing list