[llvm-bugs] [Bug 46042] New: Inconsistent debug info between step and stepi at -O1

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 22 10:37:24 PDT 2020


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

            Bug ID: 46042
           Summary: Inconsistent debug info between step and stepi at -O1
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: yangyibiao at hust.edu.cn
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

Created attachment 23524
  --> https://bugs.llvm.org/attachment.cgi?id=23524&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 main
Breakpoint 1: where = a.out`main + 1 at small.c:26:8, address =
0x00000000004011a1
(lldb) r
Process 79491 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 79491 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004011a1 a.out`main at small.c:26:8
   23   }
   24   
   25   int main() {
-> 26     if (!f("u3"))
   27       return 1;
   28     return 0;
   29   }
(lldb) step
Process 79491 stopped
* thread #1, name = 'a.out', stop reason = step in
    frame #0: 0x0000000000401157 a.out`f(p="u3") at small.c:9:11
   6      int s=0, m=3, l=3, lm=6, r;
   7    
   8      while(1) {
-> 9        m = (s+l)/2;
   10       if (lm==m) {
   11         break;
   12       }
(lldb) step
Process 79491 stopped
* thread #1, name = 'a.out', stop reason = step in
    frame #0: 0x0000000000401164 a.out`f(p="u3") at small.c:10:11
   7    
   8      while(1) {
   9        m = (s+l)/2;
-> 10       if (lm==m) {
   11         break;
   12       }
   13       r = strcmp(p, T[m]);
(lldb) step
Process 79491 stopped
* thread #1, name = 'a.out', stop reason = step in
    frame #0: 0x000000000040116c a.out`f(p="u3") at small.c:13:19
   10       if (lm==m) {
   11         break;
   12       }
-> 13       r = strcmp(p, T[m]);
   14       if (r < 0) {
   15         l = m;
   16       } else if (r > 0) {
(lldb) fr var s
(int) s = 1
(lldb) 



/*********************************************
As showed above, step into Line 13 (first hit), the value of "s" is 1.
When using step-i, the value of "s" is 0 which is as expected. 
*********************************************/

$ 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:8, address =
0x00000000004011a1
(lldb) r
Process 79554 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 79554 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004011a1 a.out`main at small.c:26:8
   23   }
   24   
   25   int main() {
-> 26     if (!f("u3"))
   27       return 1;
   28     return 0;
   29   }
(lldb) si -c 12
Process 79554 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x000000000040116c a.out`f(p="u3") at small.c:13:19
   10       if (lm==m) {
   11         break;
   12       }
-> 13       r = strcmp(p, T[m]);
   14       if (r < 0) {
   15         l = m;
   16       } else if (r > 0) {
(lldb) fr var s
(int) s = 0
(lldb)



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

char *T[3] = {"u1", "u2", "u3"};

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

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

int main() {
  if (!f("u3"))
    return 1;
  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/a81ecbd5/attachment.html>


More information about the llvm-bugs mailing list