[llvm-bugs] [Bug 46014] New: inconsistent behaviors for calling function va_arg() at -O3 (-O0 is correct)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 21 03:14:59 PDT 2020


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

            Bug ID: 46014
           Summary: inconsistent behaviors for calling function va_arg()
                    at -O3 (-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

$ 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



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

void f(int i, ...) {
  int j;
  double d;
  char *s;
  va_list ap;
  va_start(ap, i);
  j = va_arg(ap, int);
  d = va_arg(ap, double);
  s = va_arg(ap, char *);
  va_end(ap);
}

int main() {
  f(1);
  return 0;
}



$ clang -g -O3 small.c; 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 =
0x00000000004011e1
(lldb) r
Process 139129 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 139129 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004011e1 a.out`main at small.c:16:3
   13   }
   14   
   15   int main() {
-> 16     f(1);
   17     return 0;
   18   }
(lldb) si -c 26
Process 139129 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x00000000004011c7 a.out`f(i=<unavailable>) at small.c:11:7
   8      va_start(ap, i);
   9      j = va_arg(ap, int);
   10     d = va_arg(ap, double);
-> 11     s = va_arg(ap, char *);
   12     va_end(ap);
   13   }
   14   
(lldb)



/******************************
As showed above, Line 11 is hit by lldb when using "instruction level" step.
However, Line 11 is not hit by lldb when setting breakpoint on it as follow:
******************************/


$ clang -g -O3 small.c; lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b 11
Breakpoint 1: where = a.out`f + 142 at small.c:11:7, address =
0x000000000040119e
(lldb) r
Process 138683 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 138683 exited with status = 0 (0x00000000) 
(lldb)

-- 
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/20200521/470e8735/attachment.html>


More information about the llvm-bugs mailing list