<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Inconsistent debug info between break and stepi at -O1"
   href="https://bugs.llvm.org/show_bug.cgi?id=46041">46041</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inconsistent debug info between break and stepi at -O1
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yangyibiao@hust.edu.cn
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23523" name="attach_23523" title="the binary">attachment 23523</a> <a href="attachment.cgi?id=23523&action=edit" title="the binary">[details]</a></span>
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 5 
Breakpoint 1: where = a.out`f + 21 at small.c:5:1, address = 0x0000000000401125
(lldb) r
Process 46982 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 46982 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401125 a.out`f(x=-216) at small.c:5:1
   2      if (x==-216 || x==-132)
   3         return 1;
   4      return 0;
-> 5    }
   6    
   7    int main () {
   8      volatile int i;
(lldb) fr var x
(int) x = -216
(lldb) 



/************************************
As showed, when setting breakpoint on Line 5 (first hit), the value of "x" is
-216.
However, when step-i to Line 5, the value of "x" is -230 which is as expected:
************************************/



$ 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 + 5 at small.c:9:10, address =
0x0000000000401135
(lldb) r
Process 45549 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 45549 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401135 a.out`main at small.c:9:10
   6    
   7    int main () {
   8      volatile int i;
-> 9      for (i = -230; i < -120; i++)
   10       if (f(i) != (i==-216 || i==-132))
   11         return 1;
   12     return 0;
(lldb) si -c 14
Process 45549 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x0000000000401128 a.out`f(x=-230) at small.c:5:1
   2      if (x==-216 || x==-132)
   3         return 1;
   4      return 0;
-> 5    }
   6    
   7    int main () {
   8      volatile int i;
(lldb) fr var x
(int) x = -230
(lldb)



/******************* the small.c *************/

$ cat small.c
int f(int x) {
  if (x==-216 || x==-132)
     return 1;
  return 0;
}

int main () {
  volatile int i;
  for (i = -230; i < -120; i++)
    if (f(i) != (i==-216 || i==-132))
      return 1;
  return 0;
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>